@kubit-ui-web/react-charts 0.1.0 → 1.1.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/README.md +31 -36
- package/dist/cjs/charts/barChart/barChart.js +12 -29
- package/dist/cjs/charts/barChart/barChart.type.js +1 -2
- package/dist/cjs/charts/barChart/barChartStructure.js +25 -29
- package/dist/cjs/charts/barChart/context/barChartContext.js +2 -5
- package/dist/cjs/charts/barChart/context/buildBarContextValues.js +17 -21
- package/dist/cjs/charts/barChart/fragments/barChartPath.js +12 -16
- package/dist/cjs/charts/barChart/fragments/barChartSeparator.js +10 -14
- package/dist/cjs/charts/barChart/fragments/barChartXAxis.js +10 -14
- package/dist/cjs/charts/barChart/fragments/barChartYAxis.js +13 -17
- package/dist/cjs/charts/barChart/fragments/fixture/barContextData.js +3 -6
- package/dist/cjs/charts/barChart/fragments/fixture/index.js +1 -5
- package/dist/cjs/charts/barChart/index.js +1 -17
- package/dist/cjs/charts/barChart/utils/countBarChildren.js +5 -9
- package/dist/cjs/charts/barChart/utils/getAxisExtraSpacing.js +31 -35
- package/dist/cjs/charts/barChart/utils/getBarDataValue.js +1 -5
- package/dist/cjs/charts/barChart/utils/getRoundedBarMaxValue.js +1 -5
- package/dist/cjs/charts/index.js +3 -19
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +17 -21
- package/dist/cjs/charts/lineChart/context/index.js +2 -7
- package/dist/cjs/charts/lineChart/context/lineChartContext.js +2 -5
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +1 -4
- package/dist/cjs/charts/lineChart/fragments/fixture/index.js +1 -5
- package/dist/cjs/charts/lineChart/fragments/index.js +4 -11
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +31 -35
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.js +6 -10
- package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.js +10 -14
- package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.js +14 -18
- package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.js +17 -21
- package/dist/cjs/charts/lineChart/hook/index.js +3 -9
- package/dist/cjs/charts/lineChart/hook/useAutoClick.js +6 -10
- package/dist/cjs/charts/lineChart/hook/useHover.js +5 -9
- package/dist/cjs/charts/lineChart/hook/useIndicator.js +5 -9
- package/dist/cjs/charts/lineChart/index.js +1 -17
- package/dist/cjs/charts/lineChart/lineChart.js +12 -29
- package/dist/cjs/charts/lineChart/lineChart.type.js +1 -2
- package/dist/cjs/charts/lineChart/lineChartStructure.js +34 -38
- package/dist/cjs/charts/lineChart/utils/accessibilityTemplateProcessor.js +6 -10
- package/dist/cjs/charts/lineChart/utils/findSurroundingNumber.js +2 -7
- package/dist/cjs/charts/lineChart/utils/getDataValues.js +1 -5
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.js +26 -30
- package/dist/cjs/charts/lineChart/utils/getPathData.js +1 -5
- package/dist/cjs/charts/lineChart/utils/getProjection.js +1 -5
- package/dist/cjs/charts/lineChart/utils/getRoundedMaxValue.js +2 -7
- package/dist/cjs/charts/lineChart/utils/handleNodesFocus.js +1 -5
- package/dist/cjs/charts/lineChart/utils/index.js +6 -17
- package/dist/cjs/charts/pieChart/context/buildPieContextValue.js +8 -12
- package/dist/cjs/charts/pieChart/context/index.js +2 -7
- package/dist/cjs/charts/pieChart/context/pieChartContext.js +2 -5
- package/dist/cjs/charts/pieChart/fragments/index.js +2 -7
- package/dist/cjs/charts/pieChart/fragments/pieChartForeign.js +7 -11
- package/dist/cjs/charts/pieChart/fragments/pieChartPath.js +12 -16
- package/dist/cjs/charts/pieChart/fragments/pieChartSegment.js +6 -10
- package/dist/cjs/charts/pieChart/index.js +1 -17
- package/dist/cjs/charts/pieChart/pieChart.js +8 -25
- package/dist/cjs/charts/pieChart/pieChart.type.js +1 -2
- package/dist/cjs/charts/pieChart/pieChartStructure.js +16 -20
- package/dist/cjs/charts/pieChart/utils/buildL.js +1 -5
- package/dist/cjs/charts/pieChart/utils/calculatePoint.js +1 -5
- package/dist/cjs/charts/pieChart/utils/calculateSegmentPath.js +10 -14
- package/dist/cjs/charts/pieChart/utils/drawSegmentPath.js +6 -10
- package/dist/cjs/charts/pieChart/utils/index.js +2 -7
- package/dist/cjs/charts/pieChart/utils/rotationDirection.js +3 -7
- package/dist/cjs/components/axisChart/index.js +2 -18
- package/dist/cjs/components/axisChart/utils/filterLineProps/filterLineProps.js +1 -5
- package/dist/cjs/components/axisChart/utils/index.js +1 -17
- package/dist/cjs/components/axisChart/xAxis/index.js +2 -18
- package/dist/cjs/components/axisChart/xAxis/xAxis.js +14 -18
- package/dist/cjs/components/axisChart/xAxis/xAxis.types.js +1 -2
- package/dist/cjs/components/axisChart/yAxis/index.js +2 -18
- package/dist/cjs/components/axisChart/yAxis/yAxis.js +13 -17
- package/dist/cjs/components/axisChart/yAxis/yAxis.types.js +1 -2
- package/dist/cjs/components/bar/bar.js +9 -13
- package/dist/cjs/components/bar/bar.type.js +1 -4
- package/dist/cjs/components/bar/fragments/barChartSegment.js +3 -7
- package/dist/cjs/components/bar/index.js +2 -18
- package/dist/cjs/components/bar/utils/buildD.js +5 -9
- package/dist/cjs/components/bar/utils/getSegments.js +3 -7
- package/dist/cjs/components/chartText/chartText.js +3 -7
- package/dist/cjs/components/chartText/chartText.types.js +1 -2
- package/dist/cjs/components/chartText/index.js +2 -18
- package/dist/cjs/components/foreignObject/foreignObject.js +3 -7
- package/dist/cjs/components/foreignObject/foreignObject.types.js +1 -2
- package/dist/cjs/components/foreignObject/index.js +2 -18
- package/dist/cjs/components/index.js +10 -26
- package/dist/cjs/components/line/index.js +2 -18
- package/dist/cjs/components/line/line.js +3 -7
- package/dist/cjs/components/line/line.types.js +1 -2
- package/dist/cjs/components/node/components/circle/circle.js +4 -7
- package/dist/cjs/components/node/components/hexagon/hexagon.js +6 -9
- package/dist/cjs/components/node/components/pentagon/pentagon.js +6 -9
- package/dist/cjs/components/node/components/square/square.js +4 -7
- package/dist/cjs/components/node/components/star/star.js +6 -9
- package/dist/cjs/components/node/components/straight/straight.js +4 -7
- package/dist/cjs/components/node/components/triangle/triangle.js +4 -7
- package/dist/cjs/components/node/index.js +2 -18
- package/dist/cjs/components/node/node.js +22 -25
- package/dist/cjs/components/node/node.types.js +1 -4
- package/dist/cjs/components/node/utils/calculateShapePoints/calculateShapePoints.js +1 -5
- package/dist/cjs/components/path/components/nodePath/nodePath.js +9 -12
- package/dist/cjs/components/path/index.js +2 -18
- package/dist/cjs/components/path/path.js +20 -23
- package/dist/cjs/components/path/path.types.js +1 -2
- package/dist/cjs/components/plot/components/circle/circle.js +4 -7
- package/dist/cjs/components/plot/components/index.js +3 -19
- package/dist/cjs/components/plot/components/square/square.js +4 -7
- package/dist/cjs/components/plot/components/triangle/triangle.js +4 -7
- package/dist/cjs/components/plot/index.js +2 -18
- package/dist/cjs/components/plot/plot.js +21 -24
- package/dist/cjs/components/plot/plot.types.js +8 -11
- package/dist/cjs/components/svgContainer/index.js +1 -17
- package/dist/cjs/components/svgContainer/svgContainer.js +5 -8
- package/dist/cjs/components/svgContainer/svgContainer.types.js +1 -2
- package/dist/cjs/components/svgContainer/utils/buildViewBox/buildViewBox.js +1 -5
- package/dist/cjs/components/svgContainer/utils/index.js +1 -17
- package/dist/cjs/components/tick/index.js +2 -18
- package/dist/cjs/components/tick/tick.js +4 -8
- package/dist/cjs/components/tick/tick.types.js +1 -4
- package/dist/cjs/components/zoomArea/components/HandlerIcon.js +3 -7
- package/dist/cjs/components/zoomArea/components/LineRenderer.js +3 -7
- package/dist/cjs/components/zoomArea/components/SelectionArea.js +9 -14
- package/dist/cjs/components/zoomArea/components/ZoomHandler.js +6 -10
- package/dist/cjs/components/zoomArea/components/index.js +4 -12
- package/dist/cjs/components/zoomArea/hooks/index.js +5 -13
- package/dist/cjs/components/zoomArea/hooks/useDragInteraction.js +19 -23
- package/dist/cjs/components/zoomArea/hooks/useKeyboardNavigation.js +18 -22
- package/dist/cjs/components/zoomArea/hooks/useResponsiveCanvas.js +12 -16
- package/dist/cjs/components/zoomArea/hooks/useZoomAreaFocus.js +6 -10
- package/dist/cjs/components/zoomArea/hooks/useZoomData.js +8 -12
- package/dist/cjs/components/zoomArea/index.js +5 -21
- package/dist/cjs/components/zoomArea/utils/accessibilityLabels.js +6 -11
- package/dist/cjs/components/zoomArea/utils/index.js +3 -14
- package/dist/cjs/components/zoomArea/utils/indexRounding.js +5 -11
- package/dist/cjs/components/zoomArea/utils/interactionConfig.js +1 -5
- package/dist/cjs/components/zoomArea/utils/pathGeneration.js +4 -9
- package/dist/cjs/components/zoomArea/utils/rangeAndPositions.js +5 -13
- package/dist/cjs/components/zoomArea/utils/selectionConfig.js +1 -5
- package/dist/cjs/components/zoomArea/zoomArea.js +35 -39
- package/dist/cjs/components/zoomArea/zoomArea.type.js +1 -4
- package/dist/cjs/hooks/index.js +2 -18
- package/dist/cjs/hooks/useFocus/useFocus.js +5 -9
- package/dist/cjs/hooks/useFocus/useFocus.types.js +1 -2
- package/dist/cjs/hooks/useHover/useHover.js +5 -9
- package/dist/cjs/hooks/useHover/useHover.types.js +1 -2
- package/dist/cjs/index.js +3 -19
- package/dist/cjs/types/canvas.type.js +1 -4
- package/dist/cjs/types/errors.type.js +1 -4
- package/dist/cjs/types/focusConfig.type.js +1 -4
- package/dist/cjs/types/index.js +4 -20
- package/dist/cjs/types/position.enum.js +1 -4
- package/dist/cjs/types/unit.enum.js +1 -4
- package/dist/cjs/types/valueFormatter.type.js +1 -2
- package/dist/cjs/utils/ajustedTextSpace/ajustedTextSpace.js +1 -5
- package/dist/cjs/utils/buildErrors/buildErrors.js +3 -7
- package/dist/cjs/utils/buildTickValues/buildTickValues.js +2 -7
- package/dist/cjs/utils/calculateFocusOutline/calculateFocusOutline.js +8 -13
- package/dist/cjs/utils/classNames/classNames.js +1 -5
- package/dist/cjs/utils/cssGradientToSvg/cssGradientToSvg.js +4 -8
- package/dist/cjs/utils/cssGradientToSvg/cssGradientToSvg.types.js +1 -2
- package/dist/cjs/utils/cursorNear/isNear.js +1 -5
- package/dist/cjs/utils/getAxisData/getAxisData.js +1 -5
- package/dist/cjs/utils/getCanvasDimensions/getCanvasDimensions.js +8 -12
- package/dist/cjs/utils/getChildrenAttr/getChildrenAttr.js +4 -8
- package/dist/cjs/utils/getCoordinates/getCoordinates.js +9 -14
- package/dist/cjs/utils/getDataFingerprint/getDataFingerprint.js +1 -5
- package/dist/cjs/utils/getPoints/getPoints.js +1 -5
- package/dist/cjs/utils/getTickTextCoordinate/getTickTextCoordinates.js +5 -10
- package/dist/cjs/utils/getTicks/getTicks.js +2 -7
- package/dist/cjs/utils/index.js +8 -24
- package/dist/cjs/utils/parseStringToNumberPx.ts/parseStringToNumberPx.js +3 -7
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +1 -5
- package/dist/cjs/utils/shadowSvg/shadowSvg.js +3 -7
- package/dist/cjs/utils/shadowSvg/shadowSvg.types.js +1 -2
- package/dist/cjs/utils/textBound/textBound.js +1 -5
- package/dist/kubit-ui-web-react-charts.cjs.js +1 -10
- package/dist/kubit-ui-web-react-charts.es.js +1 -10
- package/dist/kubit-ui-web-react-charts.umd.js +1 -10
- package/dist/types/charts/barChart/barChart.d.ts +5 -5
- package/dist/types/charts/barChart/barChart.type.d.ts +1 -1
- package/dist/types/charts/barChart/context/barChartContext.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartXAxis.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartYAxis.d.ts +1 -1
- package/dist/types/charts/lineChart/context/lineChartContext.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartPath.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts +1 -1
- package/dist/types/charts/lineChart/lineChart.d.ts +5 -5
- package/dist/types/charts/lineChart/lineChart.type.d.ts +1 -1
- package/dist/types/charts/lineChart/lineChartStructure.d.ts +1 -1
- package/dist/types/charts/pieChart/context/pieChartContext.d.ts +1 -1
- package/dist/types/charts/pieChart/fragments/pieChartForeign.d.ts +1 -1
- package/dist/types/charts/pieChart/fragments/pieChartPath.d.ts +1 -1
- package/dist/types/charts/pieChart/pieChart.d.ts +3 -3
- package/dist/types/charts/pieChart/pieChart.type.d.ts +1 -1
- package/dist/types/charts/pieChart/pieChartStructure.d.ts +1 -1
- package/dist/types/components/axisChart/xAxis/xAxis.d.ts +1 -1
- package/dist/types/components/axisChart/yAxis/yAxis.d.ts +1 -1
- package/dist/types/components/bar/bar.d.ts +1 -1
- package/dist/types/components/bar/fragments/barChartSegment.d.ts +1 -1
- package/dist/types/components/chartText/chartText.d.ts +1 -1
- package/dist/types/components/foreignObject/foreignObject.d.ts +1 -1
- package/dist/types/components/foreignObject/foreignObject.types.d.ts +1 -1
- package/dist/types/components/line/line.d.ts +1 -1
- package/dist/types/components/node/components/circle/circle.d.ts +1 -1
- package/dist/types/components/node/components/hexagon/hexagon.d.ts +1 -1
- package/dist/types/components/node/components/pentagon/pentagon.d.ts +1 -1
- package/dist/types/components/node/components/square/square.d.ts +1 -1
- package/dist/types/components/node/components/star/star.d.ts +1 -1
- package/dist/types/components/node/components/straight/straight.d.ts +1 -1
- package/dist/types/components/node/components/triangle/triangle.d.ts +1 -1
- package/dist/types/components/node/node.d.ts +1 -1
- package/dist/types/components/path/components/nodePath/nodePath.d.ts +2 -2
- package/dist/types/components/path/path.d.ts +1 -1
- package/dist/types/components/path/path.types.d.ts +1 -1
- package/dist/types/components/plot/components/circle/circle.d.ts +1 -1
- package/dist/types/components/plot/components/square/square.d.ts +1 -1
- package/dist/types/components/plot/components/triangle/triangle.d.ts +1 -1
- package/dist/types/components/plot/plot.d.ts +1 -1
- package/dist/types/components/svgContainer/svgContainer.d.ts +1 -1
- package/dist/types/components/tick/tick.d.ts +1 -1
- package/dist/types/components/zoomArea/components/HandlerIcon.d.ts +1 -1
- package/dist/types/components/zoomArea/components/LineRenderer.d.ts +1 -1
- package/dist/types/components/zoomArea/components/SelectionArea.d.ts +1 -1
- package/dist/types/components/zoomArea/components/ZoomHandler.d.ts +1 -1
- package/dist/types/hooks/useFocus/useFocus.types.d.ts +1 -1
- package/dist/types/hooks/useHover/useHover.types.d.ts +1 -1
- package/dist/types/utils/getChildrenAttr/getChildrenAttr.d.ts +1 -1
- package/package.json +44 -47
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const barChartYAxis_1 = require("../fragments/barChartYAxis");
|
|
12
|
-
const getBarDataValue_1 = require("./getBarDataValue");
|
|
13
|
-
const getRoundedBarMaxValue_1 = require("./getRoundedBarMaxValue");
|
|
1
|
+
import { Children, isValidElement } from 'react';
|
|
2
|
+
import { BarOrientation } from '../../../components/bar/bar.type';
|
|
3
|
+
import { Positions } from '../../../types/position.enum';
|
|
4
|
+
import { buildTickValues } from '../../../utils/buildTickValues/buildTickValues';
|
|
5
|
+
import { textBound } from '../../../utils/textBound/textBound';
|
|
6
|
+
import { BarChartPath } from '../fragments/barChartPath';
|
|
7
|
+
import { BarChartXAxis } from '../fragments/barChartXAxis';
|
|
8
|
+
import { BarChartYAxis } from '../fragments/barChartYAxis';
|
|
9
|
+
import { getBarDataValues } from './getBarDataValue';
|
|
10
|
+
import { getBarKeyRoundMaxValue } from './getRoundedBarMaxValue';
|
|
14
11
|
const handleBarChartXAxis = (child, data, pKey, ajustedX, barsSpacing, viewBox, canvasHeight, canvasWidth) => {
|
|
15
12
|
const { position, tickText, tickValues } = child.props;
|
|
16
13
|
const fontSize = tickText?.fontSize ?? 0;
|
|
17
14
|
const spaceFontSize = fontSize * ajustedX;
|
|
18
15
|
const xData = tickValues
|
|
19
|
-
?
|
|
16
|
+
? getBarDataValues(tickValues)
|
|
20
17
|
: data.map(d => d[pKey]);
|
|
21
|
-
const fontSpacing =
|
|
18
|
+
const fontSpacing = textBound({
|
|
22
19
|
bound: 'width',
|
|
23
20
|
data: xData,
|
|
24
21
|
fontSize,
|
|
@@ -27,9 +24,9 @@ const handleBarChartXAxis = (child, data, pKey, ajustedX, barsSpacing, viewBox,
|
|
|
27
24
|
viewBox,
|
|
28
25
|
});
|
|
29
26
|
const securityXSpace = (() => (barsSpacing > fontSpacing ? barsSpacing : fontSpacing))();
|
|
30
|
-
const extraSpaceBottomY = position ===
|
|
31
|
-
const extraSpaceTopY = position ===
|
|
32
|
-
const barChartXPosition = (() => position ||
|
|
27
|
+
const extraSpaceBottomY = position === Positions.BOTTOM ? spaceFontSize + (tickText?.top ?? 0) : 0;
|
|
28
|
+
const extraSpaceTopY = position === Positions.TOP ? spaceFontSize + (tickText?.bottom ?? 0) : 0;
|
|
29
|
+
const barChartXPosition = (() => position || Positions.BOTTOM)();
|
|
33
30
|
const xBreakAxis = tickValues?.numeric
|
|
34
31
|
? (tickValues.numeric.breakAxis ?? 0)
|
|
35
32
|
: (tickText?.custom?.breakAxis ?? 0);
|
|
@@ -47,10 +44,10 @@ const handleBarChartYAxis = (child, data, pKey, ajustedY, barSpacing, viewBox, c
|
|
|
47
44
|
const fontSize = tickText?.fontSize ?? 0;
|
|
48
45
|
const spaceFontSize = fontSize * ajustedY; //! review
|
|
49
46
|
const dataValues = tickValues ||
|
|
50
|
-
|
|
51
|
-
const yData =
|
|
47
|
+
buildTickValues([...new Set(getBarKeyRoundMaxValue(data, pKey))]);
|
|
48
|
+
const yData = getBarDataValues(dataValues);
|
|
52
49
|
const securityYSpace = (() => (barSpacing > spaceFontSize ? barSpacing : spaceFontSize))();
|
|
53
|
-
const textWidth =
|
|
50
|
+
const textWidth = textBound({
|
|
54
51
|
bound: 'width',
|
|
55
52
|
data: yData,
|
|
56
53
|
fontSize,
|
|
@@ -58,9 +55,9 @@ const handleBarChartYAxis = (child, data, pKey, ajustedY, barSpacing, viewBox, c
|
|
|
58
55
|
svgWidth: `${canvasWidth}`,
|
|
59
56
|
viewBox,
|
|
60
57
|
});
|
|
61
|
-
const extraSpaceLeftX = position ===
|
|
62
|
-
const extraSpaceRightX = position ===
|
|
63
|
-
const barChartYPosition = (() => position ||
|
|
58
|
+
const extraSpaceLeftX = position === Positions.LEFT ? textWidth + (tickText?.right ?? 0) : 0;
|
|
59
|
+
const extraSpaceRightX = position === Positions.RIGHT ? textWidth + (tickText?.left ?? 0) : 0;
|
|
60
|
+
const barChartYPosition = (() => position || Positions.LEFT)();
|
|
64
61
|
const yBreakAxis = tickValues?.numeric
|
|
65
62
|
? (tickValues.numeric.breakAxis ?? 0)
|
|
66
63
|
: (tickText?.custom?.breakAxis ?? 0);
|
|
@@ -74,10 +71,10 @@ const handleBarChartYAxis = (child, data, pKey, ajustedY, barSpacing, viewBox, c
|
|
|
74
71
|
yData,
|
|
75
72
|
};
|
|
76
73
|
};
|
|
77
|
-
const getAxisExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, gapBetweenBars, orientation, pKey, viewBox, }) => {
|
|
74
|
+
export const getAxisExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, gapBetweenBars, orientation, pKey, viewBox, }) => {
|
|
78
75
|
let result = {
|
|
79
|
-
barChartXPosition:
|
|
80
|
-
barChartYPosition:
|
|
76
|
+
barChartXPosition: Positions.BOTTOM,
|
|
77
|
+
barChartYPosition: Positions.LEFT,
|
|
81
78
|
extraSpaceBottomY: 0,
|
|
82
79
|
extraSpaceLeftX: 0,
|
|
83
80
|
extraSpaceRightX: 0,
|
|
@@ -93,21 +90,21 @@ const getAxisExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, ch
|
|
|
93
90
|
};
|
|
94
91
|
let barsSpacing = gapBetweenBars;
|
|
95
92
|
const reviews = [];
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
if (child.type ===
|
|
93
|
+
Children.forEach(children, (child) => {
|
|
94
|
+
if (isValidElement(child)) {
|
|
95
|
+
if (child.type === BarChartPath && !reviews.includes(child.props.order)) {
|
|
99
96
|
reviews.push(child.props.order);
|
|
100
97
|
barsSpacing += child.props.barConfig.barWidth ?? 0;
|
|
101
98
|
}
|
|
102
|
-
if (child.type ===
|
|
103
|
-
const securitySpace = orientation ===
|
|
99
|
+
if (child.type === BarChartXAxis) {
|
|
100
|
+
const securitySpace = orientation === BarOrientation.VERTICAL ? barsSpacing : 0;
|
|
104
101
|
result = {
|
|
105
102
|
...result,
|
|
106
103
|
...handleBarChartXAxis(child, data, pKey, ajustedX, securitySpace, viewBox, canvasHeight, canvasWidth),
|
|
107
104
|
};
|
|
108
105
|
}
|
|
109
|
-
else if (child.type ===
|
|
110
|
-
const securitySpace = orientation ===
|
|
106
|
+
else if (child.type === BarChartYAxis) {
|
|
107
|
+
const securitySpace = orientation === BarOrientation.HORIZONTAL ? barsSpacing : 0;
|
|
111
108
|
result = {
|
|
112
109
|
...result,
|
|
113
110
|
...handleBarChartYAxis(child, data, pKey, ajustedY, securitySpace, viewBox, canvasHeight, canvasWidth),
|
|
@@ -117,4 +114,3 @@ const getAxisExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, ch
|
|
|
117
114
|
});
|
|
118
115
|
return result;
|
|
119
116
|
};
|
|
120
|
-
exports.getAxisExtraSpacing = getAxisExtraSpacing;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBarDataValues = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Retrieves the data values from the given BarTickValuesAxisProps object.
|
|
6
3
|
* @param data - The BarTickValuesAxisProps object containing the data values.
|
|
7
4
|
* @returns An array of string values representing the data, or undefined if the data is invalid.
|
|
8
5
|
*/
|
|
9
|
-
const getBarDataValues = (data) => {
|
|
6
|
+
export const getBarDataValues = (data) => {
|
|
10
7
|
if (data.custom) {
|
|
11
8
|
return data.custom?.values;
|
|
12
9
|
}
|
|
@@ -20,4 +17,3 @@ const getBarDataValues = (data) => {
|
|
|
20
17
|
}
|
|
21
18
|
return undefined;
|
|
22
19
|
};
|
|
23
|
-
exports.getBarDataValues = getBarDataValues;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBarKeyRoundMaxValue = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Returns an array of rounded maximum values for each yKey in the given data.
|
|
6
3
|
* @param data - The array of data points.
|
|
7
4
|
* @param xKey - The xKey used for filtering the data.
|
|
8
5
|
* @returns An array of rounded maximum values.
|
|
9
6
|
*/
|
|
10
|
-
const getBarKeyRoundMaxValue = (data, Key) => {
|
|
7
|
+
export const getBarKeyRoundMaxValue = (data, Key) => {
|
|
11
8
|
return data.flatMap(point => Object.keys(point)
|
|
12
9
|
.filter(k => k !== Key && typeof point[k] === 'number')
|
|
13
10
|
.map(k => Number(point[k])));
|
|
14
11
|
};
|
|
15
|
-
exports.getBarKeyRoundMaxValue = getBarKeyRoundMaxValue;
|
package/dist/cjs/charts/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./barChart"), exports);
|
|
18
|
-
__exportStar(require("./lineChart"), exports);
|
|
19
|
-
__exportStar(require("./pieChart/pieChart"), exports);
|
|
1
|
+
export * from './barChart';
|
|
2
|
+
export * from './lineChart';
|
|
3
|
+
export * from './pieChart/pieChart';
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const getPoints_1 = require("../../../utils/getPoints/getPoints");
|
|
8
|
-
const getTicks_1 = require("../../../utils/getTicks/getTicks");
|
|
9
|
-
const getExtraSpacing_1 = require("../utils/getExtraSpacing");
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
import { BuildError, buildError } from '../../../utils/buildErrors/buildErrors';
|
|
3
|
+
import { getXCoordinates, getYCoordinates } from '../../../utils/getCoordinates/getCoordinates';
|
|
4
|
+
import { getPoints } from '../../../utils/getPoints/getPoints';
|
|
5
|
+
import { getXTicks, getYTicks } from '../../../utils/getTicks/getTicks';
|
|
6
|
+
import { getExtraSpacing } from '../utils/getExtraSpacing';
|
|
10
7
|
/**
|
|
11
8
|
* Builds the context value for the line chart.
|
|
12
9
|
*
|
|
13
10
|
* @param {BuildContextValue} options - The options for building the context value.
|
|
14
11
|
* @returns {LineContextValue} - The built context value.
|
|
15
12
|
*/
|
|
16
|
-
const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
|
|
13
|
+
export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
|
|
17
14
|
let error = undefined;
|
|
18
15
|
/**
|
|
19
16
|
* Get the extra spacings for the line chart.
|
|
20
17
|
*/
|
|
21
|
-
const { extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, lineChartXPosition, lineChartYPosition, securityXSpace, securityYSpace, xAxisText, xBreakAxis, xData, yAxisText, yBreakAxis, yData, } =
|
|
18
|
+
const { extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, lineChartXPosition, lineChartYPosition, securityXSpace, securityYSpace, xAxisText, xBreakAxis, xData, yAxisText, yBreakAxis, yData, } = getExtraSpacing({
|
|
22
19
|
ajustedX,
|
|
23
20
|
ajustedY,
|
|
24
21
|
canvasHeight,
|
|
@@ -31,9 +28,9 @@ const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
|
|
|
31
28
|
/**
|
|
32
29
|
* Calculate the tick values for the X Axis.
|
|
33
30
|
*/
|
|
34
|
-
const crossXAxis = lineChartXPosition !==
|
|
31
|
+
const crossXAxis = lineChartXPosition !== Positions.TOP && lineChartXPosition !== Positions.BOTTOM;
|
|
35
32
|
const yAxisSpace = extraSpaceLeftX + extraSpaceRightX;
|
|
36
|
-
const xTickValues =
|
|
33
|
+
const xTickValues = getXTicks({
|
|
37
34
|
initPos: extraSpaceLeftX,
|
|
38
35
|
maxSpaceAvailable: canvasWidth,
|
|
39
36
|
otherAxisSpace: yAxisSpace,
|
|
@@ -42,15 +39,15 @@ const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
|
|
|
42
39
|
});
|
|
43
40
|
if ((xTickValues ?? []).some(({ position }) => isNaN(position))) {
|
|
44
41
|
error = {
|
|
45
|
-
error:
|
|
42
|
+
error: buildError(BuildError.INVALID_X_TICK),
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
45
|
/**
|
|
49
46
|
* Calculate the tick values for the Y Axis.
|
|
50
47
|
*/
|
|
51
|
-
const crossYAxis = lineChartYPosition !==
|
|
48
|
+
const crossYAxis = lineChartYPosition !== Positions.LEFT && lineChartYPosition !== Positions.RIGHT;
|
|
52
49
|
const otherAxisSpace = extraSpaceTopY + extraSpaceBottomY;
|
|
53
|
-
const yTickValues =
|
|
50
|
+
const yTickValues = getYTicks({
|
|
54
51
|
initPos: canvasHeight - extraSpaceBottomY,
|
|
55
52
|
maxSpaceAvailable: canvasHeight,
|
|
56
53
|
otherAxisSpace,
|
|
@@ -60,12 +57,12 @@ const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
|
|
|
60
57
|
/**
|
|
61
58
|
* Calculate the custom breakAxis for the X and Y Axis.
|
|
62
59
|
*/
|
|
63
|
-
const customBreakXAxis = crossXAxis ?
|
|
64
|
-
const customBreakYAxis = crossYAxis ?
|
|
60
|
+
const customBreakXAxis = crossXAxis ? getPoints(yTickValues || [], [String(xBreakAxis)])[0] : 0;
|
|
61
|
+
const customBreakYAxis = crossYAxis ? getPoints(xTickValues || [], [String(yBreakAxis)])[0] : 0;
|
|
65
62
|
/**
|
|
66
63
|
* Calculate the X coordinates for the line chart.
|
|
67
64
|
*/
|
|
68
|
-
const xCoordinates =
|
|
65
|
+
const xCoordinates = getXCoordinates({
|
|
69
66
|
canvasHeight,
|
|
70
67
|
canvasWidth,
|
|
71
68
|
customBreakAxis: Number(customBreakXAxis),
|
|
@@ -79,7 +76,7 @@ const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
|
|
|
79
76
|
/**
|
|
80
77
|
* Calculate the Y coordinates for the line chart.
|
|
81
78
|
*/
|
|
82
|
-
const yCoordinates =
|
|
79
|
+
const yCoordinates = getYCoordinates({
|
|
83
80
|
canvasHeight,
|
|
84
81
|
canvasWidth,
|
|
85
82
|
customBreakAxis: Number(customBreakYAxis),
|
|
@@ -135,4 +132,3 @@ const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
|
|
|
135
132
|
yAxisText,
|
|
136
133
|
};
|
|
137
134
|
};
|
|
138
|
-
exports.buildLineContextValue = buildLineContextValue;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LineChartContext = exports.buildLineContextValue = void 0;
|
|
4
|
-
var buildLineContextValue_1 = require("./buildLineContextValue");
|
|
5
|
-
Object.defineProperty(exports, "buildLineContextValue", { enumerable: true, get: function () { return buildLineContextValue_1.buildLineContextValue; } });
|
|
6
|
-
var lineChartContext_1 = require("./lineChartContext");
|
|
7
|
-
Object.defineProperty(exports, "LineChartContext", { enumerable: true, get: function () { return lineChartContext_1.LineChartContext; } });
|
|
1
|
+
export { buildLineContextValue } from './buildLineContextValue';
|
|
2
|
+
export { LineChartContext } from './lineChartContext';
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LineChartContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
exports.LineChartContext = (0, react_1.createContext)({});
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
export const LineChartContext = createContext({});
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONTEXT = void 0;
|
|
4
|
-
var contextData_1 = require("./contextData");
|
|
5
|
-
Object.defineProperty(exports, "CONTEXT", { enumerable: true, get: function () { return contextData_1.CONTEXT; } });
|
|
1
|
+
export { CONTEXT } from './contextData';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "LineChartPath", { enumerable: true, get: function () { return lineChartPath_1.LineChartPath; } });
|
|
6
|
-
var lineChartSeparator_1 = require("./lineChartSeparator");
|
|
7
|
-
Object.defineProperty(exports, "LineChartSeparator", { enumerable: true, get: function () { return lineChartSeparator_1.LineChartSeparator; } });
|
|
8
|
-
var lineChartXAxis_1 = require("./lineChartXAxis");
|
|
9
|
-
Object.defineProperty(exports, "LineChartXAxis", { enumerable: true, get: function () { return lineChartXAxis_1.LineChartXAxis; } });
|
|
10
|
-
var lineChartYAxis_1 = require("./lineChartYAxis");
|
|
11
|
-
Object.defineProperty(exports, "LineChartYAxis", { enumerable: true, get: function () { return lineChartYAxis_1.LineChartYAxis; } });
|
|
1
|
+
export { LineChartPath } from './lineChartPath';
|
|
2
|
+
export { LineChartSeparator } from './lineChartSeparator';
|
|
3
|
+
export { LineChartXAxis } from './lineChartXAxis';
|
|
4
|
+
export { LineChartYAxis } from './lineChartYAxis';
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const handleNodesFocus_1 = require("../utils/handleNodesFocus");
|
|
16
|
-
require("./lineChartPath.css");
|
|
17
|
-
const lineChartProjection_1 = require("./lineChartProjection");
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect, useRef } from 'react';
|
|
3
|
+
import { Line } from '../../../components/line/line';
|
|
4
|
+
import { Node } from '../../../components/node/node';
|
|
5
|
+
import { Path } from '../../../components/path/path';
|
|
6
|
+
import { getPoints } from '../../../utils/getPoints/getPoints';
|
|
7
|
+
import { pickCustomAttributes } from '../../../utils/pickCustomAttributes/pickCustomAttributes';
|
|
8
|
+
import { LineChartContext } from '../context/lineChartContext';
|
|
9
|
+
import { useIndicator } from '../hook/useIndicator';
|
|
10
|
+
import { findClosestNumber, findSurroundingNumber } from '../utils/findSurroundingNumber';
|
|
11
|
+
import { getPathData } from '../utils/getPathData';
|
|
12
|
+
import { handleNodesFocus } from '../utils/handleNodesFocus';
|
|
13
|
+
import './lineChartPath.css';
|
|
14
|
+
import { LineChartProjection } from './lineChartProjection';
|
|
18
15
|
const getAxisData = (data, key) => {
|
|
19
16
|
return data.map(dt => dt[key]);
|
|
20
17
|
};
|
|
21
|
-
const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getNodesCoords, indicatorConfig, lineProjection, onClick, ...props }) => {
|
|
18
|
+
export const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getNodesCoords, indicatorConfig, lineProjection, onClick, ...props }) => {
|
|
22
19
|
// recovery the context values
|
|
23
|
-
const { xAxisCoordinates, yAxisCoordinates, ...context } =
|
|
20
|
+
const { xAxisCoordinates, yAxisCoordinates, ...context } = useContext(LineChartContext);
|
|
24
21
|
// the node indicator logic
|
|
25
|
-
const { indicatorRef, pathRef } =
|
|
22
|
+
const { indicatorRef, pathRef } = useIndicator(context.xCursor, !!indicatorConfig);
|
|
26
23
|
const showIndicator = !!indicatorConfig && context.xCursor !== -Infinity;
|
|
27
|
-
const innerRefs =
|
|
28
|
-
const pressedRef =
|
|
24
|
+
const innerRefs = useRef(null);
|
|
25
|
+
const pressedRef = useRef(null);
|
|
29
26
|
// the projection line logic
|
|
30
27
|
const { autoClick, lineIndicator, ...nodeIndicatorConfig } = indicatorConfig || {};
|
|
31
28
|
// line indicator <Y> coordinates
|
|
@@ -36,24 +33,24 @@ const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getN
|
|
|
36
33
|
const { tickValues: yTickValues } = yAxisCoordinates;
|
|
37
34
|
const xData = getAxisData(context.data, context.xKey);
|
|
38
35
|
const yData = getAxisData(context.data, props.dataKey);
|
|
39
|
-
const xPoints =
|
|
40
|
-
const yPoints =
|
|
36
|
+
const xPoints = getPoints(xTickValues, xData, true);
|
|
37
|
+
const yPoints = getPoints(yTickValues, yData);
|
|
41
38
|
const points = xPoints.map((x, i) => [x, yPoints[i]]);
|
|
42
39
|
// the path data
|
|
43
|
-
const dataOnlyLine =
|
|
40
|
+
const dataOnlyLine = getPathData({
|
|
44
41
|
curved,
|
|
45
42
|
extendToBottom: false,
|
|
46
43
|
points,
|
|
47
44
|
svgHeight: Number(context.canvasHeight) - context.extraSpaceBottomY,
|
|
48
45
|
});
|
|
49
|
-
const dataFill =
|
|
46
|
+
const dataFill = getPathData({
|
|
50
47
|
curved,
|
|
51
48
|
extendToBottom: !!props.fill || !!props.gradient,
|
|
52
49
|
points,
|
|
53
50
|
svgHeight: Number(context.canvasHeight) - context.extraSpaceBottomY,
|
|
54
51
|
});
|
|
55
52
|
// the ref to the path and handler the nodes focus
|
|
56
|
-
|
|
53
|
+
useEffect(() => {
|
|
57
54
|
if (!innerRefs.current?.path) {
|
|
58
55
|
return;
|
|
59
56
|
}
|
|
@@ -61,15 +58,15 @@ const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getN
|
|
|
61
58
|
const main = innerRefs.current.main;
|
|
62
59
|
const nodes = innerRefs.current.node;
|
|
63
60
|
const data = xData.map((d, i) => ({ x: d, y: yData[i] }));
|
|
64
|
-
const { mount, unmount } =
|
|
61
|
+
const { mount, unmount } = handleNodesFocus({ data, getNodeFocusInfo, nodes, ref: main });
|
|
65
62
|
mount();
|
|
66
63
|
// eslint-disable-next-line consistent-return
|
|
67
64
|
return () => unmount();
|
|
68
65
|
}, []);
|
|
69
66
|
// the auto click logic
|
|
70
|
-
|
|
67
|
+
useEffect(() => {
|
|
71
68
|
if (props.nodeConfig && showIndicator && autoClick) {
|
|
72
|
-
const { idx, match } =
|
|
69
|
+
const { idx, match } = findSurroundingNumber(xPoints, context.xCursor);
|
|
73
70
|
if (match && idx !== pressedRef.current) {
|
|
74
71
|
pressedRef.current = idx;
|
|
75
72
|
const evt = new MouseEvent('click', { bubbles: true });
|
|
@@ -83,27 +80,26 @@ const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getN
|
|
|
83
80
|
}
|
|
84
81
|
}, [context.xCursor]);
|
|
85
82
|
// Return the nodes coordinates
|
|
86
|
-
|
|
83
|
+
useEffect(() => {
|
|
87
84
|
getNodesCoords?.(points);
|
|
88
85
|
}, [points]);
|
|
89
86
|
// the click handler
|
|
90
87
|
const handleClick = (data) => {
|
|
91
88
|
onClick?.(data);
|
|
92
89
|
if (closestClick) {
|
|
93
|
-
const closest =
|
|
90
|
+
const closest = findClosestNumber(xPoints, context.xCursor);
|
|
94
91
|
const evt = new MouseEvent('click', { bubbles: true });
|
|
95
92
|
evt.autoClick = false;
|
|
96
93
|
innerRefs.current?.node?.[closest]?.dispatchEvent(evt);
|
|
97
94
|
}
|
|
98
95
|
};
|
|
99
96
|
// Extract custom attributes (aria-*, data-*) and handle deprecated ariaLabel
|
|
100
|
-
const customAttributes =
|
|
97
|
+
const customAttributes = pickCustomAttributes(props);
|
|
101
98
|
const mergedProps = {
|
|
102
99
|
...props,
|
|
103
100
|
...customAttributes,
|
|
104
101
|
// Handle deprecated ariaLabel - give precedence to ariaLabel for backward compatibility
|
|
105
102
|
...(ariaLabel && { 'aria-label': ariaLabel }),
|
|
106
103
|
};
|
|
107
|
-
return ((
|
|
104
|
+
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: Number(context.canvasHeight) - context.extraSpaceBottomY })), showIndicator && (_jsxs(_Fragment, { children: [!!lineIndicator && (_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 }) })] }))] }));
|
|
108
105
|
};
|
|
109
|
-
exports.LineChartPath = LineChartPath;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const getProjection_1 = require("../utils/getProjection");
|
|
6
|
-
require("./lineChartPath.css");
|
|
7
|
-
const LineChartProjection = ({ curved, lineProjection, points, svgHeight, }) => {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getProjection } from '../utils/getProjection';
|
|
3
|
+
import './lineChartPath.css';
|
|
4
|
+
export const LineChartProjection = ({ curved, lineProjection, points, svgHeight, }) => {
|
|
8
5
|
const { lower, shapeColor, upper } = lineProjection;
|
|
9
6
|
const { xProjection: xUp, yProjection: yUp, ...upperProps } = upper || {};
|
|
10
7
|
const { xProjection: xDw, yProjection: yDw, ...lowerProps } = lower || {};
|
|
11
8
|
const upperProjection = xUp || yUp ? { x: xUp, y: yUp } : undefined;
|
|
12
9
|
const lowerProjection = xDw || yDw ? { x: xDw, y: yDw } : undefined;
|
|
13
|
-
const { downPath, shapePath, upPath } =
|
|
10
|
+
const { downPath, shapePath, upPath } = getProjection({
|
|
14
11
|
curved,
|
|
15
12
|
lowerProjection,
|
|
16
13
|
points,
|
|
17
14
|
svgHeight,
|
|
18
15
|
upperProjection,
|
|
19
16
|
});
|
|
20
|
-
return ((
|
|
17
|
+
return (_jsxs("g", { className: "pointer-events-none", children: [_jsx("path", { d: shapePath, fill: shapeColor, stroke: "transparent", strokeWidth: "0.1" }), ";", upPath && _jsx("path", { d: upPath, ...upperProps }), downPath && _jsx("path", { d: downPath, ...lowerProps })] }));
|
|
21
18
|
};
|
|
22
|
-
exports.LineChartProjection = LineChartProjection;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const lineChartContext_1 = require("../context/lineChartContext");
|
|
8
|
-
const LineChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, topSeparator, xBreakAxis, yBreakAxis, }) => {
|
|
9
|
-
const { crossXAxis, crossYAxis, xAxisCoordinates, yAxisCoordinates } = (0, react_1.useContext)(lineChartContext_1.LineChartContext);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { getPoints } from '../../../utils/getPoints/getPoints';
|
|
4
|
+
import { LineChartContext } from '../context/lineChartContext';
|
|
5
|
+
export const LineChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, topSeparator, xBreakAxis, yBreakAxis, }) => {
|
|
6
|
+
const { crossXAxis, crossYAxis, xAxisCoordinates, yAxisCoordinates } = useContext(LineChartContext);
|
|
10
7
|
if (!topSeparator && !rightSeparator && !areaSeparator) {
|
|
11
|
-
return (
|
|
8
|
+
return _jsx(_Fragment, {});
|
|
12
9
|
}
|
|
13
|
-
const customXEnd = xBreakAxis &&
|
|
14
|
-
const customYEnd = yBreakAxis &&
|
|
10
|
+
const customXEnd = xBreakAxis && getPoints(xAxisCoordinates.tickValues, [xBreakAxis], true)[0];
|
|
11
|
+
const customYEnd = yBreakAxis && getPoints(yAxisCoordinates.tickValues, [yBreakAxis])[0];
|
|
15
12
|
const autoXEnd = crossYAxis ? yAxisCoordinates.coordinates.x1 : xAxisCoordinates.coordinates.x2;
|
|
16
13
|
const autoYEnd = crossXAxis ? xAxisCoordinates.coordinates.y1 : yAxisCoordinates.coordinates.y1;
|
|
17
14
|
const xStart = xAxisCoordinates.coordinates.x1;
|
|
@@ -21,6 +18,5 @@ const LineChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, topSepa
|
|
|
21
18
|
const squarePath = `M${xStart} ${yStart} H ${xEnd} V ${yEnd} H ${xStart} Z`;
|
|
22
19
|
const lineTop = `M${xStart} ${yEnd} H ${xEnd}`;
|
|
23
20
|
const lineRight = `M${xEnd} ${yStart} V ${yEnd}`;
|
|
24
|
-
return ((
|
|
21
|
+
return (_jsxs("g", { children: [_jsx("path", { d: squarePath, "data-testid": `${dataTestId}Area`, ...areaSeparator }), _jsx("path", { d: lineTop, "data-testid": `${dataTestId}Top`, ...topSeparator }), _jsx("path", { d: lineRight, "data-testid": `${dataTestId}Right`, ...rightSeparator })] }));
|
|
25
22
|
};
|
|
26
|
-
exports.LineChartSeparator = LineChartSeparator;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const LineChartXAxis = ({ ariaLabel, position = position_enum_1.Positions.BOTTOM, tickLine, tickText, valueFormatter = (value) => value, ...props }) => {
|
|
13
|
-
const { xAxisCoordinates: { coordinates, tickValues: contextTickValues }, xCursor, ...context } = (0, react_1.useContext)(lineChartContext_1.LineChartContext);
|
|
14
|
-
const tickTextY = (0, getTickTextCoordinates_1.getTickTextYCoordinate)(position, coordinates.y1, Number(tickText?.fontSize), tickText?.top ?? 0);
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { XAxis } from '../../../components/axisChart/xAxis/xAxis';
|
|
4
|
+
import { TickDataUtils } from '../../../components/tick/tick.types';
|
|
5
|
+
import { Positions } from '../../../types/position.enum';
|
|
6
|
+
import { getTickTextYCoordinate } from '../../../utils/getTickTextCoordinate/getTickTextCoordinates';
|
|
7
|
+
import { pickCustomAttributes } from '../../../utils/pickCustomAttributes/pickCustomAttributes';
|
|
8
|
+
import { LineChartContext } from '../context/lineChartContext';
|
|
9
|
+
export const LineChartXAxis = ({ ariaLabel, position = Positions.BOTTOM, tickLine, tickText, valueFormatter = (value) => value, ...props }) => {
|
|
10
|
+
const { xAxisCoordinates: { coordinates, tickValues: contextTickValues }, xCursor, ...context } = useContext(LineChartContext);
|
|
11
|
+
const tickTextY = getTickTextYCoordinate(position, coordinates.y1, Number(tickText?.fontSize), tickText?.top ?? 0);
|
|
15
12
|
const y1 = context.extraSpaceTopY;
|
|
16
13
|
const y2 = Number(context.canvasHeight) - context.extraSpaceBottomY;
|
|
17
14
|
const tickValues = tickText
|
|
18
|
-
?
|
|
15
|
+
? TickDataUtils.formatTicksValues(contextTickValues, valueFormatter)
|
|
19
16
|
: undefined;
|
|
20
17
|
// Extract custom attributes (aria-*, data-*) and handle deprecated ariaLabel
|
|
21
|
-
const customAttributes =
|
|
18
|
+
const customAttributes = pickCustomAttributes(props);
|
|
22
19
|
const finalAriaLabel = ariaLabel || props['aria-label'];
|
|
23
20
|
// Merge all props including custom attributes and ariaLabel precedence
|
|
24
21
|
const mergedProps = {
|
|
@@ -26,7 +23,7 @@ const LineChartXAxis = ({ ariaLabel, position = position_enum_1.Positions.BOTTOM
|
|
|
26
23
|
...customAttributes,
|
|
27
24
|
...(finalAriaLabel && { 'aria-label': finalAriaLabel }),
|
|
28
25
|
};
|
|
29
|
-
return ((
|
|
26
|
+
return (_jsx(XAxis, { ...coordinates, ...mergedProps, canvasHeight: Number(context.canvasHeight), canvasWidth: Number(context.canvasWidth), cursor: xCursor, dataTestId: `${context.dataTestId}xAxis`, extraSpace: {
|
|
30
27
|
left: context.extraSpaceLeftX,
|
|
31
28
|
right: context.extraSpaceRightX,
|
|
32
29
|
}, tickLine: {
|
|
@@ -38,4 +35,3 @@ const LineChartXAxis = ({ ariaLabel, position = position_enum_1.Positions.BOTTOM
|
|
|
38
35
|
y: tickTextY,
|
|
39
36
|
}, tickValues: tickValues }));
|
|
40
37
|
};
|
|
41
|
-
exports.LineChartXAxis = LineChartXAxis;
|