@kubit-ui-web/react-charts 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +64 -128
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +8 -6
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +3 -3
- package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.js +3 -8
- package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.js +9 -9
- package/dist/cjs/charts/lineChart/lineChart.type.d.ts +12 -7
- package/dist/cjs/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/lineChartStructure.js +11 -10
- package/dist/cjs/charts/lineChart/utils/getCoordinates.d.ts +25 -0
- package/dist/cjs/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/getCoordinates.js +55 -0
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.js +68 -51
- package/dist/cjs/charts/lineChart/utils/getTicks.d.ts +21 -0
- package/dist/cjs/charts/lineChart/utils/getTicks.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/getTicks.js +36 -0
- package/dist/cjs/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/utils/handleNodesFocus.js +14 -25
- package/dist/cjs/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
- package/dist/cjs/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/tickTextPosition.js +109 -0
- package/dist/cjs/charts/lineChart/utils/validations.d.ts +54 -0
- package/dist/cjs/charts/lineChart/utils/validations.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/validations.js +117 -0
- package/dist/cjs/components/chartText/chartText.d.ts.map +1 -1
- package/dist/cjs/components/chartText/chartText.js +2 -2
- package/dist/cjs/components/line/line.d.ts.map +1 -1
- package/dist/cjs/components/line/line.js +2 -2
- package/dist/cjs/components/line/line.types.d.ts +2 -0
- package/dist/cjs/components/line/line.types.d.ts.map +1 -1
- package/dist/cjs/components/node/node.d.ts.map +1 -1
- package/dist/cjs/components/node/node.js +1 -1
- package/dist/cjs/components/node/node.types.d.ts +2 -0
- package/dist/cjs/components/node/node.types.d.ts.map +1 -1
- package/dist/cjs/components/path/path.js +1 -1
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
- package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
- package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/context/buildLineContextValue.js +64 -128
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.js +8 -6
- package/dist/esm/charts/lineChart/fragments/lineChartPath.js +3 -3
- package/dist/esm/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartXAxis.js +3 -8
- package/dist/esm/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartYAxis.js +9 -9
- package/dist/esm/charts/lineChart/lineChart.type.d.ts +12 -7
- package/dist/esm/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/lineChartStructure.js +11 -10
- package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts +25 -0
- package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/getCoordinates.js +55 -0
- package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
- package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/utils/getExtraSpacing.js +68 -51
- package/dist/esm/charts/lineChart/utils/getTicks.d.ts +21 -0
- package/dist/esm/charts/lineChart/utils/getTicks.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/getTicks.js +36 -0
- package/dist/esm/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/utils/handleNodesFocus.js +14 -25
- package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
- package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/tickTextPosition.js +109 -0
- package/dist/esm/charts/lineChart/utils/validations.d.ts +54 -0
- package/dist/esm/charts/lineChart/utils/validations.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/validations.js +117 -0
- package/dist/esm/components/chartText/chartText.d.ts.map +1 -1
- package/dist/esm/components/chartText/chartText.js +2 -2
- package/dist/esm/components/line/line.d.ts.map +1 -1
- package/dist/esm/components/line/line.js +2 -2
- package/dist/esm/components/line/line.types.d.ts +2 -0
- package/dist/esm/components/line/line.types.d.ts.map +1 -1
- package/dist/esm/components/node/node.d.ts.map +1 -1
- package/dist/esm/components/node/node.js +1 -1
- package/dist/esm/components/node/node.types.d.ts +2 -0
- package/dist/esm/components/node/node.types.d.ts.map +1 -1
- package/dist/esm/components/path/path.js +1 -1
- package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
- package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
- package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
- package/dist/kubit-ui-web-react-charts.cjs.js +1 -1
- package/dist/kubit-ui-web-react-charts.es.js +1 -1
- package/dist/kubit-ui-web-react-charts.umd.js +1 -1
- package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
- package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
- package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
- package/dist/types/charts/lineChart/lineChart.type.d.ts +12 -7
- package/dist/types/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/types/charts/lineChart/utils/getCoordinates.d.ts +25 -0
- package/dist/types/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
- package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
- package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
- package/dist/types/charts/lineChart/utils/getTicks.d.ts +21 -0
- package/dist/types/charts/lineChart/utils/getTicks.d.ts.map +1 -0
- package/dist/types/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
- package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
- package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
- package/dist/types/charts/lineChart/utils/validations.d.ts +54 -0
- package/dist/types/charts/lineChart/utils/validations.d.ts.map +1 -0
- package/dist/types/components/chartText/chartText.d.ts.map +1 -1
- package/dist/types/components/line/line.d.ts.map +1 -1
- package/dist/types/components/line/line.types.d.ts +2 -0
- package/dist/types/components/line/line.types.d.ts.map +1 -1
- package/dist/types/components/node/node.d.ts.map +1 -1
- package/dist/types/components/node/node.types.d.ts +2 -0
- package/dist/types/components/node/node.types.d.ts.map +1 -1
- package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
- package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
export const getXCoordinates = ({ lineChartXPosition, lineChartYPosition, canvasHeight, canvasWidth, customBreakAxis, xAxisLeftSpacing, xAxisTopSpacing, xAxisRightSpacing, xAxisBottomSpacing, yAxisLeftSpacing, yAxisTopSpacing, yAxisRightSpacing, yAxisBottomSpacing, }) => {
|
|
3
|
+
const x1 = lineChartYPosition === Positions.LEFT ? Math.max(yAxisLeftSpacing, xAxisLeftSpacing) : 0;
|
|
4
|
+
const x2 = lineChartYPosition === Positions.RIGHT
|
|
5
|
+
? canvasWidth - Math.max(yAxisRightSpacing, xAxisRightSpacing)
|
|
6
|
+
: canvasWidth;
|
|
7
|
+
if (lineChartXPosition === Positions.TOP) {
|
|
8
|
+
return {
|
|
9
|
+
x1,
|
|
10
|
+
x2,
|
|
11
|
+
y1: Math.max(yAxisTopSpacing, xAxisTopSpacing),
|
|
12
|
+
y2: Math.max(yAxisTopSpacing, xAxisTopSpacing),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (lineChartXPosition === Positions.CENTER) {
|
|
16
|
+
return { x1, x2, y1: canvasHeight / 2, y2: canvasHeight / 2 };
|
|
17
|
+
}
|
|
18
|
+
if (lineChartXPosition === Positions.CUSTOM) {
|
|
19
|
+
return { x1, x2, y1: customBreakAxis, y2: customBreakAxis };
|
|
20
|
+
}
|
|
21
|
+
// BOTTOM
|
|
22
|
+
return {
|
|
23
|
+
x1,
|
|
24
|
+
x2,
|
|
25
|
+
y1: canvasHeight - Math.max(yAxisBottomSpacing, xAxisBottomSpacing),
|
|
26
|
+
y2: canvasHeight - Math.max(yAxisBottomSpacing, xAxisBottomSpacing),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export const getYCoordinates = ({ lineChartXPosition, lineChartYPosition, canvasHeight, canvasWidth, customBreakAxis, xAxisLeftSpacing, xAxisTopSpacing, xAxisRightSpacing, xAxisBottomSpacing, yAxisLeftSpacing, yAxisTopSpacing, yAxisRightSpacing, yAxisBottomSpacing, }) => {
|
|
30
|
+
const y1 = lineChartXPosition === Positions.TOP ? Math.max(yAxisTopSpacing, xAxisTopSpacing) : 0;
|
|
31
|
+
const y2 = lineChartXPosition === Positions.BOTTOM
|
|
32
|
+
? canvasHeight - Math.max(yAxisBottomSpacing, xAxisBottomSpacing)
|
|
33
|
+
: canvasHeight;
|
|
34
|
+
if (lineChartYPosition === Positions.RIGHT) {
|
|
35
|
+
return {
|
|
36
|
+
x1: canvasWidth - Math.max(yAxisRightSpacing, xAxisRightSpacing),
|
|
37
|
+
x2: canvasWidth - Math.max(yAxisRightSpacing, xAxisRightSpacing),
|
|
38
|
+
y1,
|
|
39
|
+
y2,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (lineChartYPosition === Positions.CENTER) {
|
|
43
|
+
return { x1: canvasWidth / 2, x2: canvasWidth / 2, y1, y2 };
|
|
44
|
+
}
|
|
45
|
+
if (lineChartYPosition === Positions.CUSTOM) {
|
|
46
|
+
return { x1: customBreakAxis, x2: customBreakAxis, y1, y2 };
|
|
47
|
+
}
|
|
48
|
+
// LEFT
|
|
49
|
+
return {
|
|
50
|
+
x1: Math.max(yAxisLeftSpacing, xAxisLeftSpacing),
|
|
51
|
+
x2: Math.max(yAxisLeftSpacing, xAxisLeftSpacing),
|
|
52
|
+
y1,
|
|
53
|
+
y2,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -3,8 +3,6 @@ interface GetExtraSpacing {
|
|
|
3
3
|
children: ChildrenType;
|
|
4
4
|
data: IDataPoint[];
|
|
5
5
|
xKey: string;
|
|
6
|
-
ajustedX: number;
|
|
7
|
-
ajustedY: number;
|
|
8
6
|
viewBox: string;
|
|
9
7
|
canvasHeight: number;
|
|
10
8
|
canvasWidth: number;
|
|
@@ -14,6 +12,6 @@ interface GetExtraSpacing {
|
|
|
14
12
|
* @param {GetExtraSpacing} options - The options for calculating extra spacing.
|
|
15
13
|
* @returns {LineChartExtraSpacings} - The calculated extra spacings for the line chart.
|
|
16
14
|
*/
|
|
17
|
-
export declare const getExtraSpacing: ({
|
|
15
|
+
export declare const getExtraSpacing: ({ canvasHeight, canvasWidth, children, data, viewBox, xKey, }: GetExtraSpacing) => LineChartExtraSpacings;
|
|
18
16
|
export {};
|
|
19
17
|
//# sourceMappingURL=getExtraSpacing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExtraSpacing.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getExtraSpacing.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"getExtraSpacing.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getExtraSpacing.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAiI1F,UAAU,eAAe;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,+DAO7B,eAAe,KAAG,sBAqCpB,CAAC"}
|
|
@@ -6,14 +6,20 @@ import { LineChartXAxis } from '../fragments/lineChartXAxis';
|
|
|
6
6
|
import { LineChartYAxis } from '../fragments/lineChartYAxis';
|
|
7
7
|
import { getDataValues } from './getDataValues';
|
|
8
8
|
import { getYKeyRoundMaxValue } from './getRoundedMaxValue';
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import { getXAxisLeftTextSpacing, getXAxisRightTextSpacing, getYAxisLeftTextSpacing, getYAxisRightTextSpacing, } from './tickTextPosition';
|
|
10
|
+
const getBreakAxis = ({ tickValues, tickText }) => {
|
|
11
|
+
if (tickValues?.numeric) {
|
|
12
|
+
return tickValues.numeric.breakAxis ?? 0;
|
|
13
|
+
}
|
|
14
|
+
return tickText?.custom?.breakAxis ?? 0;
|
|
15
|
+
};
|
|
16
|
+
const handleLineChartXAxis = (child, data, xKey, viewBox, canvasHeight, canvasWidth) => {
|
|
17
|
+
const { position = Positions.BOTTOM, tickText, tickValues, valueFormatter } = child.props;
|
|
11
18
|
const fontSize = tickText?.fontSize ?? 0;
|
|
12
|
-
const spaceFontSize = fontSize * ajustedX;
|
|
13
19
|
const xData = tickValues ? getDataValues(tickValues) : data.map(d => d[xKey]);
|
|
14
20
|
// Apply the valueFormatter if provided to get the actual rendered text width
|
|
15
21
|
const formattedXData = valueFormatter ? xData.map(valueFormatter) : xData;
|
|
16
|
-
const
|
|
22
|
+
const textWidth = textBound({
|
|
17
23
|
bound: 'width',
|
|
18
24
|
data: formattedXData,
|
|
19
25
|
fontSize,
|
|
@@ -21,31 +27,36 @@ const handleLineChartXAxis = (child, data, xKey, ajustedX, viewBox, canvasHeight
|
|
|
21
27
|
svgWidth: `${canvasWidth}`,
|
|
22
28
|
viewBox,
|
|
23
29
|
});
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
const xBreakAxis = getBreakAxis();
|
|
30
|
+
const textHeight = textBound({
|
|
31
|
+
bound: 'height',
|
|
32
|
+
data: formattedXData,
|
|
33
|
+
fontSize,
|
|
34
|
+
svgHeight: `${canvasHeight}`,
|
|
35
|
+
svgWidth: `${canvasWidth}`,
|
|
36
|
+
viewBox,
|
|
37
|
+
});
|
|
38
|
+
const xAxisBottomSpacing = position === Positions.BOTTOM ? textHeight + (tickText?.top ?? 0) : 0;
|
|
39
|
+
const xAxisTopSpacing = position === Positions.TOP ? textHeight + (tickText?.bottom ?? 0) : 0;
|
|
40
|
+
const xBreakAxis = getBreakAxis({ tickValues, tickText });
|
|
36
41
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
xAxisLeftSpacing: getXAxisLeftTextSpacing({
|
|
43
|
+
textWidth,
|
|
44
|
+
tickText,
|
|
45
|
+
}),
|
|
46
|
+
xAxisTopSpacing,
|
|
47
|
+
xAxisRightSpacing: getXAxisRightTextSpacing({
|
|
48
|
+
textWidth,
|
|
49
|
+
tickText,
|
|
50
|
+
}),
|
|
51
|
+
xAxisBottomSpacing,
|
|
52
|
+
lineChartXPosition: position,
|
|
41
53
|
xBreakAxis,
|
|
42
54
|
xData,
|
|
43
55
|
};
|
|
44
56
|
};
|
|
45
|
-
const handleLineChartYAxis = (child, data, xKey,
|
|
46
|
-
const { position, tickText, tickValues, valueFormatter } = child.props;
|
|
47
|
-
const fontSize = tickText?.fontSize ??
|
|
48
|
-
const spaceFontSize = fontSize * ajustedY;
|
|
57
|
+
const handleLineChartYAxis = (child, data, xKey, viewBox, canvasHeight, canvasWidth) => {
|
|
58
|
+
const { position = Positions.LEFT, tickText, tickValues, valueFormatter } = child.props;
|
|
59
|
+
const fontSize = tickText?.fontSize ?? 0;
|
|
49
60
|
const dataValues = tickValues ||
|
|
50
61
|
buildTickValues([...new Set(getYKeyRoundMaxValue(data, xKey))]);
|
|
51
62
|
const yData = getDataValues(dataValues);
|
|
@@ -59,26 +70,30 @@ const handleLineChartYAxis = (child, data, xKey, ajustedY, viewBox, canvasHeight
|
|
|
59
70
|
svgWidth: `${canvasWidth}`,
|
|
60
71
|
viewBox,
|
|
61
72
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return tickValues.numeric.breakAxis ?? 0;
|
|
71
|
-
}
|
|
72
|
-
return tickText?.custom?.breakAxis ?? 0;
|
|
73
|
-
};
|
|
74
|
-
const yBreakAxis = getBreakAxis();
|
|
73
|
+
const textHeight = textBound({
|
|
74
|
+
bound: 'height',
|
|
75
|
+
data: formattedYData,
|
|
76
|
+
fontSize,
|
|
77
|
+
svgHeight: `${canvasHeight}`,
|
|
78
|
+
svgWidth: `${canvasWidth}`,
|
|
79
|
+
viewBox,
|
|
80
|
+
});
|
|
75
81
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
yAxisLeftSpacing: getYAxisLeftTextSpacing({
|
|
83
|
+
tickText,
|
|
84
|
+
textWidth: yAxisText,
|
|
85
|
+
yAxisPosition: position,
|
|
86
|
+
}),
|
|
87
|
+
yAxisTopSpacing: textHeight,
|
|
88
|
+
yAxisRightSpacing: getYAxisRightTextSpacing({
|
|
89
|
+
tickText,
|
|
90
|
+
textWidth: yAxisText,
|
|
91
|
+
yAxisPosition: position,
|
|
92
|
+
}),
|
|
93
|
+
yAxisBottomSpacing: 0,
|
|
94
|
+
lineChartYPosition: position,
|
|
80
95
|
yAxisText,
|
|
81
|
-
yBreakAxis,
|
|
96
|
+
yBreakAxis: getBreakAxis({ tickValues, tickText }),
|
|
82
97
|
yData,
|
|
83
98
|
};
|
|
84
99
|
};
|
|
@@ -87,16 +102,18 @@ const handleLineChartYAxis = (child, data, xKey, ajustedY, viewBox, canvasHeight
|
|
|
87
102
|
* @param {GetExtraSpacing} options - The options for calculating extra spacing.
|
|
88
103
|
* @returns {LineChartExtraSpacings} - The calculated extra spacings for the line chart.
|
|
89
104
|
*/
|
|
90
|
-
export const getExtraSpacing = ({
|
|
105
|
+
export const getExtraSpacing = ({ canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
|
|
91
106
|
let result = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
xAxisLeftSpacing: 0,
|
|
108
|
+
xAxisTopSpacing: 0,
|
|
109
|
+
xAxisRightSpacing: 0,
|
|
110
|
+
xAxisBottomSpacing: 0,
|
|
111
|
+
yAxisLeftSpacing: 0,
|
|
112
|
+
yAxisTopSpacing: 0,
|
|
113
|
+
yAxisRightSpacing: 0,
|
|
114
|
+
yAxisBottomSpacing: 0,
|
|
96
115
|
lineChartXPosition: Positions.BOTTOM,
|
|
97
116
|
lineChartYPosition: Positions.LEFT,
|
|
98
|
-
securityXSpace: 0,
|
|
99
|
-
securityYSpace: 0,
|
|
100
117
|
xAxisText: 0,
|
|
101
118
|
xBreakAxis: 0,
|
|
102
119
|
xData: [],
|
|
@@ -109,13 +126,13 @@ export const getExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
|
|
|
109
126
|
if (child.type === LineChartXAxis) {
|
|
110
127
|
result = {
|
|
111
128
|
...result,
|
|
112
|
-
...handleLineChartXAxis(child, data, xKey,
|
|
129
|
+
...handleLineChartXAxis(child, data, xKey, viewBox, canvasHeight, canvasWidth),
|
|
113
130
|
};
|
|
114
131
|
}
|
|
115
132
|
else if (child.type === LineChartYAxis) {
|
|
116
133
|
result = {
|
|
117
134
|
...result,
|
|
118
|
-
...handleLineChartYAxis(child, data, xKey,
|
|
135
|
+
...handleLineChartYAxis(child, data, xKey, viewBox, canvasHeight, canvasWidth),
|
|
119
136
|
};
|
|
120
137
|
}
|
|
121
138
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TickData } from '../../../components/tick/tick.types';
|
|
2
|
+
interface GetXTickProps {
|
|
3
|
+
tickValues: string[];
|
|
4
|
+
maxSpaceAvailable: number;
|
|
5
|
+
xAxisLeftSpacing: number;
|
|
6
|
+
xAxisRightSpacing: number;
|
|
7
|
+
yAxisLeftSpacing: number;
|
|
8
|
+
yAxisRightSpacing: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const getXTicks: ({ tickValues, maxSpaceAvailable, xAxisLeftSpacing, xAxisRightSpacing, yAxisLeftSpacing, yAxisRightSpacing, }: GetXTickProps) => TickData[];
|
|
11
|
+
interface GetYTickProps {
|
|
12
|
+
tickValues: string[];
|
|
13
|
+
maxSpaceAvailable: number;
|
|
14
|
+
xAxisTopSpacing: number;
|
|
15
|
+
xAxisBottomSpacing: number;
|
|
16
|
+
yAxisTopSpacing: number;
|
|
17
|
+
yAxisBottomSpacing: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const getYTicks: ({ maxSpaceAvailable, tickValues, xAxisTopSpacing, xAxisBottomSpacing, yAxisTopSpacing, yAxisBottomSpacing, }: GetYTickProps) => TickData[];
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=getTicks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTicks.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getTicks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,SAAS,GAAI,8GAOvB,aAAa,KAAG,QAAQ,EAkB1B,CAAC;AAEF,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS,GAAI,8GAOvB,aAAa,KAAG,QAAQ,EAkB1B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const getXTicks = ({ tickValues, maxSpaceAvailable, xAxisLeftSpacing, xAxisRightSpacing, yAxisLeftSpacing, yAxisRightSpacing, }) => {
|
|
2
|
+
const initPos = Math.max(yAxisLeftSpacing, xAxisLeftSpacing);
|
|
3
|
+
const endPos = maxSpaceAvailable - Math.max(xAxisRightSpacing, yAxisRightSpacing);
|
|
4
|
+
if (tickValues.length <= 1) {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
position: initPos,
|
|
8
|
+
value: tickValues[0],
|
|
9
|
+
},
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
const step = (endPos - initPos) / (tickValues.length - 1);
|
|
13
|
+
const ticks = tickValues.map((value, idx) => {
|
|
14
|
+
const position = initPos + step * idx;
|
|
15
|
+
return { position, value };
|
|
16
|
+
});
|
|
17
|
+
return ticks;
|
|
18
|
+
};
|
|
19
|
+
export const getYTicks = ({ maxSpaceAvailable, tickValues, xAxisTopSpacing, xAxisBottomSpacing, yAxisTopSpacing, yAxisBottomSpacing, }) => {
|
|
20
|
+
const initPos = maxSpaceAvailable - Math.max(xAxisBottomSpacing, yAxisBottomSpacing);
|
|
21
|
+
const endPos = Math.max(yAxisTopSpacing, xAxisTopSpacing);
|
|
22
|
+
if (tickValues.length <= 1) {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
position: initPos,
|
|
26
|
+
value: tickValues[0],
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
const step = (initPos - endPos) / (tickValues.length - 1);
|
|
31
|
+
const ticks = tickValues.map((value, idx) => {
|
|
32
|
+
const position = initPos - step * idx;
|
|
33
|
+
return { position, value };
|
|
34
|
+
});
|
|
35
|
+
return ticks;
|
|
36
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleNodesFocus.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/handleNodesFocus.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,UAAU,qBAAqB;IAC7B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,gBAAgB,GAAI,yCAK9B,qBAAqB,KAAG,
|
|
1
|
+
{"version":3,"file":"handleNodesFocus.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/handleNodesFocus.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,UAAU,qBAAqB;IAC7B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,gBAAgB,GAAI,yCAK9B,qBAAqB,KAAG,sBAoC1B,CAAC"}
|
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
export const handleNodesFocus = ({ data, getNodeFocusInfo, nodes, ref, }) => {
|
|
2
|
-
let refFocused = false;
|
|
3
2
|
let currentNode = undefined;
|
|
4
3
|
const g = ref.querySelector('[data-draw]');
|
|
5
|
-
//* callbacks
|
|
6
4
|
const handleKeyDown = (e) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
let newCurrentNode = undefined;
|
|
6
|
+
if (e.key === 'ArrowRight') {
|
|
7
|
+
newCurrentNode =
|
|
8
|
+
currentNode === undefined || currentNode === nodes.length - 1 ? 0 : currentNode + 1;
|
|
9
|
+
}
|
|
10
|
+
else if (e.key === 'ArrowLeft') {
|
|
11
|
+
newCurrentNode =
|
|
12
|
+
currentNode === undefined || currentNode === 0 ? nodes.length - 1 : currentNode - 1;
|
|
13
|
+
}
|
|
14
|
+
if (newCurrentNode !== undefined) {
|
|
15
|
+
currentNode = newCurrentNode;
|
|
16
|
+
if (nodes[currentNode]) {
|
|
17
17
|
nodes[currentNode].focus();
|
|
18
18
|
getNodeFocusInfo?.(data[currentNode]);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
const handleFocusin = () => {
|
|
23
|
-
refFocused = true;
|
|
24
|
-
};
|
|
25
|
-
const handleFocusout = () => {
|
|
26
|
-
refFocused = false;
|
|
27
|
-
};
|
|
28
22
|
const handleFocus = () => {
|
|
29
23
|
currentNode = undefined;
|
|
30
24
|
};
|
|
31
|
-
//* listeners
|
|
32
25
|
const mount = () => {
|
|
33
|
-
ref.addEventListener('focusin', handleFocusin);
|
|
34
|
-
ref.addEventListener('focusout', handleFocusout);
|
|
35
26
|
g?.addEventListener('focus', handleFocus);
|
|
36
|
-
|
|
27
|
+
ref.addEventListener('keydown', (e) => handleKeyDown(e));
|
|
37
28
|
};
|
|
38
29
|
const unmount = () => {
|
|
39
|
-
ref.removeEventListener('focusin', handleFocusin);
|
|
40
|
-
ref.removeEventListener('focusout', handleFocusout);
|
|
41
30
|
g?.removeEventListener('focus', handleFocus);
|
|
42
|
-
|
|
31
|
+
ref.removeEventListener('keydown', (e) => handleKeyDown(e));
|
|
43
32
|
};
|
|
44
33
|
return { mount, unmount };
|
|
45
34
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
import type { LineChartXAxisProps, LineChartYAxisProps } from '../lineChart.type';
|
|
3
|
+
type GetYAxisTextXCoordinate = (params: {
|
|
4
|
+
tickText?: LineChartYAxisProps['tickText'];
|
|
5
|
+
yAxisPosition: LineChartYAxisProps['position'];
|
|
6
|
+
textWidth: number;
|
|
7
|
+
yAxisX1: number;
|
|
8
|
+
}) => number;
|
|
9
|
+
export declare const getYAxisTextXCoordinate: GetYAxisTextXCoordinate;
|
|
10
|
+
type GetYAxisLeftTextSpacing = (params: {
|
|
11
|
+
tickText?: LineChartYAxisProps['tickText'];
|
|
12
|
+
textWidth: number;
|
|
13
|
+
yAxisPosition: (typeof Positions)[keyof typeof Positions];
|
|
14
|
+
}) => number;
|
|
15
|
+
export declare const getYAxisLeftTextSpacing: GetYAxisLeftTextSpacing;
|
|
16
|
+
type GetYAxisRightTextSpacing = (params: {
|
|
17
|
+
tickText?: LineChartYAxisProps['tickText'];
|
|
18
|
+
textWidth: number;
|
|
19
|
+
yAxisPosition: (typeof Positions)[keyof typeof Positions];
|
|
20
|
+
}) => number;
|
|
21
|
+
export declare const getYAxisRightTextSpacing: GetYAxisRightTextSpacing;
|
|
22
|
+
type GetXAxisLeftTextSpacing = (params: {
|
|
23
|
+
tickText?: LineChartXAxisProps['tickText'];
|
|
24
|
+
textWidth: number;
|
|
25
|
+
}) => number;
|
|
26
|
+
export declare const getXAxisLeftTextSpacing: GetXAxisLeftTextSpacing;
|
|
27
|
+
type GetXAxisRightTextSpacing = (params: {
|
|
28
|
+
tickText?: LineChartXAxisProps['tickText'];
|
|
29
|
+
textWidth: number;
|
|
30
|
+
}) => number;
|
|
31
|
+
export declare const getXAxisRightTextSpacing: GetXAxisRightTextSpacing;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=tickTextPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tickTextPosition.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/tickTextPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,aAAa,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBA8BrC,CAAC;AAEF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;CAC3D,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBAmCrC,CAAC;AAEF,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE;IACvC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;CAC3D,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,wBAAwB,EAAE,wBAmCtC,CAAC;AAEF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBASrC,CAAC;AAEF,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE;IACvC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,wBAAwB,EAAE,wBAStC,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
import { ajustedTextSpace } from '../../../utils/ajustedTextSpace/ajustedTextSpace';
|
|
3
|
+
import { getTickTextXCoordinate } from '../../../utils/getTickTextCoordinate/getTickTextCoordinates';
|
|
4
|
+
export const getYAxisTextXCoordinate = ({ tickText, yAxisPosition, textWidth, yAxisX1, }) => {
|
|
5
|
+
if (tickText?.useAxisAsOrigin) {
|
|
6
|
+
let xTickText = yAxisX1;
|
|
7
|
+
xTickText += tickText.right ?? 0;
|
|
8
|
+
xTickText -= tickText.left ?? 0;
|
|
9
|
+
return xTickText;
|
|
10
|
+
}
|
|
11
|
+
// TODO Review this logic, I don't understand the logic behind it
|
|
12
|
+
// Maybe it only makes sense when anchor is middle
|
|
13
|
+
// IMPORTANT: When changing or deleting this logic, review the getYAxisLeftTextSpacing and getYAxisRightTextSpacing functions
|
|
14
|
+
const textAnchor = tickText?.textAnchor || 'middle';
|
|
15
|
+
let ajustedSpace = 0;
|
|
16
|
+
if (yAxisPosition === Positions.RIGHT) {
|
|
17
|
+
ajustedSpace = tickText?.right ?? 0;
|
|
18
|
+
}
|
|
19
|
+
else if (yAxisPosition === Positions.LEFT) {
|
|
20
|
+
ajustedSpace = tickText?.left ?? 0;
|
|
21
|
+
}
|
|
22
|
+
const ajustedText = ajustedTextSpace(textAnchor, textWidth, ajustedSpace);
|
|
23
|
+
const xTickText = getTickTextXCoordinate(yAxisPosition, yAxisX1, ajustedText);
|
|
24
|
+
return xTickText;
|
|
25
|
+
};
|
|
26
|
+
export const getYAxisLeftTextSpacing = ({ tickText, textWidth, yAxisPosition, }) => {
|
|
27
|
+
if (yAxisPosition !== Positions.LEFT) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
if (tickText?.useAxisAsOrigin) {
|
|
31
|
+
const { textAnchor = 'start' } = tickText;
|
|
32
|
+
let res = 0;
|
|
33
|
+
if (textAnchor === 'end') {
|
|
34
|
+
res = textWidth;
|
|
35
|
+
}
|
|
36
|
+
if (textAnchor === 'middle') {
|
|
37
|
+
res = textWidth / 2;
|
|
38
|
+
}
|
|
39
|
+
res += tickText.left ?? 0;
|
|
40
|
+
res -= tickText.right ?? 0;
|
|
41
|
+
return Math.max(0, res);
|
|
42
|
+
}
|
|
43
|
+
// TODO Review this logic, I don't understand the logic behind it
|
|
44
|
+
// This left spacing is applied because the logic in getYAxisTextXCoordinate
|
|
45
|
+
const textAnchor = tickText?.textAnchor;
|
|
46
|
+
const extraSpace = tickText?.left ?? 0;
|
|
47
|
+
if (textAnchor === 'start') {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
if (textAnchor === 'middle') {
|
|
51
|
+
return textWidth + extraSpace;
|
|
52
|
+
}
|
|
53
|
+
if (textAnchor === 'end') {
|
|
54
|
+
return 2 * textWidth + extraSpace;
|
|
55
|
+
}
|
|
56
|
+
return textWidth / 2 + extraSpace;
|
|
57
|
+
};
|
|
58
|
+
export const getYAxisRightTextSpacing = ({ tickText, textWidth, yAxisPosition, }) => {
|
|
59
|
+
if (yAxisPosition !== Positions.RIGHT) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (tickText?.useAxisAsOrigin) {
|
|
63
|
+
const { textAnchor = 'start' } = tickText;
|
|
64
|
+
let res = textWidth;
|
|
65
|
+
if (textAnchor === 'end') {
|
|
66
|
+
res = 0;
|
|
67
|
+
}
|
|
68
|
+
if (textAnchor === 'middle') {
|
|
69
|
+
res = textWidth / 2;
|
|
70
|
+
}
|
|
71
|
+
res -= tickText.left ?? 0;
|
|
72
|
+
res += tickText.right ?? 0;
|
|
73
|
+
return Math.max(0, res);
|
|
74
|
+
}
|
|
75
|
+
// TODO Review this logic, I don't understand the logic behind it
|
|
76
|
+
// This size is applied because the logic in getYAxisTextXCoordinate
|
|
77
|
+
const textAnchor = tickText?.textAnchor;
|
|
78
|
+
const extraSpace = tickText?.right ?? 0;
|
|
79
|
+
if (textAnchor === 'start') {
|
|
80
|
+
return textWidth;
|
|
81
|
+
}
|
|
82
|
+
if (textAnchor === 'middle') {
|
|
83
|
+
return textWidth + extraSpace;
|
|
84
|
+
}
|
|
85
|
+
if (textAnchor === 'end') {
|
|
86
|
+
return textWidth + extraSpace;
|
|
87
|
+
}
|
|
88
|
+
return 2 * textWidth - textWidth / 2 + extraSpace;
|
|
89
|
+
};
|
|
90
|
+
export const getXAxisLeftTextSpacing = ({ tickText, textWidth }) => {
|
|
91
|
+
const textAnchor = tickText?.textAnchor ?? 'start';
|
|
92
|
+
if (textAnchor === 'start') {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
if (textAnchor === 'middle') {
|
|
96
|
+
return textWidth / 2;
|
|
97
|
+
}
|
|
98
|
+
return textWidth;
|
|
99
|
+
};
|
|
100
|
+
export const getXAxisRightTextSpacing = ({ tickText, textWidth }) => {
|
|
101
|
+
const textAnchor = tickText?.textAnchor ?? 'start';
|
|
102
|
+
if (textAnchor === 'end') {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
if (textAnchor === 'middle') {
|
|
106
|
+
return textWidth / 2;
|
|
107
|
+
}
|
|
108
|
+
return textWidth;
|
|
109
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TickData } from '../../../components/tick/tick.types';
|
|
2
|
+
import type { ChartError, ErrorType } from '../../../types/errors.type';
|
|
3
|
+
import type { IDataPoint } from '../lineChart.type';
|
|
4
|
+
type ValidateData = (params: {
|
|
5
|
+
data: IDataPoint[];
|
|
6
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
7
|
+
}) => {
|
|
8
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const validateData: ValidateData;
|
|
11
|
+
type ValidateCanvasDimensions = (params: {
|
|
12
|
+
canvasWidth: number;
|
|
13
|
+
canvasHeight: number;
|
|
14
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
15
|
+
}) => {
|
|
16
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
17
|
+
};
|
|
18
|
+
export declare const validateCanvasDimensions: ValidateCanvasDimensions;
|
|
19
|
+
type ValidateYTickValues = (params: {
|
|
20
|
+
yTickValues: TickData[];
|
|
21
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
22
|
+
}) => {
|
|
23
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
24
|
+
};
|
|
25
|
+
export declare const validateYTickValues: ValidateYTickValues;
|
|
26
|
+
type ValidateXTickValues = (params: {
|
|
27
|
+
xTickValues: TickData[];
|
|
28
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
29
|
+
}) => {
|
|
30
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
31
|
+
};
|
|
32
|
+
export declare const validateXTickValues: ValidateXTickValues;
|
|
33
|
+
type ValidateXCoordinates = (params: {
|
|
34
|
+
xCoordinates: {
|
|
35
|
+
x1: number;
|
|
36
|
+
x2: number;
|
|
37
|
+
};
|
|
38
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
39
|
+
}) => {
|
|
40
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
41
|
+
};
|
|
42
|
+
export declare const validateXCoordinates: ValidateXCoordinates;
|
|
43
|
+
type ValidateYCoordinates = (params: {
|
|
44
|
+
yCoordinates: {
|
|
45
|
+
y1: number;
|
|
46
|
+
y2: number;
|
|
47
|
+
};
|
|
48
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
49
|
+
}) => {
|
|
50
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
51
|
+
};
|
|
52
|
+
export declare const validateYCoordinates: ValidateYCoordinates;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=validations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/validations.ts"],"names":[],"mappings":"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"}
|