Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/core/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type DateView = 'month' | 'year' | 'decade' | 'century';

type DateUnitSource = TimeIntervalConfig | Partial<Record<TimeInterval, unknown>>;

interface DatesDifferences {
export interface DatesDifferences {
year: boolean;
month: boolean;
day: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
return mode === 'ignore' || mode === 'none' ? mode : 'hide';
},

getTicksCountInRange(ticks, valueKey, range) {
getTicksCountInRange(ticks, valueKey, range): number {
let i = 1;

if (ticks.length > 1) {
Expand All @@ -40,7 +40,7 @@ export default {
return i;
},

areLabelsOverlap(bBox1, bBox2, spacing, alignment) {
areLabelsOverlap(bBox1, bBox2, spacing, alignment): boolean {
const horizontalInverted = bBox1.x > bBox2.x;
const verticalInverted = bBox1.y > bBox2.y;
let x1 = bBox1.x;
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/viz/axes/axes_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const calculateCanvasMargins = function (bBoxes, canvas) {
});
};

export const measureLabels = function (items) {
export const measureLabels = function (items): void {
items.forEach((item) => {
const label = item.getContentContainer();
item.labelBBox = label ? label.getBBox() : {
Expand Down
8 changes: 4 additions & 4 deletions packages/devextreme/js/__internal/viz/axes/constant_line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ export default function createConstantLine(axis, options) {
return this.label;
},

removeLabel() {
removeLabel(): void {
this.label && this.label.remove();
},

updatePosition(animate) {
updatePosition(animate): void {
const canvas = axis._getCanvasStartEnd();

const coord = axis._getConstantLinePos(this.getParsedValue(), canvas.start, canvas.end);
Expand All @@ -115,12 +115,12 @@ export default function createConstantLine(axis, options) {
}
},

saveCoords() {
saveCoords(): void {
lastStoredCoordinates = storedCoord;
storedCoord = this.coord;
},

resetCoordinates() {
resetCoordinates(): void {
storedCoord = lastStoredCoordinates;
},
};
Expand Down
14 changes: 7 additions & 7 deletions packages/devextreme/js/__internal/viz/axes/datetime_breaks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { dateUtils } from '@ts/core/utils/date';

const days = [0, 1, 2, 3, 4, 5, 6];

function getWeekendDays(workdays) {
function getWeekendDays(workdays): number[] {
return days.filter((day) => !workdays.some((workDay) => workDay === day));
}

function getNextDayIndex(dayIndex) {
function getNextDayIndex(dayIndex): number {
return (dayIndex + 1) % 7;
}

function dayBetweenWeekend(weekend, day) {
function dayBetweenWeekend(weekend, day): boolean {
let { start } = weekend;
const { end } = weekend;

Expand All @@ -34,7 +34,7 @@ function dayBetweenWeekend(weekend, day) {
return false;
}

function getDaysDistance(day, end) {
function getDaysDistance(day, end): number {
let length = 0;

while (day !== end) {
Expand Down Expand Up @@ -70,7 +70,7 @@ function separateBreak(scaleBreak, day) {
return result;
}

function getWeekEndDayIndices(workDays) {
function getWeekEndDayIndices(workDays): number[] {
const indices = getWeekendDays(workDays);

if (indices.length < 7) {
Expand Down Expand Up @@ -139,7 +139,7 @@ function generateDateBreaksForWeekend(min, max, weekendDayIndices) {
function excludeWorkDaysFromWeekEndBreaks(breaks, exactWorkDays) {
const result = breaks.slice();
let i;
const processWorkDay = function (workday) {
const processWorkDay = function (workday): void {
workday = dateUtils.trimTime(new Date(workday));
if (result[i].from <= workday && result[i].to > workday) {
const separatedBreak = separateBreak(result[i], workday);
Expand All @@ -162,7 +162,7 @@ function excludeWorkDaysFromWeekEndBreaks(breaks, exactWorkDays) {

function generateBreaksForHolidays(min, max, holidays, weekendDayIndices) {
let day;
const dayInWeekend = function (dayIndex) {
const dayInWeekend = function (dayIndex): boolean {
return dayIndex === day;
};
const adjustedMin = dateUtils.trimTime(min);
Expand Down
55 changes: 28 additions & 27 deletions packages/devextreme/js/__internal/viz/axes/polar_axes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import constants from '@ts/viz/axes/axes_constants';
import { calculateCanvasMargins, measureLabels } from '@ts/viz/axes/axes_utils';
import { tick } from '@ts/viz/axes/tick';
import xyAxes from '@ts/viz/axes/xy_axes';
import type { Coords } from '@ts/viz/core/types';
import {
convertPolarToXY, convertXYToPolar,
getCosAndSin, getDistance,
Expand Down Expand Up @@ -73,7 +74,7 @@ const circularAxes = {
};
},

applyMargins() {
applyMargins(): void {
const margins = this._calculateValueMargins(this._majorTicks);

const br = this._translator.getBusinessRange();
Expand Down Expand Up @@ -107,15 +108,15 @@ const circularAxes = {
return [options.startAngle, options.endAngle];
},

_updateRadius(canvas) {
_updateRadius(canvas): void {
const rad = _min(
canvas.width - canvas.left - canvas.right,
canvas.height - canvas.top - canvas.bottom,
) / 2;
this._radius = rad < 0 ? 0 : rad;
},

_updateCenter(canvas) {
_updateCenter(canvas): void {
this._center = {
x: canvas.left + (canvas.width - canvas.right - canvas.left) / 2,
y: canvas.top + (canvas.height - canvas.top - canvas.bottom) / 2,
Expand All @@ -133,7 +134,7 @@ const circularAxes = {
return this._renderer.circle();
},

_updateAxisElementPosition() {
_updateAxisElementPosition(): void {
const center = this.getCenter();
this._axisElement.attr({ cx: center.x, cy: center.y, r: this.getRadius() });
},
Expand All @@ -146,7 +147,7 @@ const circularAxes = {
return this._options.firstPointOnStartAngle;
},

_validateOptions(options) {
_validateOptions(options): void {
const that = this;
let { originValue } = options;
const wholeRange = options.wholeRange = {};
Expand Down Expand Up @@ -195,7 +196,7 @@ const circularAxes = {
return margins;
},

_updateLabelsPosition() {
_updateLabelsPosition(): void {
const that = this;

measureLabels(that._majorTicks);
Expand All @@ -212,11 +213,11 @@ const circularAxes = {
return this._options.firstPointOnStartAngle || (this._options.type !== constants.discrete);
},

_getTranslatedCoord(value, offset) {
_getTranslatedCoord(value, offset): number {
return this._translator.translate(value, offset) - HALF_PI_ANGLE;
},

_getCanvasStartEnd() {
_getCanvasStartEnd(): { start: number; end: number } {
return {
start: 0 - HALF_PI_ANGLE,
end: 360 - HALF_PI_ANGLE,
Expand Down Expand Up @@ -249,7 +250,7 @@ const circularAxes = {
);
},

_getStripLabelCoords(from, to) {
_getStripLabelCoords(from, to): { x: number; y: number; align: string } {
const that = this;
const coords = that._getStripGraphicAttributes(from, to);
const angle = coords.startAngle + (coords.endAngle - coords.startAngle) / 2;
Expand All @@ -275,12 +276,12 @@ const circularAxes = {
return this._createPathElement(this._getConstantLineGraphicAttributes(value).points, attr);
},

_rotateConstantLine(line, value) {
_rotateConstantLine(line, value): void {
const { x, y } = this.getCenter();
line.rotate(value + this.getAngles()[0], x, y);
},

_getConstantLineLabelsCoords(value) {
_getConstantLineLabelsCoords(value): Coords {
const that = this;
const cosSin = getCosAndSin(-value - that.getAngles()[0]);
const halfRad = that.getRadius() / 2;
Expand All @@ -293,11 +294,11 @@ const circularAxes = {

_checkAlignmentConstantLineLabels: _noop,

_adjustDivisionFactor(val) {
_adjustDivisionFactor(val): number {
return val * 180 / (this.getRadius() * PI);
},

_getScreenDelta() {
_getScreenDelta(): number {
const angles = this.getAngles();
return abs(angles[0] - angles[1]);
},
Expand Down Expand Up @@ -410,19 +411,19 @@ const circularAxes = {
return { x: coords.x, y: coords.y, angle: this.getTranslatedAngle(angle) };
},

_getAdjustedStripLabelCoords(strip) {
_getAdjustedStripLabelCoords(strip): { translateY: number } {
const box = strip.labelBBox;

return {
translateY: strip.label.attr('y') - box.y - box.height / 2,
};
},

coordsIn(x, y) {
coordsIn(x, y): boolean {
return convertXYToPolar(this.getCenter(), x, y).r > this.getRadius();
},

_rotateTick(element, coords) {
_rotateTick(element, coords): void {
const center = this.getCenter();
element.rotate(coords.angle, center.x, center.y);
},
Expand All @@ -431,11 +432,11 @@ const circularAxes = {
return constants.validateOverlappingMode(mode);
},

_validateDisplayMode() {
_validateDisplayMode(): string {
return 'standard';
},

_getStep(boxes) {
_getStep(boxes): number {
const that = this;
const radius = that.getRadius() + (that._options.label.indentFromAxis || 0);
const maxLabelBox = boxes.reduce((prevValue, box) => {
Expand All @@ -454,7 +455,7 @@ const circularAxes = {
return constants.getTicksCountInRange(that._majorTicks, 'angle', _max(angle1, angle2));
},

_checkBoundedLabelsOverlapping(majorTicks, boxes, mode) {
_checkBoundedLabelsOverlapping(majorTicks, boxes, mode): void {
const labelOpt = this._options.label;
mode = mode || this._validateOverlappingMode(labelOpt.overlappingBehavior);
if (mode !== 'hide') {
Expand Down Expand Up @@ -483,12 +484,12 @@ const circularAxes = {
}
},

shift(margins) {
shift(margins): void {
this._axisGroup.attr({ translateX: margins.right, translateY: margins.bottom });
this._axisElementsGroup.attr({ translateX: margins.right, translateY: margins.bottom });
},

getTranslatedAngle(angle) {
getTranslatedAngle(angle): number {
const startAngle = this.getAngles()[0];
return angle + startAngle - HALF_PI_ANGLE;
},
Expand Down Expand Up @@ -583,7 +584,7 @@ export const circularSpider = extend({}, circularAxes, {
});

export const linear = {
_resetMargins() {
_resetMargins(): void {
this._reinitTranslator(this._getViewportRange());
},
_getStick: xyAxesLinear._getStick,
Expand Down Expand Up @@ -617,7 +618,7 @@ export const linear = {

_createAxisElement: xyAxesLinear._createAxisElement,

_updateAxisElementPosition() {
_updateAxisElementPosition(): void {
const centerCoord = this.getCenter();

this._axisElement.attr({
Expand All @@ -638,7 +639,7 @@ export const linear = {
];
},

_getLabelAdjustedCoord(tick) {
_getLabelAdjustedCoord(tick): Coords {
const that = this;
const { labelCoords } = tick;
const labelY = labelCoords.y;
Expand Down Expand Up @@ -683,7 +684,7 @@ export const linear = {
};
},

_getTranslatedValue(value, offset) {
_getTranslatedValue(value, offset): { x: number; y: number; angle: number } {
const startAngle = this.getAngles()[0];
const xy = convertPolarToXY(
this.getCenter(),
Expand Down Expand Up @@ -762,15 +763,15 @@ export const linear = {

_checkAlignmentConstantLineLabels: _noop,

_rotateTick(element, coords, isGridLine) {
_rotateTick(element, coords, isGridLine): void {
!isGridLine && element.rotate(coords.angle + HALF_PI_ANGLE, coords.x, coords.y);
},

_validateOverlappingMode: circularAxes._validateOverlappingMode,

_validateDisplayMode: circularAxes._validateDisplayMode,

_getStep(boxes) {
_getStep(boxes): number {
const quarter = getPolarQuarter(this.getAngles()[0]);
const spacing = this._options.label.minSpacing;
const func = quarter === 2 || quarter === 4
Expand Down
Loading
Loading