Skip to content
Open
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
8 changes: 4 additions & 4 deletions packages/devextreme/js/__internal/viz/axes/base_axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { tickGenerator } from '@ts/viz/axes/tick_generator';
import xyMethods from '@ts/viz/axes/xy_axes';
import { getParser } from '@ts/viz/components/parse_utils';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import type { Bounds } from '@ts/viz/core/types';
import type { BBox, Bounds, Coords } from '@ts/viz/core/types';

import {
adjustVisualRange,
Expand Down Expand Up @@ -604,7 +604,7 @@ export let Axis = class Axis {
declare _getConstantLineLabelsCoords: (
value: number,
labelOptions: ThemeValue,
) => { x: number; y: number };
) => Coords;

declare _getAdjustedStripLabelCoords: (strip: ThemeValue) => LabelTranslation;

Expand Down Expand Up @@ -964,7 +964,7 @@ export let Axis = class Axis {
_getStripGraphicAttributes(
fromPoint: number,
toPoint: number,
): { x: number; y: number; width: number; height: number } {
): BBox {
let x;
let y;
let width;
Expand Down Expand Up @@ -3391,7 +3391,7 @@ export let Axis = class Axis {
measureLabels(
canvas: ThemeValue,
withIndents?: boolean,
): { x: number; y: number; width: number; height: number } {
): BBox {
const options = this._options;
const widthAxis = options.visible ? options.width : 0;
let ticks;
Expand Down
13 changes: 2 additions & 11 deletions packages/devextreme/js/__internal/viz/axes/xy_axes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ function getRightMargin(bBox): number {
function generateRangesOnPoints(points, edgePoints, getRange) {
let i;
let length;
let maxRange = null;
const ranges = [];
let maxRange: { start: number; end: number; length: number } | null = null;
const ranges: { start: number; end: number; length: number }[] = [];
let curValue;
let prevValue;
let curRange;
Expand All @@ -189,17 +189,13 @@ function generateRangesOnPoints(points, edgePoints, getRange) {
curRange = getRange(curValue, prevValue);

if (edgePoints.indexOf(curValue) >= 0) {
// @ts-expect-error
if (!maxRange || curRange > maxRange.length) {
// @ts-expect-error
maxRange = { start: curValue, end: prevValue, length: curRange };
}
} else {
// @ts-expect-error
if (maxRange && curRange < maxRange.length) {
ranges.push(maxRange);
} else {
// @ts-expect-error
ranges.push({ start: curValue, end: prevValue, length: curRange });
}
maxRange = null;
Expand Down Expand Up @@ -239,25 +235,20 @@ function generateAutoBreaks(

const ranges = generateRangesOnPoints(sortedAllPoints, edgePoints, getRange)
.filter(({ length }) => !!length)
// @ts-expect-error
.sort((a, b) => b.length - a.length);
const epsilon = _math.min.apply(
null,
// @ts-expect-error
ranges.map((r) => r.length),
) / 1000;
const _maxAutoBreakCount = isDefined(maxAutoBreakCount)
? _math.min(maxAutoBreakCount, ranges.length)
: ranges.length;

for (let i = 0; i < _maxAutoBreakCount; i++) {
// @ts-expect-error
if (ranges[i].length >= minDiff) {
// @ts-expect-error
if (visibleRange <= ranges[i].length) {
break;
}
// @ts-expect-error
visibleRange -= ranges[i].length;
if (visibleRange > epsilon || visibleRange < -epsilon) {
// @ts-expect-error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Axis } from '@ts/viz/axes/base_axis';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import { setupWidgetPrototype } from '@ts/viz/core/helpers';
import { SeriesFamily } from '@ts/viz/core/series_family';
import type { Size } from '@ts/viz/core/types';
import {
convertVisualRangeObject, map as _map,
mergeMarginOptions, rangesAreEqual, setCanvasValues, unique,
Expand Down Expand Up @@ -56,7 +57,7 @@ function processBubbleMargin(marginOptions, bubbleSize) {
}

function estimateBubbleSize(
size: { width: number; height: number },
size: Size,
panesCount: number,
maxSize: number,
rotated: boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isNumeric as _isNumber } from '@ts/core/utils/type';
import consts from '@ts/viz/components/consts';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import { WrapperLayoutElement } from '@ts/viz/core/layout_element';
import type { Canvas } from '@ts/viz/core/types';
import type { Canvas, Size } from '@ts/viz/core/types';

const { floor, sqrt } = Math;
const _min = Math.min;
Expand Down Expand Up @@ -318,7 +318,7 @@ let LayoutManager = class LayoutManager {
panes: ThemeValue[],
rotated: boolean,
fixedSizeCallback?: (pane: ThemeValue) => PaneFixedSize,
): { width: number; height: number } | false {
): Size | false {
const options = this._options;
const { width, height, piePercentage } = options;
const percentageIsValid = _isNumber(piePercentage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BBox } from '@ts/viz/core/types';
import type { BBox, Coords } from '@ts/viz/core/types';

interface RollingStockLabel {
getBoundingRect: () => BBox;
hideInsideLabel: (coords: { x: number; y: number }) => boolean;
hideInsideLabel: (coords: Coords) => boolean;
getData: () => { value: number | string | Date };
shift: (x: number, y: number) => void;
}
Expand All @@ -21,7 +21,7 @@ export class RollingStock {
private readonly shiftFunction: (
bBox: BBox,
shiftLength: number,
) => { x: number; y: number };
) => Coords;

private readonly initialPosition: number;

Expand All @@ -30,7 +30,7 @@ export class RollingStock {
constructor(
label: RollingStockLabel,
isRotated: boolean,
shiftFunction: (bBox: BBox, shiftLength: number) => { x: number; y: number },
shiftFunction: (bBox: BBox, shiftLength: number) => Coords,
) {
const bBox = label.getBoundingRect();
const { x } = bBox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import eventsEngine from '@ts/events/core/events_engine';
import { end as dragEventEnd, move as dragEventMove, start as dragEventStart } from '@ts/events/drag';
import { fireEvent } from '@ts/events/utils/index';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import type { Bounds, Canvas } from '@ts/viz/core/types';
import type { Bounds, Canvas, Coords } from '@ts/viz/core/types';

import { Translator2D } from '../translators/translator2d';

Expand All @@ -29,7 +29,7 @@ interface ScrollBarLayoutOptions {
}

interface ScrollBarPointerEvent extends EngineEvent {
offset: { x: number; y: number };
offset: Coords;
}

interface ScrollBarRange {
Expand All @@ -41,7 +41,7 @@ interface ScrollBarDragEvent {
type: string;
originalEvent: ScrollBarPointerEvent;
target: ThemeValue;
offset: { x: number; y: number };
offset: Coords;
scrollRange: ScrollBarRange | undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default {
const rotated = chart.option('rotated');
const { actionData } = zoomAndPan;
const { options } = zoomAndPan;
let zoomStarted = true;
let zoomStarted: boolean | number = true;

if (actionData.fallback) {
// @ts-expect-error
Expand All @@ -311,7 +311,6 @@ export default {
getFilteredAxes(axes).forEach((axis) => {
axis.handleZooming(null, { start: true }, e, actionField);
});
// @ts-expect-error
zoomStarted = axes.length;
}
zoomStarted && chart._requestChange(['VISUAL_RANGE']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@ function sortData(data, groupsData, options, uniqueArgumentFields) {
const userCategories = isDiscrete
&& groupsData.argumentOptions
&& groupsData.argumentOptions.categories;
let sortFunction = function (data) { return data; };
let sortFunction: (
data: unknown[],
argumentField?: string,
) => unknown[] = function (data) { return data; };
const sortingMethodOption = options.sortingMethod;
let reSortCategories;

Expand All @@ -368,16 +371,13 @@ function sortData(data, groupsData, options, uniqueArgumentFields) {
&& groupsData.argumentType === STRING
&& !options._skipArgumentSorting)
) {
// @ts-expect-error
sortFunction = getSortByCategories(groupsData.categories);
} else if (sortingMethodOption === true && groupsData.argumentType !== STRING) {
// @ts-expect-error
sortFunction = sortByArgument;
reSortCategories = isDiscrete;
}

uniqueArgumentFields.forEach((field) => {
// @ts-expect-error
dataByArguments[field] = sortFunction(data, field);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/devextreme/js/__internal/viz/components/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { AlignedLayoutRect, LayoutAlignment } from '@ts/viz/core/layout_ele
import { LayoutElement, WrapperLayoutElement } from '@ts/viz/core/layout_element';
import { getFuncIri, processHatchingAttrs } from '@ts/viz/core/renderers/renderer';
import { Title } from '@ts/viz/core/title';
import type { BBox, Bounds } from '@ts/viz/core/types';
import type { BBox, Bounds, Size } from '@ts/viz/core/types';
import { enumParser, normalizeEnum, patchFontOptions } from '@ts/viz/core/utils';

const _Number = Number;
Expand Down Expand Up @@ -122,7 +122,7 @@ interface LegendItem extends CreatedLegendItem {
markerBBox: BBox;
markerSize: number;
labelBBox: BBox;
bBox: { width: number; height: number };
bBox: Size;
}

interface LegendLineItem {
Expand Down Expand Up @@ -243,7 +243,7 @@ function getSizeItem(
options: ThemeValue,
markerBBox: BBox,
labelBBox: BBox,
): { width: number; height: number } {
): Size {
const defaultXMargin = 7;
const defaultTopMargin = 4;
let width;
Expand Down Expand Up @@ -582,7 +582,7 @@ export let Legend = class Legend extends LayoutElement {

declare _items: LegendItem[];

declare _size: { width: number; height: number };
declare _size: Size;

declare _x1: number;

Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme/js/__internal/viz/core/base_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import warnings from '@ts/viz/core/errors_warnings';
import { changes, isDisabledOnServer, replaceInherit } from '@ts/viz/core/helpers';
import _Layout from '@ts/viz/core/layout';
import { Renderer } from '@ts/viz/core/renderers/renderer';
import type { Canvas } from '@ts/viz/core/types';
import type { Canvas, Size } from '@ts/viz/core/types';
import { parseScalar as _parseScalar } from '@ts/viz/core/utils';
import { areCanvasesDifferent, floorCanvasDimensions } from '@ts/viz/utils';

Expand Down Expand Up @@ -776,7 +776,7 @@ class BaseWidget extends DOMComponent<any, any> {
return this._renderer.svg();
}

getSize(): { width: number; height: number } {
getSize(): Size {
const canvas = this._canvas || {};
return { width: canvas.width, height: canvas.height };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/prefer-optional-chain */

import type { Size } from '@ts/viz/core/types';

import type { ThemeValue } from './base_theme_manager';
import { patchFontOptions as _patchFontOptions } from './utils';

Expand Down Expand Up @@ -90,7 +92,7 @@ export let LoadingIndicator = class LoadingIndicator {
this._state = STATE_HIDDEN;
}

setSize(size: { width: number; height: number }): void {
setSize(size: Size): void {
const { width, height } = size;
this._rect.attr({ width, height });
this._text.attr({ x: width / 2, y: height / 2 });
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme/js/__internal/viz/funnel/funnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BaseWidget from '@ts/viz/core/base_widget';
import type { DataSourcePluginMembers } from '@ts/viz/core/data_source';
import { plugin } from '@ts/viz/core/data_source';
import { setupWidgetPrototype } from '@ts/viz/core/helpers';
import type { Size } from '@ts/viz/core/types';

import Item from './item';
import { addAlgorithm, getAlgorithm } from './tiling';
Expand Down Expand Up @@ -56,7 +57,7 @@ class Funnel extends BaseWidget {

_proxyData!: HitTestCallback[];

_getDefaultSize(): { width: number; height: number } {
_getDefaultSize(): Size {
return { width: 400, height: 400 };
}

Expand Down Expand Up @@ -264,7 +265,7 @@ class Funnel extends BaseWidget {
}

_getMinSize(): number[] {
const adaptiveLayout: { width: number; height: number } = this._getOption('adaptiveLayout');
const adaptiveLayout: Size = this._getOption('adaptiveLayout');

return [adaptiveLayout.width, adaptiveLayout.height];
}
Expand Down
13 changes: 8 additions & 5 deletions packages/devextreme/js/__internal/viz/funnel/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import { noop } from '@ts/core/utils/common';
import { extend } from '@ts/core/utils/extend';
import type { Coords } from '@ts/viz/core/types';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import type { BBox, Coords } from '@ts/viz/core/types';
import { normalizeEnum } from '@ts/viz/core/utils';
import { Label } from '@ts/viz/series/points/label';

Expand Down Expand Up @@ -258,17 +259,20 @@ export const plugin = {
_change_TILING(): void {
const that = this;
const options = that._getOption('label');
let getCoords = getInsideLabelPosition;
let getCoords: (
coords: Coords,
bBox: BBox,
options: ThemeValue,
inverted?: boolean,
) => Coords = getInsideLabelPosition;
const inverted = that._getOption('inverted', true);
let textAlignment;

if (isOutsidePosition(options.position)) {
if (normalizeEnum(options.position) === OUTSIDE_POSITION) {
// @ts-expect-error
getCoords = options.horizontalAlignment === 'left' ? getOutsideLeftLabelPosition : getOutsideRightLabelPosition;
} else {
textAlignment = this._defaultLabelTextAlignment();
// @ts-expect-error
getCoords = options.horizontalAlignment === 'left' ? getColumnLabelLeftPosition(this._labelRect, this._rect, textAlignment) : getColumnLabelRightPosition(this._labelRect, this._rect, textAlignment);
}
}
Expand Down Expand Up @@ -298,7 +302,6 @@ export const plugin = {

const bBox = label.getBoundingRect();
const pos = correctLabelPosition(
// @ts-expect-error
getCoords(coords, bBox, options, inverted),
bBox,
that._labelRect,
Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme/js/__internal/viz/gauges/bar_gauge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { plugin as pluginLegend } from '@ts/viz/components/legend';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import { plugins as centerTemplatePlugins } from '@ts/viz/core/center_template';
import { setupWidgetPrototype } from '@ts/viz/core/helpers';
import type { Coords } from '@ts/viz/core/types';
import type { Coords, Size } from '@ts/viz/core/types';
import {
convertAngleToRendererSpace,
getCosAndSin,
Expand Down Expand Up @@ -463,7 +463,7 @@ class BarGauge extends BaseGauge {
this._baseValue = isFinite(baseValue) ? baseValue : domainMin;
}

_getDefaultSize(): { width: number; height: number } {
_getDefaultSize(): Size {
return { width: 300, height: 300 };
}

Expand Down
Loading
Loading