@kubit-ui-web/react-charts 1.0.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 +2 -0
- 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/package.json +31 -33
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAxisData = void 0;
|
|
4
|
-
const getAxisData = (data, key) => {
|
|
1
|
+
export const getAxisData = (data, key) => {
|
|
5
2
|
return data.map(dt => dt[key]);
|
|
6
3
|
};
|
|
7
|
-
exports.getAxisData = getAxisData;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCanvasDimensions = void 0;
|
|
4
|
-
const unit_enum_1 = require("../../types/unit.enum");
|
|
1
|
+
import { Unit } from '../../types/unit.enum';
|
|
5
2
|
/**
|
|
6
3
|
* A mapping of string representations of units to their corresponding `Unit` enum values.
|
|
7
4
|
* This is used to convert string-based unit identifiers into their respective `Unit` enum types.
|
|
@@ -11,8 +8,8 @@ const unit_enum_1 = require("../../types/unit.enum");
|
|
|
11
8
|
* stringToUnit["rem"] // Returns Unit.REM
|
|
12
9
|
*/
|
|
13
10
|
const stringToUnit = {
|
|
14
|
-
[
|
|
15
|
-
[
|
|
11
|
+
[Unit.PERCENTAGE]: Unit.PERCENTAGE,
|
|
12
|
+
[Unit.REM]: Unit.REM,
|
|
16
13
|
};
|
|
17
14
|
/**
|
|
18
15
|
* An enumeration representing the dimensions of an SVG element.
|
|
@@ -83,19 +80,18 @@ const calculateRem = (value) => {
|
|
|
83
80
|
* @param {SVGSVGElement} props.svgElement - The SVG element to calculate dimensions for.
|
|
84
81
|
* @returns {GetCanvasDimensionsReturn} An object containing the calculated canva's width and height.
|
|
85
82
|
*/
|
|
86
|
-
const getCanvasDimensions = ({ canvasHeight, canvasWidth, svgElement, }) => {
|
|
83
|
+
export const getCanvasDimensions = ({ canvasHeight, canvasWidth, svgElement, }) => {
|
|
87
84
|
const { unit: widthUnit, value: widthValue } = parseDimensionValue(canvasWidth);
|
|
88
|
-
const parsedCanvasWidth = widthUnit ===
|
|
85
|
+
const parsedCanvasWidth = widthUnit === Unit.PERCENTAGE
|
|
89
86
|
? calculatePercentage(widthValue, Dimension.WIDTH, svgElement)
|
|
90
|
-
: widthUnit ===
|
|
87
|
+
: widthUnit === Unit.REM
|
|
91
88
|
? calculateRem(widthValue)
|
|
92
89
|
: widthValue;
|
|
93
90
|
const { unit: heightUnit, value: heightValue } = parseDimensionValue(canvasHeight);
|
|
94
|
-
const parsedCanvasHeight = heightUnit ===
|
|
91
|
+
const parsedCanvasHeight = heightUnit === Unit.PERCENTAGE
|
|
95
92
|
? calculatePercentage(heightValue, Dimension.HEIGHT, svgElement)
|
|
96
|
-
: heightUnit ===
|
|
93
|
+
: heightUnit === Unit.REM
|
|
97
94
|
? calculateRem(heightValue)
|
|
98
95
|
: heightValue;
|
|
99
96
|
return { parsedCanvasHeight, parsedCanvasWidth };
|
|
100
97
|
};
|
|
101
|
-
exports.getCanvasDimensions = getCanvasDimensions;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getChildrenAttr = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const getChildrenAttr = ({ attrName, children, originalValue, updateValue, }) => {
|
|
1
|
+
import { Children, isValidElement } from 'react';
|
|
2
|
+
export const getChildrenAttr = ({ attrName, children, originalValue, updateValue, }) => {
|
|
6
3
|
let combineString = '';
|
|
7
|
-
|
|
8
|
-
if (
|
|
4
|
+
Children.toArray(children).forEach((child) => {
|
|
5
|
+
if (isValidElement(child)) {
|
|
9
6
|
const attrValue = child.props[attrName];
|
|
10
7
|
if (attrValue) {
|
|
11
8
|
combineString += attrValue;
|
|
@@ -16,4 +13,3 @@ const getChildrenAttr = ({ attrName, children, originalValue, updateValue, }) =>
|
|
|
16
13
|
updateValue(combineString);
|
|
17
14
|
}
|
|
18
15
|
};
|
|
19
|
-
exports.getChildrenAttr = getChildrenAttr;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getYCoordinates = exports.getXCoordinates = void 0;
|
|
4
|
-
const position_enum_1 = require("../../types/position.enum");
|
|
1
|
+
import { Positions } from '../../types/position.enum';
|
|
5
2
|
/**
|
|
6
3
|
* Calculates the X coordinates for drawing lines in a chart.
|
|
7
4
|
* @param position - The position of the line.
|
|
@@ -14,8 +11,8 @@ const position_enum_1 = require("../../types/position.enum");
|
|
|
14
11
|
* @param customBreakAxis - The custom break axis value.
|
|
15
12
|
* @returns The X coordinates for drawing lines.
|
|
16
13
|
*/
|
|
17
|
-
const getXCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, position, }) => {
|
|
18
|
-
if (position ===
|
|
14
|
+
export const getXCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, position, }) => {
|
|
15
|
+
if (position === Positions.TOP) {
|
|
19
16
|
return {
|
|
20
17
|
x1: extraSpaceLeftX,
|
|
21
18
|
x2: canvasWidth - extraSpaceRightX,
|
|
@@ -23,7 +20,7 @@ const getXCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpac
|
|
|
23
20
|
y2: extraSpaceTopY,
|
|
24
21
|
};
|
|
25
22
|
}
|
|
26
|
-
if (position ===
|
|
23
|
+
if (position === Positions.CENTER) {
|
|
27
24
|
return {
|
|
28
25
|
x1: extraSpaceLeftX,
|
|
29
26
|
x2: canvasWidth - extraSpaceRightX,
|
|
@@ -31,7 +28,7 @@ const getXCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpac
|
|
|
31
28
|
y2: canvasHeight / 2,
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
|
-
if (position ===
|
|
31
|
+
if (position === Positions.CUSTOM) {
|
|
35
32
|
return {
|
|
36
33
|
x1: extraSpaceLeftX,
|
|
37
34
|
x2: canvasWidth - extraSpaceRightX,
|
|
@@ -46,7 +43,6 @@ const getXCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpac
|
|
|
46
43
|
y2: canvasHeight - extraSpaceBottomY,
|
|
47
44
|
};
|
|
48
45
|
};
|
|
49
|
-
exports.getXCoordinates = getXCoordinates;
|
|
50
46
|
/**
|
|
51
47
|
* Calculates the y-coordinates for drawing lines in a chart.
|
|
52
48
|
*
|
|
@@ -60,8 +56,8 @@ exports.getXCoordinates = getXCoordinates;
|
|
|
60
56
|
* @param customBreakAxis - The custom break axis position (used when position is CUSTOM).
|
|
61
57
|
* @returns The y-coordinates for drawing lines in the chart.
|
|
62
58
|
*/
|
|
63
|
-
const getYCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, position, }) => {
|
|
64
|
-
if (position ===
|
|
59
|
+
export const getYCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, position, }) => {
|
|
60
|
+
if (position === Positions.RIGHT) {
|
|
65
61
|
return {
|
|
66
62
|
x1: canvasWidth - extraSpaceRightX,
|
|
67
63
|
x2: canvasWidth - extraSpaceRightX,
|
|
@@ -69,7 +65,7 @@ const getYCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpac
|
|
|
69
65
|
y2: canvasHeight - extraSpaceBottomY,
|
|
70
66
|
};
|
|
71
67
|
}
|
|
72
|
-
if (position ===
|
|
68
|
+
if (position === Positions.CENTER) {
|
|
73
69
|
return {
|
|
74
70
|
x1: canvasWidth / 2,
|
|
75
71
|
x2: canvasWidth / 2,
|
|
@@ -77,7 +73,7 @@ const getYCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpac
|
|
|
77
73
|
y2: canvasHeight - extraSpaceBottomY,
|
|
78
74
|
};
|
|
79
75
|
}
|
|
80
|
-
if (position ===
|
|
76
|
+
if (position === Positions.CUSTOM) {
|
|
81
77
|
return {
|
|
82
78
|
x1: customBreakAxis,
|
|
83
79
|
x2: customBreakAxis,
|
|
@@ -92,4 +88,3 @@ const getYCoordinates = ({ canvasHeight, canvasWidth, customBreakAxis, extraSpac
|
|
|
92
88
|
y2: canvasHeight - extraSpaceBottomY,
|
|
93
89
|
};
|
|
94
90
|
};
|
|
95
|
-
exports.getYCoordinates = getYCoordinates;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDataFingerprint = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Generates a fingerprint of chart data for use in React.useMemo dependencies
|
|
6
3
|
* @param data - Chart data from LineChart, BarChart, or PieChart
|
|
7
4
|
* @returns JSON string representation of the data
|
|
8
5
|
*/
|
|
9
|
-
const getDataFingerprint = (data) => {
|
|
6
|
+
export const getDataFingerprint = (data) => {
|
|
10
7
|
// TODO: study and compare performance with other hash libraries or manual methods
|
|
11
8
|
// ! Data might grow a lot in size, that is because this may be reviewed in the future
|
|
12
9
|
return JSON.stringify(data);
|
|
13
10
|
};
|
|
14
|
-
exports.getDataFingerprint = getDataFingerprint;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPoints = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Calculates the positions of data points on the chart based on tick values and data values.
|
|
6
3
|
* @param tickValues - An array of tick data objects.
|
|
@@ -8,7 +5,7 @@ exports.getPoints = void 0;
|
|
|
8
5
|
* @param xAxis - Optional parameter indicating whether the points are for the x-axis. Defaults to false.
|
|
9
6
|
* @returns An array of numbers representing the positions of the data points.
|
|
10
7
|
*/
|
|
11
|
-
const getPoints = (tickValues, data, xAxis) => {
|
|
8
|
+
export const getPoints = (tickValues, data, xAxis) => {
|
|
12
9
|
return data.map(dt => {
|
|
13
10
|
// IF NOT A NUMBER, FIND THE POSITION OF THE TICK
|
|
14
11
|
if (isNaN(Number(dt))) {
|
|
@@ -50,4 +47,3 @@ const getPoints = (tickValues, data, xAxis) => {
|
|
|
50
47
|
return tick.position;
|
|
51
48
|
});
|
|
52
49
|
};
|
|
53
|
-
exports.getPoints = getPoints;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTickTextYCoordinate = exports.getTickTextXCoordinate = void 0;
|
|
4
|
-
const position_enum_1 = require("../../types/position.enum");
|
|
1
|
+
import { Positions } from '../../types/position.enum';
|
|
5
2
|
/**
|
|
6
3
|
* Calculates the x-coordinate for the tick text based on the position, x-coordinate, and font size.
|
|
7
4
|
*
|
|
@@ -10,13 +7,12 @@ const position_enum_1 = require("../../types/position.enum");
|
|
|
10
7
|
* @param fontSize - The font size of the tick text.
|
|
11
8
|
* @returns The calculated x-coordinate for the tick text.
|
|
12
9
|
*/
|
|
13
|
-
const getTickTextXCoordinate = (position, x, fontSize) => {
|
|
14
|
-
if (position ===
|
|
10
|
+
export const getTickTextXCoordinate = (position, x, fontSize) => {
|
|
11
|
+
if (position === Positions.RIGHT) {
|
|
15
12
|
return x + fontSize;
|
|
16
13
|
}
|
|
17
14
|
return x - fontSize;
|
|
18
15
|
};
|
|
19
|
-
exports.getTickTextXCoordinate = getTickTextXCoordinate;
|
|
20
16
|
/**
|
|
21
17
|
* Calculates the y-coordinate for the tick text based on the position, y-coordinate, font size, and security space.
|
|
22
18
|
*
|
|
@@ -26,10 +22,9 @@ exports.getTickTextXCoordinate = getTickTextXCoordinate;
|
|
|
26
22
|
* @param securitySpace - The security space between the tick text and the chart.
|
|
27
23
|
* @returns The calculated y-coordinate for the tick text.
|
|
28
24
|
*/
|
|
29
|
-
const getTickTextYCoordinate = (position, y, fontSize, securitySpace) => {
|
|
30
|
-
if (position ===
|
|
25
|
+
export const getTickTextYCoordinate = (position, y, fontSize, securitySpace) => {
|
|
26
|
+
if (position === Positions.TOP) {
|
|
31
27
|
return fontSize;
|
|
32
28
|
}
|
|
33
29
|
return y + fontSize + securitySpace;
|
|
34
30
|
};
|
|
35
|
-
exports.getTickTextYCoordinate = getTickTextYCoordinate;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getYTicks = exports.getXTicks = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Calculates the tick positions and values for the x-axis of a line chart.
|
|
6
3
|
*
|
|
@@ -12,7 +9,7 @@ exports.getYTicks = exports.getXTicks = void 0;
|
|
|
12
9
|
* @param initPos - The initial position of the x-axis.
|
|
13
10
|
* @returns An array of objects containing the tick values and their corresponding positions.
|
|
14
11
|
*/
|
|
15
|
-
const getXTicks = ({ initPos, maxSpaceAvailable, otherAxisSpace, securitySpace, tickValues, }) => {
|
|
12
|
+
export const getXTicks = ({ initPos, maxSpaceAvailable, otherAxisSpace, securitySpace, tickValues, }) => {
|
|
16
13
|
const ticksNumber = tickValues.length - 1;
|
|
17
14
|
const maxSpace = maxSpaceAvailable - otherAxisSpace - securitySpace;
|
|
18
15
|
const stepValue = maxSpace / ticksNumber;
|
|
@@ -25,7 +22,6 @@ const getXTicks = ({ initPos, maxSpaceAvailable, otherAxisSpace, securitySpace,
|
|
|
25
22
|
});
|
|
26
23
|
return ticks;
|
|
27
24
|
};
|
|
28
|
-
exports.getXTicks = getXTicks;
|
|
29
25
|
/**
|
|
30
26
|
* Calculates the tick positions and values for the y-axis of a line chart.
|
|
31
27
|
*
|
|
@@ -37,7 +33,7 @@ exports.getXTicks = getXTicks;
|
|
|
37
33
|
* @param initPos - The initial position of the y-axis.
|
|
38
34
|
* @returns An array of objects containing the tick values and their corresponding positions.
|
|
39
35
|
*/
|
|
40
|
-
const getYTicks = ({ initPos, maxSpaceAvailable, needAjusted, otherAxisSpace, securitySpace, tickValues, }) => {
|
|
36
|
+
export const getYTicks = ({ initPos, maxSpaceAvailable, needAjusted, otherAxisSpace, securitySpace, tickValues, }) => {
|
|
41
37
|
const ticksNumber = tickValues.length - 1;
|
|
42
38
|
const maxSpace = maxSpaceAvailable - otherAxisSpace - securitySpace;
|
|
43
39
|
const stepValue = maxSpace / ticksNumber;
|
|
@@ -51,4 +47,3 @@ const getYTicks = ({ initPos, maxSpaceAvailable, needAjusted, otherAxisSpace, se
|
|
|
51
47
|
});
|
|
52
48
|
return ticks;
|
|
53
49
|
};
|
|
54
|
-
exports.getYTicks = getYTicks;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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("./ajustedTextSpace/ajustedTextSpace"), exports);
|
|
18
|
-
__exportStar(require("./buildTickValues/buildTickValues"), exports);
|
|
19
|
-
__exportStar(require("./classNames/classNames"), exports);
|
|
20
|
-
__exportStar(require("./cssGradientToSvg/cssGradientToSvg"), exports);
|
|
21
|
-
__exportStar(require("./cursorNear/isNear"), exports);
|
|
22
|
-
__exportStar(require("./shadowSvg/shadowSvg"), exports);
|
|
23
|
-
__exportStar(require("./shadowSvg/shadowSvg.types"), exports);
|
|
24
|
-
__exportStar(require("./textBound/textBound"), exports);
|
|
1
|
+
export * from './ajustedTextSpace/ajustedTextSpace';
|
|
2
|
+
export * from './buildTickValues/buildTickValues';
|
|
3
|
+
export * from './classNames/classNames';
|
|
4
|
+
export * from './cssGradientToSvg/cssGradientToSvg';
|
|
5
|
+
export * from './cursorNear/isNear';
|
|
6
|
+
export * from './shadowSvg/shadowSvg';
|
|
7
|
+
export * from './shadowSvg/shadowSvg.types';
|
|
8
|
+
export * from './textBound/textBound';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseStringToNumberPx = void 0;
|
|
4
|
-
const unit_enum_1 = require("../../types/unit.enum");
|
|
1
|
+
import { Unit } from '../../types/unit.enum';
|
|
5
2
|
const UNIT_VALUE_REGEX = /^(\d+(\.\d+)?)(px|rem|%)?$/;
|
|
6
3
|
const MATCH_VALUE_INDEX = 1;
|
|
7
4
|
const MATCH_UNIT_INDEX = 3;
|
|
@@ -14,7 +11,7 @@ const MATCH_UNIT_INDEX = 3;
|
|
|
14
11
|
* @returns The parsed pixel value as a number.
|
|
15
12
|
* @throws Will throw an error if the string format is invalid.
|
|
16
13
|
*/
|
|
17
|
-
const parseStringToNumberPx = (value) => {
|
|
14
|
+
export const parseStringToNumberPx = (value) => {
|
|
18
15
|
if (typeof value === 'number') {
|
|
19
16
|
return value;
|
|
20
17
|
}
|
|
@@ -25,9 +22,8 @@ const parseStringToNumberPx = (value) => {
|
|
|
25
22
|
}
|
|
26
23
|
const number = match[MATCH_VALUE_INDEX]; // match for group (\d+(\.\d+)?)
|
|
27
24
|
const unit = match[MATCH_UNIT_INDEX]; // match for group (px|rem|%)
|
|
28
|
-
if (unit ===
|
|
25
|
+
if (unit === Unit.REM) {
|
|
29
26
|
return parseFloat(number) * 16;
|
|
30
27
|
}
|
|
31
28
|
return parseFloat(number);
|
|
32
29
|
};
|
|
33
|
-
exports.parseStringToNumberPx = parseStringToNumberPx;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pickCustomAttributes = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Filters and extracts only aria-* and data-* attributes from a given object,
|
|
6
3
|
* converting all values to strings for HTML compatibility.
|
|
@@ -32,7 +29,7 @@ exports.pickCustomAttributes = void 0;
|
|
|
32
29
|
* // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true' }
|
|
33
30
|
* ```
|
|
34
31
|
*/
|
|
35
|
-
const pickCustomAttributes = (
|
|
32
|
+
export const pickCustomAttributes = (
|
|
36
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
34
|
attributes) => {
|
|
38
35
|
if (!attributes) {
|
|
@@ -47,4 +44,3 @@ attributes) => {
|
|
|
47
44
|
return acc;
|
|
48
45
|
}, {});
|
|
49
46
|
};
|
|
50
|
-
exports.pickCustomAttributes = pickCustomAttributes;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const ShadowSvg = ({ height = '140%', width = '140%', x = '-20%', y = '-20%', ...props }) => {
|
|
6
|
-
return ((0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("filter", { height: height, id: props.id, width: width, x: x, y: y, children: (0, jsx_runtime_1.jsx)("feDropShadow", { ...props.shadowSvgConfig }) }) }));
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const ShadowSvg = ({ height = '140%', width = '140%', x = '-20%', y = '-20%', ...props }) => {
|
|
3
|
+
return (_jsx("defs", { children: _jsx("filter", { height: height, id: props.id, width: width, x: x, y: y, children: _jsx("feDropShadow", { ...props.shadowSvgConfig }) }) }));
|
|
7
4
|
};
|
|
8
|
-
exports.ShadowSvg = ShadowSvg;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.textBound = void 0;
|
|
4
|
-
const textBound = ({ bound, data, fontSize, svgHeight, svgWidth, viewBox, }) => {
|
|
1
|
+
export const textBound = ({ bound, data, fontSize, svgHeight, svgWidth, viewBox, }) => {
|
|
5
2
|
if (!window || !document || !data.length) {
|
|
6
3
|
return 0;
|
|
7
4
|
}
|
|
@@ -23,4 +20,3 @@ const textBound = ({ bound, data, fontSize, svgHeight, svgWidth, viewBox, }) =>
|
|
|
23
20
|
svgContainer.remove();
|
|
24
21
|
return Math.max(...sizes);
|
|
25
22
|
};
|
|
26
|
-
exports.textBound = textBound;
|