@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextData.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/lineChart/fragments/fixture/contextData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contextData.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/lineChart/fragments/fixture/contextData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,OAAO,EAAE,oBA0CrB,CAAC"}
|
|
@@ -11,12 +11,14 @@ export const CONTEXT = {
|
|
|
11
11
|
{ testKey: 30, xKey: 3 },
|
|
12
12
|
],
|
|
13
13
|
dataTestId: 'test',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
xAxisLeftSpacing: 0,
|
|
15
|
+
xAxisTopSpacing: 0,
|
|
16
|
+
xAxisRightSpacing: 0,
|
|
17
|
+
xAxisBottomSpacing: 0,
|
|
18
|
+
yAxisLeftSpacing: 0,
|
|
19
|
+
yAxisTopSpacing: 0,
|
|
20
|
+
yAxisRightSpacing: 0,
|
|
21
|
+
yAxisBottomSpacing: 0,
|
|
20
22
|
xAxisCoordinates: {
|
|
21
23
|
coordinates: { x1: 0, x2: 100, y1: 0, y2: 0 },
|
|
22
24
|
tickValues: [
|
|
@@ -85,13 +85,13 @@ export const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInf
|
|
|
85
85
|
curved,
|
|
86
86
|
extendToBottom: false,
|
|
87
87
|
points,
|
|
88
|
-
svgHeight:
|
|
88
|
+
svgHeight: yAxisCoordinates.coordinates.y2,
|
|
89
89
|
});
|
|
90
90
|
const dataFill = getPathData({
|
|
91
91
|
curved,
|
|
92
92
|
extendToBottom: !!props.fill || !!props.gradient,
|
|
93
93
|
points,
|
|
94
|
-
svgHeight:
|
|
94
|
+
svgHeight: yAxisCoordinates.coordinates.y2,
|
|
95
95
|
});
|
|
96
96
|
// the ref to the path and handler the nodes focus
|
|
97
97
|
useEffect(() => {
|
|
@@ -145,5 +145,5 @@ export const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInf
|
|
|
145
145
|
// Handle deprecated ariaLabel - give precedence to ariaLabel for backward compatibility
|
|
146
146
|
...(ariaLabel && { 'aria-label': ariaLabel }),
|
|
147
147
|
};
|
|
148
|
-
return (_jsxs(_Fragment, { children: [_jsx(Path, { ref: innerRefs, d: dataOnlyLine, dFill: dataFill, dataTestId: `${context.dataTestId}path`, dataValue: context.data, points: points, xKey: context.xKey, onClick: handleClick, ...mergedProps }), lineProjection && (_jsx(LineChartProjection, { curved: curved, dataKey: props.dataKey, lineProjection: lineProjection, points: points, svgHeight:
|
|
148
|
+
return (_jsxs(_Fragment, { children: [_jsx(Path, { ref: innerRefs, d: dataOnlyLine, dFill: dataFill, dataTestId: `${context.dataTestId}path`, dataValue: context.data, points: points, xKey: context.xKey, onClick: handleClick, ...mergedProps }), lineProjection && (_jsx(LineChartProjection, { curved: curved, dataKey: props.dataKey, lineProjection: lineProjection, points: points, svgHeight: yAxisCoordinates.coordinates.y2 })), showIndicator && (_jsxs(_Fragment, { children: [!!lineIndicator && isCursorWithinPathArea && (_jsx(Line, { ...lineIndicator, className: "pointer-events-none", x1: context.xCursor, x2: context.xCursor, y1: y1, y2: y2 })), _jsx("g", { ref: indicatorRef, className: "pointer-events-none", children: _jsx(Node, { ...nodeIndicatorConfig }) })] }))] }));
|
|
149
149
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChartXAxis.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartXAxis.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAiC,MAAM,OAAO,CAAC;AAS/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"lineChartXAxis.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartXAxis.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAiC,MAAM,OAAO,CAAC;AAS/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAwDlD,CAAC"}
|
|
@@ -9,8 +9,6 @@ import { LineChartContext } from '../context/lineChartContext';
|
|
|
9
9
|
export const LineChartXAxis = ({ ariaLabel, position = Positions.BOTTOM, tickLine, tickText, valueFormatter = (value) => value, ...props }) => {
|
|
10
10
|
const { xAxisCoordinates: { coordinates, tickValues: contextTickValues }, xCursor, ...context } = useContext(LineChartContext);
|
|
11
11
|
const tickTextY = getTickTextYCoordinate(position, coordinates.y1, Number(tickText?.fontSize), tickText?.top ?? 0);
|
|
12
|
-
const y1 = context.extraSpaceTopY;
|
|
13
|
-
const y2 = Number(context.canvasHeight) - context.extraSpaceBottomY;
|
|
14
12
|
const tickValues = tickText
|
|
15
13
|
? TickDataUtils.formatTicksValues(contextTickValues, valueFormatter)
|
|
16
14
|
: undefined;
|
|
@@ -23,13 +21,10 @@ export const LineChartXAxis = ({ ariaLabel, position = Positions.BOTTOM, tickLin
|
|
|
23
21
|
...customAttributes,
|
|
24
22
|
...(finalAriaLabel && { 'aria-label': finalAriaLabel }),
|
|
25
23
|
};
|
|
26
|
-
return (_jsx(XAxis, { ...coordinates, ...mergedProps, canvasHeight: Number(context.canvasHeight), canvasWidth: Number(context.canvasWidth), cursor: xCursor, dataTestId: `${context.dataTestId}xAxis`,
|
|
27
|
-
left: context.extraSpaceLeftX,
|
|
28
|
-
right: context.extraSpaceRightX,
|
|
29
|
-
}, tickLine: {
|
|
24
|
+
return (_jsx(XAxis, { ...coordinates, ...mergedProps, canvasHeight: Number(context.canvasHeight), canvasWidth: Number(context.canvasWidth), cursor: xCursor, dataTestId: `${context.dataTestId}xAxis`, tickLine: {
|
|
30
25
|
...tickLine,
|
|
31
|
-
y1,
|
|
32
|
-
y2,
|
|
26
|
+
y1: context.yAxisCoordinates.coordinates.y1,
|
|
27
|
+
y2: context.yAxisCoordinates.coordinates.y2,
|
|
33
28
|
}, tickText: {
|
|
34
29
|
...tickText,
|
|
35
30
|
y: tickTextY,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChartYAxis.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartYAxis.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lineChartYAxis.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartYAxis.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4DxD,CAAC"}
|
|
@@ -3,10 +3,9 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { YAxis } from '../../../components/axisChart/yAxis/yAxis';
|
|
4
4
|
import { TickDataUtils } from '../../../components/tick/tick.types';
|
|
5
5
|
import { Positions } from '../../../types/position.enum';
|
|
6
|
-
import { ajustedTextSpace } from '../../../utils/ajustedTextSpace/ajustedTextSpace';
|
|
7
|
-
import { getTickTextXCoordinate } from '../../../utils/getTickTextCoordinate/getTickTextCoordinates';
|
|
8
6
|
import { pickCustomAttributes } from '../../../utils/pickCustomAttributes/pickCustomAttributes';
|
|
9
7
|
import { LineChartContext } from '../context/lineChartContext';
|
|
8
|
+
import { getYAxisTextXCoordinate } from '../utils/tickTextPosition';
|
|
10
9
|
export const LineChartYAxis = ({ ariaLabel, position = Positions.LEFT, tickLine, tickText, valueFormatter = (value) => value,
|
|
11
10
|
// NOTE: tickValues prop is destructured but NOT USED - see TODO in lineChart.type.ts
|
|
12
11
|
...props }) => {
|
|
@@ -16,11 +15,12 @@ export const LineChartYAxis = ({ ariaLabel, position = Positions.LEFT, tickLine,
|
|
|
16
15
|
// 1. Check if props.tickValues exists
|
|
17
16
|
// 2. Use custom tick values instead of context values when provided
|
|
18
17
|
// 3. Update buildLineContextValue to handle custom Y-axis tick values
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const xTickText = getYAxisTextXCoordinate({
|
|
19
|
+
tickText,
|
|
20
|
+
yAxisPosition: position,
|
|
21
|
+
textWidth: context.yAxisText,
|
|
22
|
+
yAxisX1: coordinates.x1,
|
|
23
|
+
});
|
|
24
24
|
const tickValues = tickText
|
|
25
25
|
? TickDataUtils.formatTicksValues(contextTickValues, valueFormatter)
|
|
26
26
|
: undefined;
|
|
@@ -35,7 +35,7 @@ export const LineChartYAxis = ({ ariaLabel, position = Positions.LEFT, tickLine,
|
|
|
35
35
|
};
|
|
36
36
|
return (_jsx(YAxis, { ...coordinates, ...mergedProps, canvasHeight: Number(context.canvasHeight), canvasWidth: Number(context.canvasWidth), cursor: yCursor, dataTestId: `${context.dataTestId}yAxis`, tickLine: {
|
|
37
37
|
...tickLine,
|
|
38
|
-
x1: context.
|
|
39
|
-
x2:
|
|
38
|
+
x1: context.xAxisCoordinates.coordinates.x1,
|
|
39
|
+
x2: context.xAxisCoordinates.coordinates.x2,
|
|
40
40
|
}, tickText: { ...tickText, x: xTickText }, tickValues: tickValues }));
|
|
41
41
|
};
|
|
@@ -23,12 +23,14 @@ export interface LineChartCoordinatesData {
|
|
|
23
23
|
tickValues: TickData[];
|
|
24
24
|
}
|
|
25
25
|
export interface LineChartExtraSpacings {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
xAxisLeftSpacing: number;
|
|
27
|
+
xAxisTopSpacing: number;
|
|
28
|
+
xAxisRightSpacing: number;
|
|
29
|
+
xAxisBottomSpacing: number;
|
|
30
|
+
yAxisLeftSpacing: number;
|
|
31
|
+
yAxisTopSpacing: number;
|
|
32
|
+
yAxisRightSpacing: number;
|
|
33
|
+
yAxisBottomSpacing: number;
|
|
32
34
|
lineChartXPosition: (typeof Positions)[keyof typeof Positions];
|
|
33
35
|
lineChartYPosition: (typeof Positions)[keyof typeof Positions];
|
|
34
36
|
xData: string[];
|
|
@@ -104,13 +106,16 @@ export interface LineChartXAxisProps extends Omit<XAxisProps, OmitProps | 'ariaL
|
|
|
104
106
|
ariaLabel?: string;
|
|
105
107
|
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
106
108
|
}
|
|
107
|
-
export interface LineChartYAxisProps extends Omit<YAxisProps, OmitProps | 'ariaLabel'>, React.AriaAttributes {
|
|
109
|
+
export interface LineChartYAxisProps extends Omit<YAxisProps, OmitProps | 'ariaLabel' | 'tickText'>, React.AriaAttributes {
|
|
108
110
|
/**
|
|
109
111
|
* TODO: This prop is defined in the interface but NOT IMPLEMENTED in LineChartYAxis component.
|
|
110
112
|
* The component currently ignores this prop and uses auto-generated tick values from context.
|
|
111
113
|
* Implementation needed in lineChartYAxis.tsx to properly handle custom tick values.
|
|
112
114
|
*/
|
|
113
115
|
tickValues?: TickValuesAxisProps;
|
|
116
|
+
tickText?: YAxisProps['tickText'] & {
|
|
117
|
+
useAxisAsOrigin?: boolean;
|
|
118
|
+
};
|
|
114
119
|
valueFormatter?: ValueFormatter;
|
|
115
120
|
/**
|
|
116
121
|
* @deprecated Use aria-label instead for better accessibility standards
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChart.type.d.ts","sourceRoot":"","sources":["../../../../src/charts/lineChart/lineChart.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;AAEzF,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,oBAAoB,CAAC;IAClC,UAAU,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,
|
|
1
|
+
{"version":3,"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IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc;IAC5F,eAAe,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAAG;QAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;KAC5D,CAAC;IACF,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;IACtD,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAChE"}
|
|
@@ -60,9 +60,6 @@ export const LineChartStructure = ({ ariaHidden, ariaLabel, canvasConfig = Defau
|
|
|
60
60
|
];
|
|
61
61
|
const arrayChildren = (Children.toArray(children) || []);
|
|
62
62
|
const chidrenWithDefaultAxis = defaultAxis.concat(arrayChildren);
|
|
63
|
-
const maxValue = Math.max(parsedCanvas.width, parsedCanvas.height, parsedCanvasExtraSpace ?? 0);
|
|
64
|
-
const ajustedX = isNaN(parsedCanvas.width / maxValue) ? 0 : parsedCanvas.width / maxValue;
|
|
65
|
-
const ajustedY = isNaN(parsedCanvas.height / maxValue) ? 0 : parsedCanvas.height / maxValue;
|
|
66
63
|
// watch the Y childs keys
|
|
67
64
|
getChildrenAttr({
|
|
68
65
|
attrName: 'dataKey',
|
|
@@ -79,8 +76,6 @@ export const LineChartStructure = ({ ariaHidden, ariaLabel, canvasConfig = Defau
|
|
|
79
76
|
addError: (errorType, error) => {
|
|
80
77
|
errorAccumulator.addError(errorType, error);
|
|
81
78
|
},
|
|
82
|
-
ajustedX,
|
|
83
|
-
ajustedY,
|
|
84
79
|
canvasHeight: parsedCanvas.height,
|
|
85
80
|
canvasWidth: parsedCanvas.width,
|
|
86
81
|
children: chidrenWithDefaultAxis,
|
|
@@ -117,12 +112,18 @@ export const LineChartStructure = ({ ariaHidden, ariaLabel, canvasConfig = Defau
|
|
|
117
112
|
}, [canvasWidth, canvasHeight]);
|
|
118
113
|
useEffect(() => {
|
|
119
114
|
getPathArea?.({
|
|
120
|
-
x1: contextValue.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
y2:
|
|
115
|
+
x1: contextValue.xAxisCoordinates.coordinates.x1,
|
|
116
|
+
y1: contextValue.yAxisCoordinates.coordinates.y1,
|
|
117
|
+
x2: contextValue.xAxisCoordinates.coordinates.x2,
|
|
118
|
+
y2: contextValue.yAxisCoordinates.coordinates.y2,
|
|
124
119
|
});
|
|
125
|
-
}, [
|
|
120
|
+
}, [
|
|
121
|
+
contextValue.xAxisCoordinates.coordinates.x1,
|
|
122
|
+
contextValue.yAxisCoordinates.coordinates.y1,
|
|
123
|
+
contextValue.xAxisCoordinates.coordinates.x2,
|
|
124
|
+
contextValue.yAxisCoordinates.coordinates.y2,
|
|
125
|
+
getPathArea,
|
|
126
|
+
]);
|
|
126
127
|
return (_jsx(SvgContainer, { ref: svgRef, ariaHidden: ariaHidden, ariaLabel: ariaLabel, caption: caption, className: classNames, "data-kbt-svg": true, dataTestId: dataTestId, height: height, role: role, tabIndex: tabIndex, viewBox: viewBox, width: width, ...props, children: _jsx(LineChartContext.Provider, { value: {
|
|
127
128
|
...contextValue,
|
|
128
129
|
canvasExtraSpace: parsedCanvasExtraSpace,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
type GetCoordinates = (params: {
|
|
3
|
+
lineChartXPosition: (typeof Positions)[keyof typeof Positions];
|
|
4
|
+
lineChartYPosition: (typeof Positions)[keyof typeof Positions];
|
|
5
|
+
canvasHeight: number;
|
|
6
|
+
canvasWidth: number;
|
|
7
|
+
customBreakAxis: number;
|
|
8
|
+
xAxisLeftSpacing: number;
|
|
9
|
+
xAxisTopSpacing: number;
|
|
10
|
+
xAxisRightSpacing: number;
|
|
11
|
+
xAxisBottomSpacing: number;
|
|
12
|
+
yAxisLeftSpacing: number;
|
|
13
|
+
yAxisTopSpacing: number;
|
|
14
|
+
yAxisRightSpacing: number;
|
|
15
|
+
yAxisBottomSpacing: number;
|
|
16
|
+
}) => {
|
|
17
|
+
x1: number;
|
|
18
|
+
x2: number;
|
|
19
|
+
y1: number;
|
|
20
|
+
y2: number;
|
|
21
|
+
};
|
|
22
|
+
export declare const getXCoordinates: GetCoordinates;
|
|
23
|
+
export declare const getYCoordinates: GetCoordinates;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=getCoordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCoordinates.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE;IAC7B,kBAAkB,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;IAC/D,kBAAkB,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;CAC5B,KAAK;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,eAAO,MAAM,eAAe,EAAE,cA2C7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAyC7B,CAAC"}
|
|
@@ -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"}
|