Skip to content

Commit bb7ecf5

Browse files
Chart: move files to TS (DevExpress#31012)
1 parent 5b99e2a commit bb7ecf5

File tree

403 files changed

+49988
-47095
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

403 files changed

+49988
-47095
lines changed

packages/devextreme/js/__internal/common/m_charts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getNextDefsSvgId } from '@js/viz/core/utils';
1+
import { getNextDefsSvgId } from '@ts/viz/core/utils';
22

33
const graphicObjects = {};
44

packages/devextreme/js/__internal/core/utils/m_math.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function isEdgeBug() {
5252
return correctValue !== value.toPrecision(precisionValue);
5353
}
5454

55-
function adjust(value, interval) {
55+
function adjust(value, interval?) {
5656
let precision = getPrecision(interval || 0) + 2;
5757
const separatedValue = value.toString().split('.');
5858
const sourceValue = value;

packages/devextreme/js/__internal/core/utils/m_svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function decodeHtmlEntities(markup) {
4141

4242
export const HIDDEN_FOR_EXPORT = 'hidden-for-export';
4343

44-
export function getSvgMarkup(element, backgroundColor) {
44+
export function getSvgMarkup(element, backgroundColor?) {
4545
return fixNamespaces(decodeHtmlEntities(getMarkup(element, backgroundColor)));
4646
}
4747

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* eslint-disable no-plusplus */
2+
/* eslint-disable @stylistic/max-len */
3+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4+
/* eslint-disable @typescript-eslint/no-unsafe-return */
5+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
6+
7+
import { map as _map } from '@ts/viz/core/utils';
8+
9+
export default {
10+
logarithmic: 'logarithmic',
11+
discrete: 'discrete',
12+
numeric: 'numeric',
13+
14+
left: 'left',
15+
right: 'right',
16+
top: 'top',
17+
bottom: 'bottom',
18+
center: 'center',
19+
20+
horizontal: 'horizontal',
21+
vertical: 'vertical',
22+
23+
convertTicksToValues(ticks) {
24+
return _map(ticks || [], (item) => item.value);
25+
},
26+
27+
validateOverlappingMode(mode) {
28+
return mode === 'ignore' || mode === 'none' ? mode : 'hide';
29+
},
30+
31+
getTicksCountInRange(ticks, valueKey, range) {
32+
let i = 1;
33+
34+
if (ticks.length > 1) {
35+
for (; i < ticks.length; i++) {
36+
if (Math.abs(ticks[i].coords[valueKey] - ticks[0].coords[valueKey]) >= range) {
37+
break;
38+
}
39+
}
40+
}
41+
return i;
42+
},
43+
44+
areLabelsOverlap(bBox1, bBox2, spacing, alignment) {
45+
const horizontalInverted = bBox1.x > bBox2.x;
46+
const verticalInverted = bBox1.y > bBox2.y;
47+
let x1 = bBox1.x;
48+
let x2 = bBox2.x;
49+
const width1 = bBox1.width;
50+
const width2 = bBox2.width;
51+
52+
if (alignment === 'left') {
53+
x1 += width1 / 2;
54+
x2 += width2 / 2;
55+
} else if (alignment === 'right') {
56+
x1 -= width1 / 2;
57+
x2 -= width2 / 2;
58+
}
59+
60+
const hasHorizontalOverlapping = horizontalInverted ? (x2 + width2 + spacing) > x1 : (x1 + width1 + spacing) > x2;
61+
const hasVerticalOverlapping = verticalInverted ? (bBox2.y + bBox2.height) > bBox1.y : (bBox1.y + bBox1.height) > bBox2.y;
62+
63+
return hasHorizontalOverlapping && hasVerticalOverlapping;
64+
},
65+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* eslint-disable func-names */
2+
/* eslint-disable @typescript-eslint/naming-convention */
3+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4+
/* eslint-disable @typescript-eslint/no-unsafe-return */
5+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
6+
7+
const _max = Math.max;
8+
9+
export const calculateCanvasMargins = function (bBoxes, canvas) {
10+
const cLeft = canvas.left;
11+
const cTop = canvas.top;
12+
const cRight = canvas.width - canvas.right;
13+
const cBottom = canvas.height - canvas.bottom;
14+
return bBoxes
15+
.reduce((margins, bBox) => {
16+
if (!bBox || bBox.isEmpty) {
17+
return margins;
18+
}
19+
return {
20+
left: _max(margins.left, cLeft - bBox.x),
21+
top: _max(margins.top, cTop - bBox.y),
22+
right: _max(margins.right, bBox.x + bBox.width - cRight),
23+
bottom: _max(margins.bottom, bBox.y + bBox.height - cBottom),
24+
};
25+
}, {
26+
left: 0,
27+
right: 0,
28+
top: 0,
29+
bottom: 0,
30+
});
31+
};
32+
33+
export const measureLabels = function (items) {
34+
items.forEach((item) => {
35+
const label = item.getContentContainer();
36+
item.labelBBox = label ? label.getBBox() : {
37+
x: 0, y: 0, width: 0, height: 0,
38+
};
39+
});
40+
};

0 commit comments

Comments
 (0)