@kubit-ui-web/react-charts 1.3.0 → 1.5.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/barChart/fragments/barChartPath.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/barChartPath.js +12 -7
- package/dist/cjs/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/barChartSeparator.js +20 -8
- package/dist/cjs/charts/constants/chartDefaults.d.ts +20 -0
- package/dist/cjs/charts/constants/chartDefaults.d.ts.map +1 -1
- package/dist/cjs/charts/constants/chartDefaults.js +20 -0
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +15 -8
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.js +10 -7
- package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.js +20 -8
- package/dist/cjs/charts/pieChart/context/buildPieContextValue.d.ts +3 -1
- package/dist/cjs/charts/pieChart/context/buildPieContextValue.d.ts.map +1 -1
- package/dist/cjs/charts/pieChart/context/buildPieContextValue.js +15 -3
- package/dist/cjs/charts/pieChart/fragments/pieChartPath.d.ts.map +1 -1
- package/dist/cjs/charts/pieChart/fragments/pieChartPath.js +31 -3
- package/dist/cjs/charts/pieChart/fragments/pieChartSegment.d.ts.map +1 -1
- package/dist/cjs/charts/pieChart/fragments/pieChartSegment.js +58 -1
- package/dist/cjs/charts/pieChart/pieChart.type.d.ts +7 -0
- package/dist/cjs/charts/pieChart/pieChart.type.d.ts.map +1 -1
- package/dist/cjs/charts/pieChart/pieChartStructure.d.ts.map +1 -1
- package/dist/cjs/charts/pieChart/pieChartStructure.js +12 -2
- package/dist/cjs/types/errors.type.d.ts +3 -0
- package/dist/cjs/types/errors.type.d.ts.map +1 -1
- package/dist/cjs/types/errors.type.js +4 -0
- package/dist/cjs/utils/buildErrors/buildErrors.d.ts +11 -0
- package/dist/cjs/utils/buildErrors/buildErrors.d.ts.map +1 -1
- package/dist/cjs/utils/buildErrors/buildErrors.js +5 -0
- package/dist/cjs/utils/buildErrors/charts/buildPieChartErrors.d.ts +37 -0
- package/dist/cjs/utils/buildErrors/charts/buildPieChartErrors.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/charts/buildPieChartErrors.js +36 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.d.ts +13 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.js +20 -0
- package/dist/cjs/utils/buildErrors/constants/errors/pieChartErrors.d.ts +14 -0
- package/dist/cjs/utils/buildErrors/constants/errors/pieChartErrors.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/constants/errors/pieChartErrors.js +25 -0
- package/dist/esm/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/barChartPath.js +12 -7
- package/dist/esm/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/barChartSeparator.js +20 -8
- package/dist/esm/charts/constants/chartDefaults.d.ts +20 -0
- package/dist/esm/charts/constants/chartDefaults.d.ts.map +1 -1
- package/dist/esm/charts/constants/chartDefaults.js +20 -0
- package/dist/esm/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartPath.js +15 -8
- package/dist/esm/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartProjection.js +10 -7
- package/dist/esm/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartSeparator.js +20 -8
- package/dist/esm/charts/pieChart/context/buildPieContextValue.d.ts +3 -1
- package/dist/esm/charts/pieChart/context/buildPieContextValue.d.ts.map +1 -1
- package/dist/esm/charts/pieChart/context/buildPieContextValue.js +15 -3
- package/dist/esm/charts/pieChart/fragments/pieChartPath.d.ts.map +1 -1
- package/dist/esm/charts/pieChart/fragments/pieChartPath.js +31 -3
- package/dist/esm/charts/pieChart/fragments/pieChartSegment.d.ts.map +1 -1
- package/dist/esm/charts/pieChart/fragments/pieChartSegment.js +58 -1
- package/dist/esm/charts/pieChart/pieChart.type.d.ts +7 -0
- package/dist/esm/charts/pieChart/pieChart.type.d.ts.map +1 -1
- package/dist/esm/charts/pieChart/pieChartStructure.d.ts.map +1 -1
- package/dist/esm/charts/pieChart/pieChartStructure.js +12 -2
- package/dist/esm/types/errors.type.d.ts +3 -0
- package/dist/esm/types/errors.type.d.ts.map +1 -1
- package/dist/esm/types/errors.type.js +4 -0
- package/dist/esm/utils/buildErrors/buildErrors.d.ts +11 -0
- package/dist/esm/utils/buildErrors/buildErrors.d.ts.map +1 -1
- package/dist/esm/utils/buildErrors/buildErrors.js +5 -0
- package/dist/esm/utils/buildErrors/charts/buildPieChartErrors.d.ts +37 -0
- package/dist/esm/utils/buildErrors/charts/buildPieChartErrors.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/charts/buildPieChartErrors.js +36 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.d.ts +13 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.js +20 -0
- package/dist/esm/utils/buildErrors/constants/errors/pieChartErrors.d.ts +14 -0
- package/dist/esm/utils/buildErrors/constants/errors/pieChartErrors.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/constants/errors/pieChartErrors.js +25 -0
- 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/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/barChartPath.d.ts.map +1 -1
- package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts.map +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/constants/chartDefaults.d.ts +20 -0
- package/dist/types/charts/constants/chartDefaults.d.ts.map +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/lineChartPath.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts.map +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/buildPieContextValue.d.ts +3 -1
- package/dist/types/charts/pieChart/context/buildPieContextValue.d.ts.map +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/fragments/pieChartPath.d.ts.map +1 -1
- package/dist/types/charts/pieChart/fragments/pieChartSegment.d.ts.map +1 -1
- package/dist/types/charts/pieChart/pieChart.d.ts +3 -3
- package/dist/types/charts/pieChart/pieChart.type.d.ts +8 -1
- package/dist/types/charts/pieChart/pieChart.type.d.ts.map +1 -1
- package/dist/types/charts/pieChart/pieChartStructure.d.ts +1 -1
- package/dist/types/charts/pieChart/pieChartStructure.d.ts.map +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/types/errors.type.d.ts +3 -0
- package/dist/types/types/errors.type.d.ts.map +1 -1
- package/dist/types/utils/buildErrors/buildErrors.d.ts +11 -0
- package/dist/types/utils/buildErrors/buildErrors.d.ts.map +1 -1
- package/dist/types/utils/buildErrors/charts/buildPieChartErrors.d.ts +37 -0
- package/dist/types/utils/buildErrors/charts/buildPieChartErrors.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.d.ts +13 -0
- package/dist/types/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/constants/errors/pieChartErrors.d.ts +14 -0
- package/dist/types/utils/buildErrors/constants/errors/pieChartErrors.d.ts.map +1 -0
- package/dist/types/utils/getChildrenAttr/getChildrenAttr.d.ts +1 -1
- package/package.json +6 -4
|
@@ -3,6 +3,8 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { SvgContainer } from '../../components/svgContainer/svgContainer';
|
|
4
4
|
import { buildViewBox } from '../../components/svgContainer/utils/buildViewBox/buildViewBox';
|
|
5
5
|
import { DefaultCanvasConfig } from '../../types/canvas.type';
|
|
6
|
+
import { createErrorAccumulator } from '../../utils/createErrorAccumulator';
|
|
7
|
+
import { getDataFingerprint } from '../../utils/getDataFingerprint/getDataFingerprint';
|
|
6
8
|
import { parseStringToNumberPx } from '../../utils/parseStringToNumberPx.ts/parseStringToNumberPx';
|
|
7
9
|
import { buildPieContextValue } from './context/buildPieContextValue';
|
|
8
10
|
import { PieChartContext } from './context/pieChartContext';
|
|
@@ -36,7 +38,7 @@ import { PieChartContext } from './context/pieChartContext';
|
|
|
36
38
|
* @param {ChartData[]} props.data - The data for the pie chart.
|
|
37
39
|
* @returns {ReactElement} The rendered pie chart component.
|
|
38
40
|
*/
|
|
39
|
-
export const PieChartStructure = ({ ariaHidden, ariaLabel, canvasConfig = DefaultCanvasConfig, caption, children, classNames, data, dataTestId = 'pie-chart', halfChart, height = '100%', radius = '50%', role, tabIndex, width = '100%', ...props }) => {
|
|
41
|
+
export const PieChartStructure = ({ ariaHidden, ariaLabel, canvasConfig = DefaultCanvasConfig, caption, children, classNames, data, dataTestId = 'pie-chart', halfChart, height = '100%', onErrors, radius = '50%', role, tabIndex, width = '100%', ...props }) => {
|
|
40
42
|
// Destructure the canvas configuration to obtain width, height, and extra space.
|
|
41
43
|
const { extraSpace: canvasExtraSpace, height: canvasHeight, width: canvasWidth } = canvasConfig;
|
|
42
44
|
const parsedCanvasWidth = parseStringToNumberPx(canvasWidth);
|
|
@@ -46,14 +48,22 @@ export const PieChartStructure = ({ ariaHidden, ariaLabel, canvasConfig = Defaul
|
|
|
46
48
|
: undefined;
|
|
47
49
|
// Build the viewBox string based on canvas dimensions and extra space.
|
|
48
50
|
const viewBox = buildViewBox(parsedCanvasWidth, parsedCanvasHeight, parsedCanvasExtraSpace);
|
|
51
|
+
const errorAccumulator = useMemo(() => createErrorAccumulator(onErrors), [onErrors]);
|
|
52
|
+
// Create a fingerprint of the data to avoid unnecessary contextValue updates
|
|
53
|
+
const dataFingerprint = getDataFingerprint(data);
|
|
49
54
|
const contextValue = useMemo(() => {
|
|
55
|
+
// Clear previous errors before building new context
|
|
56
|
+
errorAccumulator.clearErrors();
|
|
50
57
|
return buildPieContextValue({
|
|
58
|
+
addError: (errorType, error) => {
|
|
59
|
+
errorAccumulator.addError(errorType, error);
|
|
60
|
+
},
|
|
51
61
|
canvasHeight: parsedCanvasHeight,
|
|
52
62
|
canvasWidth: parsedCanvasWidth,
|
|
53
63
|
children,
|
|
54
64
|
halfChart,
|
|
55
65
|
});
|
|
56
|
-
}, [canvasHeight, canvasWidth, halfChart]);
|
|
66
|
+
}, [canvasHeight, canvasWidth, halfChart, dataFingerprint, errorAccumulator]);
|
|
57
67
|
return (_jsx(SvgContainer, { ariaHidden: ariaHidden, ariaLabel: ariaLabel, caption: caption, className: classNames, dataTestId: dataTestId, height: height, radius: radius, role: role, tabIndex: tabIndex, viewBox: viewBox, width: width, ...props, children: _jsx(PieChartContext.Provider, { value: {
|
|
58
68
|
...contextValue,
|
|
59
69
|
canvasHeight: parsedCanvasHeight,
|
|
@@ -11,6 +11,9 @@ export declare const ErrorType: {
|
|
|
11
11
|
readonly LINE_CHART_SEPARATOR_ERROR: "LINE_CHART_SEPARATOR_ERROR";
|
|
12
12
|
readonly LINE_CHART_X_AXIS_ERROR: "LINE_CHART_X_AXIS_ERROR";
|
|
13
13
|
readonly LINE_CHART_Y_AXIS_ERROR: "LINE_CHART_Y_AXIS_ERROR";
|
|
14
|
+
readonly PIE_CHART_CONTEXT_ERROR: "PIE_CHART_CONTEXT_ERROR";
|
|
15
|
+
readonly PIE_CHART_PATH_ERROR: "PIE_CHART_PATH_ERROR";
|
|
16
|
+
readonly PIE_CHART_SEGMENT_ERROR: "PIE_CHART_SEGMENT_ERROR";
|
|
14
17
|
};
|
|
15
18
|
export interface ChartError {
|
|
16
19
|
error?: Error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.type.d.ts","sourceRoot":"","sources":["../../../src/types/errors.type.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"errors.type.d.ts","sourceRoot":"","sources":["../../../src/types/errors.type.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;CAoBZ,CAAC;AAEX,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,OAAO,SAAS,CAAC;CAC9B;AACD,MAAM,MAAM,oBAAoB,GAAG;KAChC,IAAI,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE;CACjF,CAAC;AAGF,eAAO,MAAM,gBAAgB,GAAI,OAAO,UAAU,GAAG,UAAU,EAAE,KAAG,UAAU,EAE7E,CAAC"}
|
|
@@ -14,6 +14,10 @@ export const ErrorType = {
|
|
|
14
14
|
LINE_CHART_SEPARATOR_ERROR: 'LINE_CHART_SEPARATOR_ERROR',
|
|
15
15
|
LINE_CHART_X_AXIS_ERROR: 'LINE_CHART_X_AXIS_ERROR',
|
|
16
16
|
LINE_CHART_Y_AXIS_ERROR: 'LINE_CHART_Y_AXIS_ERROR',
|
|
17
|
+
// Pie Chart Error categories
|
|
18
|
+
PIE_CHART_CONTEXT_ERROR: 'PIE_CHART_CONTEXT_ERROR',
|
|
19
|
+
PIE_CHART_PATH_ERROR: 'PIE_CHART_PATH_ERROR',
|
|
20
|
+
PIE_CHART_SEGMENT_ERROR: 'PIE_CHART_SEGMENT_ERROR',
|
|
17
21
|
};
|
|
18
22
|
// Utility for array conversion
|
|
19
23
|
export const normalizeToArray = (error) => {
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
export declare const BuildError: {
|
|
2
|
+
readonly PIE_CHART_EMPTY_DATA: "PIE_CHART_EMPTY_DATA";
|
|
3
|
+
readonly PIE_CHART_INNER_RADIUS_OUT_OF_RANGE: "PIE_CHART_INNER_RADIUS_OUT_OF_RANGE";
|
|
4
|
+
readonly PIE_CHART_INVALID_CANVAS_DIMENSIONS: "PIE_CHART_INVALID_CANVAS_DIMENSIONS";
|
|
5
|
+
readonly PIE_CHART_INVALID_DATA_KEY: "PIE_CHART_INVALID_DATA_KEY";
|
|
6
|
+
readonly PIE_CHART_INVALID_INNER_RADIUS: "PIE_CHART_INVALID_INNER_RADIUS";
|
|
7
|
+
readonly PIE_CHART_INVALID_RADIUS: "PIE_CHART_INVALID_RADIUS";
|
|
8
|
+
readonly PIE_CHART_INVALID_SEGMENT_VALUE: "PIE_CHART_INVALID_SEGMENT_VALUE";
|
|
9
|
+
readonly PIE_CHART_INVALID_TOTAL: "PIE_CHART_INVALID_TOTAL";
|
|
10
|
+
readonly PIE_CHART_MISSING_SEGMENT_NAME: "PIE_CHART_MISSING_SEGMENT_NAME";
|
|
11
|
+
readonly PIE_CHART_NEGATIVE_SEGMENT_VALUE: "PIE_CHART_NEGATIVE_SEGMENT_VALUE";
|
|
2
12
|
readonly LINE_CHART_INVALID_CANVAS: "LINE_CHART_INVALID_CANVAS";
|
|
3
13
|
readonly LINE_CHART_NO_DATA: "LINE_CHART_NO_DATA";
|
|
4
14
|
readonly LINE_CHART_PATH_ALL_VALUES_NULL: "LINE_CHART_PATH_ALL_VALUES_NULL";
|
|
@@ -66,4 +76,5 @@ export declare const buildSeparatorXOutOfRangeError: (value: number, min: number
|
|
|
66
76
|
*/
|
|
67
77
|
export declare const buildSeparatorYOutOfRangeError: (value: number, min: number, max: number) => Error;
|
|
68
78
|
export { buildBarValueError, buildBarNegativeValueError, buildBarDataKeyNotFoundError, buildBarDistributionError, } from './charts/buildBarChartErrors';
|
|
79
|
+
export { buildSegmentValueError, buildSegmentNegativeValueError, buildPieDataKeyNotFoundError, buildEmptyDataArrayError, buildInvalidTotalError, buildInvalidGroupError, buildInvalidRadiusError, buildInvalidInnerRadiusError, buildInnerRadiusOutOfRangeError, } from './charts/buildPieChartErrors';
|
|
69
80
|
//# sourceMappingURL=buildErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildErrors.d.ts","sourceRoot":"","sources":["../../../../src/utils/buildErrors/buildErrors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildErrors.d.ts","sourceRoot":"","sources":["../../../../src/utils/buildErrors/buildErrors.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKb,CAAC;AAIX,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,EAAE,KAAK,CAKpF,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,CAAC,OAAO,UAAU,EAAE,MAAM,OAAO,UAAU,CAAC,KAAG,KAC5D,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,KAAG,KACJ,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,KAGxE,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,6BAA6B,GAAI,OAAO,MAAM,GAAG,MAAM,KAAG,KACO,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,6BAA6B,GAAI,OAAO,MAAM,GAAG,MAAM,KAAG,KACO,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,8BAA8B,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,KACT,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,8BAA8B,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,KACT,CAAC;AAGjF,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { BarChartErrors, BarChartErrorsRecord } from './constants/errors/barChartErrors';
|
|
2
2
|
import { LineChartErrors, LineChartErrorsRecord } from './constants/errors/lineChartErrors';
|
|
3
|
+
import { PieChartErrors, PieChartErrorsRecord } from './constants/errors/pieChartErrors';
|
|
3
4
|
export const BuildError = {
|
|
4
5
|
INVALID_X_TICK: 'INVALID_X_TICK',
|
|
5
6
|
...BarChartErrors,
|
|
6
7
|
...LineChartErrors,
|
|
8
|
+
...PieChartErrors,
|
|
7
9
|
};
|
|
8
10
|
const INVALID_X_TICK_ERROR = '[getXTicks] Invalid X tick values calculated';
|
|
9
11
|
export const ErrorsRecord = {
|
|
10
12
|
...BarChartErrorsRecord,
|
|
11
13
|
...LineChartErrorsRecord,
|
|
14
|
+
...PieChartErrorsRecord,
|
|
12
15
|
INVALID_X_TICK: new Error(INVALID_X_TICK_ERROR),
|
|
13
16
|
};
|
|
14
17
|
export const buildError = (error) => ErrorsRecord[error];
|
|
@@ -38,3 +41,5 @@ export const buildSeparatorXOutOfRangeError = (value, min, max) => new Error(`xB
|
|
|
38
41
|
export const buildSeparatorYOutOfRangeError = (value, min, max) => new Error(`yBreakAxis value ${value} is outside data range (${min} - ${max})`);
|
|
39
42
|
// Re-export bar chart error builders
|
|
40
43
|
export { buildBarValueError, buildBarNegativeValueError, buildBarDataKeyNotFoundError, buildBarDistributionError, } from './charts/buildBarChartErrors';
|
|
44
|
+
// Re-export pie chart error builders
|
|
45
|
+
export { buildSegmentValueError, buildSegmentNegativeValueError, buildPieDataKeyNotFoundError, buildEmptyDataArrayError, buildInvalidTotalError, buildInvalidGroupError, buildInvalidRadiusError, buildInvalidInnerRadiusError, buildInnerRadiusOutOfRangeError, } from './charts/buildPieChartErrors';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a dynamic error for when a segment value is not numeric
|
|
3
|
+
*/
|
|
4
|
+
export declare const buildSegmentValueError: (value: unknown, groupName: string) => Error;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a dynamic error for when a segment value is negative
|
|
7
|
+
*/
|
|
8
|
+
export declare const buildSegmentNegativeValueError: (value: number, groupName: string) => Error;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a dynamic error for when a dataKey is not found in the dataset
|
|
11
|
+
*/
|
|
12
|
+
export declare const buildPieDataKeyNotFoundError: (dataKey: string) => Error;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a dynamic error for when the data array is empty
|
|
15
|
+
*/
|
|
16
|
+
export declare const buildEmptyDataArrayError: (dataKey: string) => Error;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a dynamic error for when total value is zero or invalid
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildInvalidTotalError: (dataKey: string, total: number) => Error;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a dynamic error for when a group is missing required properties
|
|
23
|
+
*/
|
|
24
|
+
export declare const buildInvalidGroupError: (dataKey: string, index: number, missingProp: string) => Error;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a dynamic error for invalid radius value
|
|
27
|
+
*/
|
|
28
|
+
export declare const buildInvalidRadiusError: (radius: unknown) => Error;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a dynamic error for invalid innerRadius value
|
|
31
|
+
*/
|
|
32
|
+
export declare const buildInvalidInnerRadiusError: (innerRadius: unknown) => Error;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a dynamic error for when innerRadius is greater than or equal to radius
|
|
35
|
+
*/
|
|
36
|
+
export declare const buildInnerRadiusOutOfRangeError: (innerRadius: number, radius: number) => Error;
|
|
37
|
+
//# sourceMappingURL=buildPieChartErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildPieChartErrors.d.ts","sourceRoot":"","sources":["../../../../../src/utils/buildErrors/charts/buildPieChartErrors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,EAAE,WAAW,MAAM,KAAG,KACc,CAAC;AAE1F;;GAEG;AACH,eAAO,MAAM,8BAA8B,GAAI,OAAO,MAAM,EAAE,WAAW,MAAM,KAAG,KACM,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,MAAM,KAAG,KACE,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,KAAG,KACJ,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,MAAM,EAAE,OAAO,MAAM,KAAG,KACG,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,OAAO,MAAM,EACb,aAAa,MAAM,KAClB,KAGA,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,OAAO,KAAG,KACkB,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,aAAa,OAAO,KAAG,KAC0B,CAAC;AAE/F;;GAEG;AACH,eAAO,MAAM,+BAA+B,GAAI,aAAa,MAAM,EAAE,QAAQ,MAAM,KAAG,KAGnF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a dynamic error for when a segment value is not numeric
|
|
3
|
+
*/
|
|
4
|
+
export const buildSegmentValueError = (value, groupName) => new Error(`Invalid segment value for "${groupName}": "${value}" is not a valid number`);
|
|
5
|
+
/**
|
|
6
|
+
* Creates a dynamic error for when a segment value is negative
|
|
7
|
+
*/
|
|
8
|
+
export const buildSegmentNegativeValueError = (value, groupName) => new Error(`Negative segment value for "${groupName}": ${value} (values must be >= 0)`);
|
|
9
|
+
/**
|
|
10
|
+
* Creates a dynamic error for when a dataKey is not found in the dataset
|
|
11
|
+
*/
|
|
12
|
+
export const buildPieDataKeyNotFoundError = (dataKey) => new Error(`DataKey "${dataKey}" not found in PieChart dataset`);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a dynamic error for when the data array is empty
|
|
15
|
+
*/
|
|
16
|
+
export const buildEmptyDataArrayError = (dataKey) => new Error(`Data array for key "${dataKey}" is empty`);
|
|
17
|
+
/**
|
|
18
|
+
* Creates a dynamic error for when total value is zero or invalid
|
|
19
|
+
*/
|
|
20
|
+
export const buildInvalidTotalError = (dataKey, total) => new Error(`Invalid total value for "${dataKey}": ${total} (must be > 0)`);
|
|
21
|
+
/**
|
|
22
|
+
* Creates a dynamic error for when a group is missing required properties
|
|
23
|
+
*/
|
|
24
|
+
export const buildInvalidGroupError = (dataKey, index, missingProp) => new Error(`Invalid group at index ${index} in "${dataKey}": missing required property "${missingProp}"`);
|
|
25
|
+
/**
|
|
26
|
+
* Creates a dynamic error for invalid radius value
|
|
27
|
+
*/
|
|
28
|
+
export const buildInvalidRadiusError = (radius) => new Error(`Invalid radius value: "${radius}" (must be a positive number)`);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a dynamic error for invalid innerRadius value
|
|
31
|
+
*/
|
|
32
|
+
export const buildInvalidInnerRadiusError = (innerRadius) => new Error(`Invalid innerRadius value: "${innerRadius}" (must be a positive number or zero)`);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a dynamic error for when innerRadius is greater than or equal to radius
|
|
35
|
+
*/
|
|
36
|
+
export const buildInnerRadiusOutOfRangeError = (innerRadius, radius) => new Error(`innerRadius (${innerRadius}) must be less than radius (${radius}) for donut chart rendering`);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const PieChartErrorMessages: {
|
|
2
|
+
readonly PIE_CHART_EMPTY_DATA: "PieChart data is empty or undefined";
|
|
3
|
+
readonly PIE_CHART_INNER_RADIUS_OUT_OF_RANGE: "Inner radius must be less than radius";
|
|
4
|
+
readonly PIE_CHART_INVALID_CANVAS_DIMENSIONS: "Invalid canvas dimensions for PieChart";
|
|
5
|
+
readonly PIE_CHART_INVALID_DATA_KEY: "Invalid or missing dataKey in PieChart data";
|
|
6
|
+
readonly PIE_CHART_INVALID_INNER_RADIUS: "Invalid innerRadius value";
|
|
7
|
+
readonly PIE_CHART_INVALID_RADIUS: "Invalid radius value";
|
|
8
|
+
readonly PIE_CHART_INVALID_SEGMENT_VALUE: "Invalid segment value (non-numeric)";
|
|
9
|
+
readonly PIE_CHART_INVALID_TOTAL: "PieChart total value is zero or invalid";
|
|
10
|
+
readonly PIE_CHART_MISSING_SEGMENT_NAME: "Segment is missing required name property";
|
|
11
|
+
readonly PIE_CHART_NEGATIVE_SEGMENT_VALUE: "Segment value cannot be negative";
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=pieChartErrorMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieChartErrorMessages.d.ts","sourceRoot":"","sources":["../../../../../../src/utils/buildErrors/constants/errorMessages/pieChartErrorMessages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;;;;;;CAmBxB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const PieChartErrorMessages = {
|
|
2
|
+
// Data Validation Errors
|
|
3
|
+
PIE_CHART_EMPTY_DATA: 'PieChart data is empty or undefined',
|
|
4
|
+
// Radius Errors
|
|
5
|
+
PIE_CHART_INNER_RADIUS_OUT_OF_RANGE: 'Inner radius must be less than radius',
|
|
6
|
+
// Canvas & Context Errors
|
|
7
|
+
PIE_CHART_INVALID_CANVAS_DIMENSIONS: 'Invalid canvas dimensions for PieChart',
|
|
8
|
+
// Data Validation Errors
|
|
9
|
+
PIE_CHART_INVALID_DATA_KEY: 'Invalid or missing dataKey in PieChart data',
|
|
10
|
+
// Radius Errors
|
|
11
|
+
PIE_CHART_INVALID_INNER_RADIUS: 'Invalid innerRadius value',
|
|
12
|
+
PIE_CHART_INVALID_RADIUS: 'Invalid radius value',
|
|
13
|
+
// Segment Errors
|
|
14
|
+
PIE_CHART_INVALID_SEGMENT_VALUE: 'Invalid segment value (non-numeric)',
|
|
15
|
+
// Data Validation Errors
|
|
16
|
+
PIE_CHART_INVALID_TOTAL: 'PieChart total value is zero or invalid',
|
|
17
|
+
// Segment Errors
|
|
18
|
+
PIE_CHART_MISSING_SEGMENT_NAME: 'Segment is missing required name property',
|
|
19
|
+
PIE_CHART_NEGATIVE_SEGMENT_VALUE: 'Segment value cannot be negative',
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const PieChartErrors: {
|
|
2
|
+
readonly PIE_CHART_EMPTY_DATA: "PIE_CHART_EMPTY_DATA";
|
|
3
|
+
readonly PIE_CHART_INNER_RADIUS_OUT_OF_RANGE: "PIE_CHART_INNER_RADIUS_OUT_OF_RANGE";
|
|
4
|
+
readonly PIE_CHART_INVALID_CANVAS_DIMENSIONS: "PIE_CHART_INVALID_CANVAS_DIMENSIONS";
|
|
5
|
+
readonly PIE_CHART_INVALID_DATA_KEY: "PIE_CHART_INVALID_DATA_KEY";
|
|
6
|
+
readonly PIE_CHART_INVALID_INNER_RADIUS: "PIE_CHART_INVALID_INNER_RADIUS";
|
|
7
|
+
readonly PIE_CHART_INVALID_RADIUS: "PIE_CHART_INVALID_RADIUS";
|
|
8
|
+
readonly PIE_CHART_INVALID_SEGMENT_VALUE: "PIE_CHART_INVALID_SEGMENT_VALUE";
|
|
9
|
+
readonly PIE_CHART_INVALID_TOTAL: "PIE_CHART_INVALID_TOTAL";
|
|
10
|
+
readonly PIE_CHART_MISSING_SEGMENT_NAME: "PIE_CHART_MISSING_SEGMENT_NAME";
|
|
11
|
+
readonly PIE_CHART_NEGATIVE_SEGMENT_VALUE: "PIE_CHART_NEGATIVE_SEGMENT_VALUE";
|
|
12
|
+
};
|
|
13
|
+
export declare const PieChartErrorsRecord: Record<"PIE_CHART_EMPTY_DATA" | "PIE_CHART_INNER_RADIUS_OUT_OF_RANGE" | "PIE_CHART_INVALID_CANVAS_DIMENSIONS" | "PIE_CHART_INVALID_DATA_KEY" | "PIE_CHART_INVALID_INNER_RADIUS" | "PIE_CHART_INVALID_RADIUS" | "PIE_CHART_INVALID_SEGMENT_VALUE" | "PIE_CHART_INVALID_TOTAL" | "PIE_CHART_MISSING_SEGMENT_NAME" | "PIE_CHART_NEGATIVE_SEGMENT_VALUE", Error>;
|
|
14
|
+
//# sourceMappingURL=pieChartErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieChartErrors.d.ts","sourceRoot":"","sources":["../../../../../../src/utils/buildErrors/constants/errors/pieChartErrors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc;;;;;;;;;;;CAmBjB,CAAC;AAEX,eAAO,MAAM,oBAAoB,8VAMhC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PieChartErrorMessages } from '../errorMessages/pieChartErrorMessages';
|
|
2
|
+
export const PieChartErrors = {
|
|
3
|
+
// Data Validation Errors
|
|
4
|
+
PIE_CHART_EMPTY_DATA: 'PIE_CHART_EMPTY_DATA',
|
|
5
|
+
// Radius Errors
|
|
6
|
+
PIE_CHART_INNER_RADIUS_OUT_OF_RANGE: 'PIE_CHART_INNER_RADIUS_OUT_OF_RANGE',
|
|
7
|
+
// Canvas & Context Errors
|
|
8
|
+
PIE_CHART_INVALID_CANVAS_DIMENSIONS: 'PIE_CHART_INVALID_CANVAS_DIMENSIONS',
|
|
9
|
+
// Data Validation Errors
|
|
10
|
+
PIE_CHART_INVALID_DATA_KEY: 'PIE_CHART_INVALID_DATA_KEY',
|
|
11
|
+
// Radius Errors
|
|
12
|
+
PIE_CHART_INVALID_INNER_RADIUS: 'PIE_CHART_INVALID_INNER_RADIUS',
|
|
13
|
+
PIE_CHART_INVALID_RADIUS: 'PIE_CHART_INVALID_RADIUS',
|
|
14
|
+
// Segment Errors
|
|
15
|
+
PIE_CHART_INVALID_SEGMENT_VALUE: 'PIE_CHART_INVALID_SEGMENT_VALUE',
|
|
16
|
+
// Data Validation Errors
|
|
17
|
+
PIE_CHART_INVALID_TOTAL: 'PIE_CHART_INVALID_TOTAL',
|
|
18
|
+
// Segment Errors
|
|
19
|
+
PIE_CHART_MISSING_SEGMENT_NAME: 'PIE_CHART_MISSING_SEGMENT_NAME',
|
|
20
|
+
PIE_CHART_NEGATIVE_SEGMENT_VALUE: 'PIE_CHART_NEGATIVE_SEGMENT_VALUE',
|
|
21
|
+
};
|
|
22
|
+
export const PieChartErrorsRecord = Object.entries(PieChartErrorMessages).reduce((acc, [key, message]) => {
|
|
23
|
+
acc[key] = new Error(message);
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barChartPath.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/fragments/barChartPath.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D;;;;;GAKG;AAEH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"barChartPath.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/fragments/barChartPath.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D;;;;;GAKG;AAEH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkFpD,CAAC"}
|
|
@@ -22,31 +22,36 @@ export const BarChartPath = ({ barConfig, dataIdx, dataKey, order, ...props }) =
|
|
|
22
22
|
const dataItem = context.data[dataIdx];
|
|
23
23
|
const xData = dataItem?.[xKey];
|
|
24
24
|
const yData = dataItem?.[yKey];
|
|
25
|
+
// Extract values for stable dependencies
|
|
26
|
+
const firstDataItem = context.data[0];
|
|
27
|
+
const hasDataKey = firstDataItem
|
|
28
|
+
? Object.prototype.hasOwnProperty.call(firstDataItem, dataKey)
|
|
29
|
+
: false;
|
|
30
|
+
const hasData = context.data.length > 0;
|
|
31
|
+
const numericYData = Number(yData);
|
|
25
32
|
// Path error validations - only validates the data for this specific bar
|
|
26
33
|
useEffect(() => {
|
|
27
34
|
// Validate dataKey exists in dataset
|
|
28
|
-
if (
|
|
29
|
-
!Object.prototype.hasOwnProperty.call(context.data[0], dataKey)) {
|
|
35
|
+
if (hasData && !hasDataKey) {
|
|
30
36
|
addError?.('BAR_CHART_PATH_ERROR', {
|
|
31
37
|
error: buildDataKeyNotFoundError(dataKey),
|
|
32
38
|
});
|
|
33
39
|
return; // Stop validation if dataKey doesn't exist
|
|
34
40
|
}
|
|
35
41
|
// Validate bar value is numeric
|
|
36
|
-
|
|
37
|
-
if (isNaN(numericValue)) {
|
|
42
|
+
if (isNaN(numericYData)) {
|
|
38
43
|
addError?.('BAR_CHART_PATH_ERROR', {
|
|
39
44
|
error: buildBarValueError(yData, dataKey),
|
|
40
45
|
});
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
48
|
// Validate negative values
|
|
44
|
-
if (
|
|
49
|
+
if (numericYData < 0) {
|
|
45
50
|
addError?.('BAR_CHART_PATH_ERROR', {
|
|
46
|
-
error: buildBarNegativeValueError(
|
|
51
|
+
error: buildBarNegativeValueError(numericYData, dataKey),
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
|
-
}, [
|
|
54
|
+
}, [dataKey, hasData, hasDataKey, numericYData, yData]);
|
|
50
55
|
const xPoint = getPoints(xTickValues, [String(xData)], true)[0];
|
|
51
56
|
const yPoint = getPoints(yTickValues, [String(yData)])[0];
|
|
52
57
|
const points = isVertical
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barChartSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/fragments/barChartSeparator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAA4C,MAAM,OAAO,CAAC;AAY1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"barChartSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/fragments/barChartSeparator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAA4C,MAAM,OAAO,CAAC;AAY1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA0GxD,CAAC"}
|
|
@@ -5,13 +5,26 @@ import { getPoints } from '../../../utils/getPoints/getPoints';
|
|
|
5
5
|
import { BarChartContext } from '../context/barChartContext';
|
|
6
6
|
export const BarChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, topSeparator, xBreakAxis, yBreakAxis, }) => {
|
|
7
7
|
const { addError, crossXAxis, crossYAxis, xAxisCoordinates, yAxisCoordinates } = useContext(BarChartContext);
|
|
8
|
+
// Extract tick values for stable dependencies
|
|
9
|
+
const xTickValues = xAxisCoordinates.tickValues;
|
|
10
|
+
const yTickValues = yAxisCoordinates.tickValues;
|
|
11
|
+
// Pre-calculate numeric values for dependencies
|
|
12
|
+
const xBreakNumeric = xBreakAxis !== undefined
|
|
13
|
+
? typeof xBreakAxis === 'string'
|
|
14
|
+
? parseFloat(xBreakAxis)
|
|
15
|
+
: xBreakAxis
|
|
16
|
+
: undefined;
|
|
17
|
+
const yBreakNumeric = yBreakAxis !== undefined
|
|
18
|
+
? typeof yBreakAxis === 'string'
|
|
19
|
+
? parseFloat(yBreakAxis)
|
|
20
|
+
: yBreakAxis
|
|
21
|
+
: undefined;
|
|
8
22
|
// Separator error validations
|
|
9
23
|
useEffect(() => {
|
|
10
24
|
// xBreakAxis validation
|
|
11
25
|
if (xBreakAxis !== undefined) {
|
|
12
|
-
const xValues =
|
|
13
|
-
|
|
14
|
-
if (isNaN(xBreakNumeric)) {
|
|
26
|
+
const xValues = xTickValues.map(tick => tick.value);
|
|
27
|
+
if (xBreakNumeric === undefined || isNaN(xBreakNumeric)) {
|
|
15
28
|
addError?.('BAR_CHART_SEPARATOR_ERROR', {
|
|
16
29
|
error: buildSeparatorXBreakAxisError(xBreakAxis),
|
|
17
30
|
});
|
|
@@ -28,9 +41,8 @@ export const BarChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, t
|
|
|
28
41
|
}
|
|
29
42
|
// yBreakAxis validation
|
|
30
43
|
if (yBreakAxis !== undefined) {
|
|
31
|
-
const yValues =
|
|
32
|
-
|
|
33
|
-
if (isNaN(yBreakNumeric)) {
|
|
44
|
+
const yValues = yTickValues.map(tick => tick.value);
|
|
45
|
+
if (yBreakNumeric === undefined || isNaN(yBreakNumeric)) {
|
|
34
46
|
addError?.('BAR_CHART_SEPARATOR_ERROR', {
|
|
35
47
|
error: buildSeparatorYBreakAxisError(yBreakAxis),
|
|
36
48
|
});
|
|
@@ -45,7 +57,7 @@ export const BarChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, t
|
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
}
|
|
48
|
-
}, [xBreakAxis,
|
|
60
|
+
}, [xBreakAxis, xBreakNumeric, xTickValues, yBreakAxis, yBreakNumeric, yTickValues]);
|
|
49
61
|
if (!topSeparator && !rightSeparator && !areaSeparator) {
|
|
50
62
|
return _jsx(_Fragment, {});
|
|
51
63
|
}
|
|
@@ -64,7 +76,7 @@ export const BarChartSeparator = ({ areaSeparator, dataTestId, rightSeparator, t
|
|
|
64
76
|
error: buildError(BuildError.LINE_CHART_SEPARATOR_INVALID_COORDINATES),
|
|
65
77
|
});
|
|
66
78
|
}
|
|
67
|
-
}, [xStart, xEnd, yStart, yEnd
|
|
79
|
+
}, [xStart, xEnd, yStart, yEnd]);
|
|
68
80
|
const squarePath = `M${xStart} ${yStart} H ${xEnd} V ${yEnd} H ${xStart} Z`;
|
|
69
81
|
const lineTop = `M${xStart} ${yEnd} H ${xEnd}`;
|
|
70
82
|
const lineRight = `M${xEnd} ${yStart} V ${yEnd}`;
|
|
@@ -74,4 +74,24 @@ export declare const LINE_CHART_FALLBACK_DATA: {
|
|
|
74
74
|
/** Second Y value for line chart fallback data */
|
|
75
75
|
readonly FALLBACK_Y_SECOND: 1;
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Pie Chart specific default configuration values
|
|
79
|
+
*/
|
|
80
|
+
export declare const PIE_CHART_DEFAULTS: {
|
|
81
|
+
/** Default radius percentage when not specified */
|
|
82
|
+
readonly DEFAULT_RADIUS_PERCENTAGE: 50;
|
|
83
|
+
/** Minimum number of segments required for a valid pie chart */
|
|
84
|
+
readonly MIN_SEGMENTS: 1;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Pie Chart specific fallback data points used when pie chart data is invalid or empty
|
|
88
|
+
*/
|
|
89
|
+
export declare const PIE_CHART_FALLBACK_DATA: {
|
|
90
|
+
/** Generic data key for fallback data */
|
|
91
|
+
readonly FALLBACK_DATA_KEY: "fallbackSegments";
|
|
92
|
+
/** Default segment name for fallback data */
|
|
93
|
+
readonly FALLBACK_SEGMENT_NAME: "fallback";
|
|
94
|
+
/** Default segment value for fallback data */
|
|
95
|
+
readonly FALLBACK_SEGMENT_VALUE: 100;
|
|
96
|
+
};
|
|
77
97
|
//# sourceMappingURL=chartDefaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartDefaults.d.ts","sourceRoot":"","sources":["../../../../src/charts/constants/chartDefaults.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,4DAA4D;;IAE5D,0DAA0D;;CAElD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,8DAA8D;;IAE9D,+DAA+D;;CAEvD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,sBAAsB;IACjC,yDAAyD;;CAEjD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAC9B,2DAA2D;;CAEnD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B,8DAA8D;;IAE9D,+DAA+D;;CAEvD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,wDAAwD;;CAEhD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC,+CAA+C;;IAE/C,qEAAqE;;CAE7D,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB;IACnC,iDAAiD;;IAEjD,kDAAkD;;IAElD,iDAAiD;;IAEjD,kDAAkD;;CAE1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"chartDefaults.d.ts","sourceRoot":"","sources":["../../../../src/charts/constants/chartDefaults.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,4DAA4D;;IAE5D,0DAA0D;;CAElD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,8DAA8D;;IAE9D,+DAA+D;;CAEvD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,sBAAsB;IACjC,yDAAyD;;CAEjD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAC9B,2DAA2D;;CAEnD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B,8DAA8D;;IAE9D,+DAA+D;;CAEvD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,wDAAwD;;CAEhD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC,+CAA+C;;IAE/C,qEAAqE;;CAE7D,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB;IACnC,iDAAiD;;IAEjD,kDAAkD;;IAElD,iDAAiD;;IAEjD,kDAAkD;;CAE1C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,mDAAmD;;IAEnD,gEAAgE;;CAExD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC,yCAAyC;;IAEzC,6CAA6C;;IAE7C,8CAA8C;;CAEtC,CAAC"}
|
|
@@ -74,3 +74,23 @@ export const LINE_CHART_FALLBACK_DATA = {
|
|
|
74
74
|
/** Second Y value for line chart fallback data */
|
|
75
75
|
FALLBACK_Y_SECOND: 1,
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Pie Chart specific default configuration values
|
|
79
|
+
*/
|
|
80
|
+
export const PIE_CHART_DEFAULTS = {
|
|
81
|
+
/** Default radius percentage when not specified */
|
|
82
|
+
DEFAULT_RADIUS_PERCENTAGE: 50,
|
|
83
|
+
/** Minimum number of segments required for a valid pie chart */
|
|
84
|
+
MIN_SEGMENTS: 1,
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Pie Chart specific fallback data points used when pie chart data is invalid or empty
|
|
88
|
+
*/
|
|
89
|
+
export const PIE_CHART_FALLBACK_DATA = {
|
|
90
|
+
/** Generic data key for fallback data */
|
|
91
|
+
FALLBACK_DATA_KEY: 'fallbackSegments',
|
|
92
|
+
/** Default segment name for fallback data */
|
|
93
|
+
FALLBACK_SEGMENT_NAME: 'fallback',
|
|
94
|
+
/** Default segment value for fallback data */
|
|
95
|
+
FALLBACK_SEGMENT_VALUE: 100,
|
|
96
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChartPath.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartPath.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAoD,MAAM,OAAO,CAAC;AAWlF,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIxE,OAAO,qBAAqB,CAAC;AAO7B,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"lineChartPath.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartPath.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAoD,MAAM,OAAO,CAAC;AAWlF,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIxE,OAAO,qBAAqB,CAAC;AAO7B,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA8LhD,CAAC"}
|
|
@@ -19,38 +19,45 @@ const getAxisData = (data, key) => {
|
|
|
19
19
|
export const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getNodesCoords, indicatorConfig, lineProjection, onClick, ...props }) => {
|
|
20
20
|
// recovery the context values
|
|
21
21
|
const { addError, xAxisCoordinates, yAxisCoordinates, ...context } = useContext(LineChartContext);
|
|
22
|
+
// Extract stable values for dependencies
|
|
23
|
+
const dataKey = props.dataKey;
|
|
24
|
+
const hasData = context.data.length > 0;
|
|
25
|
+
const firstDataItem = context.data[0];
|
|
26
|
+
const hasDataKey = firstDataItem
|
|
27
|
+
? Object.prototype.hasOwnProperty.call(firstDataItem, dataKey)
|
|
28
|
+
: false;
|
|
29
|
+
const dataLength = context.data.length;
|
|
22
30
|
// Path error validations
|
|
23
31
|
useEffect(() => {
|
|
24
32
|
// Invalid dataKey validation
|
|
25
|
-
if (!
|
|
33
|
+
if (!dataKey || typeof dataKey !== 'string') {
|
|
26
34
|
addError?.('LINE_CHART_PATH_ERROR', {
|
|
27
35
|
error: buildError(BuildError.LINE_CHART_PATH_INVALID_DATAKEY),
|
|
28
36
|
});
|
|
29
37
|
return;
|
|
30
38
|
}
|
|
31
39
|
// Check if dataKey exists in dataset
|
|
32
|
-
if (
|
|
33
|
-
!Object.prototype.hasOwnProperty.call(context.data[0], props.dataKey)) {
|
|
40
|
+
if (hasData && !hasDataKey) {
|
|
34
41
|
addError?.('LINE_CHART_PATH_ERROR', {
|
|
35
|
-
error: buildDataKeyNotFoundError(
|
|
42
|
+
error: buildDataKeyNotFoundError(dataKey),
|
|
36
43
|
});
|
|
37
44
|
return;
|
|
38
45
|
}
|
|
39
46
|
// Curved path calculation errors
|
|
40
|
-
if (curved &&
|
|
47
|
+
if (curved && dataLength < 2) {
|
|
41
48
|
addError?.('LINE_CHART_PATH_ERROR', {
|
|
42
49
|
error: buildError(BuildError.LINE_CHART_PATH_INSUFFICIENT_POINTS),
|
|
43
50
|
});
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
46
53
|
// Path rendering errors - validate coordinates
|
|
47
|
-
const yData = getAxisData(context.data,
|
|
54
|
+
const yData = getAxisData(context.data, dataKey);
|
|
48
55
|
if (yData.length > 0 && yData.every(val => val === null || val === undefined)) {
|
|
49
56
|
addError?.('LINE_CHART_PATH_ERROR', {
|
|
50
57
|
error: buildError(BuildError.LINE_CHART_PATH_ALL_VALUES_NULL),
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
|
-
}, [
|
|
60
|
+
}, [addError, curved, dataKey, dataLength, hasData, hasDataKey, context.data]);
|
|
54
61
|
// the node indicator logic
|
|
55
62
|
const { indicatorRef, pathRef } = useIndicator(context.xCursor, !!indicatorConfig);
|
|
56
63
|
const showIndicator = !!indicatorConfig && context.xCursor !== -Infinity;
|
|
@@ -65,7 +72,7 @@ export const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInf
|
|
|
65
72
|
const { tickValues: xTickValues } = xAxisCoordinates;
|
|
66
73
|
const { tickValues: yTickValues } = yAxisCoordinates;
|
|
67
74
|
const xData = getAxisData(context.data, context.xKey);
|
|
68
|
-
const yData = getAxisData(context.data,
|
|
75
|
+
const yData = getAxisData(context.data, dataKey);
|
|
69
76
|
const xPoints = getPoints(xTickValues, xData, true);
|
|
70
77
|
const yPoints = getPoints(yTickValues, yData);
|
|
71
78
|
const points = xPoints.map((x, i) => [x, yPoints[i]]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChartProjection.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartProjection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAyB,MAAM,OAAO,CAAC;AASvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,qBAAqB,CAAC;AAE7B,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"lineChartProjection.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartProjection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAyB,MAAM,OAAO,CAAC;AASvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,qBAAqB,CAAC;AAE7B,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CA8E5D,CAAC"}
|
|
@@ -11,21 +11,25 @@ export const LineChartProjection = ({ curved, lineProjection, points, svgHeight,
|
|
|
11
11
|
const { xProjection: xDw, yProjection: yDw, ...lowerProps } = lower || {};
|
|
12
12
|
const upperProjection = xUp || yUp ? { x: xUp, y: yUp } : undefined;
|
|
13
13
|
const lowerProjection = xDw || yDw ? { x: xDw, y: yDw } : undefined;
|
|
14
|
+
// Extract values for stable dependencies
|
|
15
|
+
const upperY = upperProjection?.y;
|
|
16
|
+
const lowerY = lowerProjection?.y;
|
|
17
|
+
const upperX = upperProjection?.x;
|
|
18
|
+
const lowerX = lowerProjection?.x;
|
|
14
19
|
// Projection error validations
|
|
15
20
|
useEffect(() => {
|
|
16
21
|
// Invalid projection bounds - upper/lower overlap
|
|
17
22
|
if (upperProjection && lowerProjection) {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
23
|
+
const upperYVal = upperY || 0;
|
|
24
|
+
const lowerYVal = lowerY || 0;
|
|
25
|
+
if (upperYVal >= lowerYVal) {
|
|
21
26
|
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
22
|
-
error: buildProjectionBoundsError(
|
|
27
|
+
error: buildProjectionBoundsError(upperYVal, lowerYVal),
|
|
23
28
|
});
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
// Projection coordinates outside chart area
|
|
27
32
|
if (upperProjection) {
|
|
28
|
-
const { x: upperX, y: upperY } = upperProjection;
|
|
29
33
|
if (upperX !== undefined && (upperX < 0 || upperX > 100)) {
|
|
30
34
|
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
31
35
|
error: buildProjectionXOutOfRangeError(upperX, true),
|
|
@@ -38,7 +42,6 @@ export const LineChartProjection = ({ curved, lineProjection, points, svgHeight,
|
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
if (lowerProjection) {
|
|
41
|
-
const { x: lowerX, y: lowerY } = lowerProjection;
|
|
42
45
|
if (lowerX !== undefined && (lowerX < 0 || lowerX > 100)) {
|
|
43
46
|
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
44
47
|
error: buildProjectionXOutOfRangeError(lowerX, false),
|
|
@@ -50,7 +53,7 @@ export const LineChartProjection = ({ curved, lineProjection, points, svgHeight,
|
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
|
-
}, [
|
|
56
|
+
}, [lowerProjection, lowerX, lowerY, svgHeight, upperProjection, upperX, upperY]);
|
|
54
57
|
const { downPath, shapePath, upPath } = getProjection({
|
|
55
58
|
curved,
|
|
56
59
|
lowerProjection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChartSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartSeparator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAA4C,MAAM,OAAO,CAAC;AAa1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"lineChartSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartSeparator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAA4C,MAAM,OAAO,CAAC;AAa1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CA0G1D,CAAC"}
|