@kubit-ui-web/react-charts 1.1.0 → 1.2.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/barChart.type.d.ts +4 -0
- package/dist/cjs/charts/barChart/barChart.type.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/barChartStructure.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/barChartStructure.js +9 -2
- package/dist/cjs/charts/barChart/context/buildBarContextValues.d.ts +3 -1
- package/dist/cjs/charts/barChart/context/buildBarContextValues.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/context/buildBarContextValues.js +177 -16
- package/dist/cjs/charts/barChart/fragments/barChartPath.d.ts +6 -0
- package/dist/cjs/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/barChartPath.js +38 -4
- package/dist/cjs/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/barChartSeparator.js +52 -2
- package/dist/cjs/charts/barChart/fragments/barChartXAxis.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/barChartXAxis.js +2 -1
- package/dist/cjs/charts/barChart/fragments/barChartYAxis.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/barChartYAxis.js +2 -1
- package/dist/cjs/charts/barChart/fragments/fixture/barContextData.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/fragments/fixture/barContextData.js +1 -0
- package/dist/cjs/charts/barChart/utils/getBarDataValue.d.ts.map +1 -1
- package/dist/cjs/charts/barChart/utils/getBarDataValue.js +5 -0
- package/dist/cjs/charts/constants/chartDefaults.d.ts +77 -0
- package/dist/cjs/charts/constants/chartDefaults.d.ts.map +1 -0
- package/dist/cjs/charts/constants/chartDefaults.js +76 -0
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts +3 -1
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +162 -46
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts +1 -0
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +1 -0
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +34 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.js +44 -0
- package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.js +52 -2
- package/dist/cjs/charts/lineChart/lineChart.type.d.ts +2 -1
- package/dist/cjs/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/lineChartStructure.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/lineChartStructure.js +15 -11
- package/dist/cjs/types/errors.type.d.ts +14 -1
- package/dist/cjs/types/errors.type.d.ts.map +1 -1
- package/dist/cjs/types/errors.type.js +18 -0
- package/dist/cjs/utils/buildErrors/buildErrors.d.ts +63 -0
- package/dist/cjs/utils/buildErrors/buildErrors.d.ts.map +1 -1
- package/dist/cjs/utils/buildErrors/buildErrors.js +32 -0
- package/dist/cjs/utils/buildErrors/charts/buildBarChartErrors.d.ts +17 -0
- package/dist/cjs/utils/buildErrors/charts/buildBarChartErrors.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/charts/buildBarChartErrors.js +16 -0
- package/dist/cjs/utils/buildErrors/charts/buildLineChartErrors.d.ts +13 -0
- package/dist/cjs/utils/buildErrors/charts/buildLineChartErrors.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/charts/buildLineChartErrors.js +12 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts +19 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/barChartErrorMessages.js +23 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts +25 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.js +29 -0
- package/dist/cjs/utils/buildErrors/constants/errors/barChartErrors.d.ts +20 -0
- package/dist/cjs/utils/buildErrors/constants/errors/barChartErrors.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/constants/errors/barChartErrors.js +28 -0
- package/dist/cjs/utils/buildErrors/constants/errors/lineChartErrors.d.ts +26 -0
- package/dist/cjs/utils/buildErrors/constants/errors/lineChartErrors.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/constants/errors/lineChartErrors.js +34 -0
- package/dist/cjs/utils/buildErrors/index.d.ts +2 -0
- package/dist/cjs/utils/buildErrors/index.d.ts.map +1 -0
- package/dist/cjs/utils/buildErrors/index.js +2 -0
- package/dist/cjs/utils/createErrorAccumulator/createErrorAccumulator.d.ts +7 -0
- package/dist/cjs/utils/createErrorAccumulator/createErrorAccumulator.d.ts.map +1 -0
- package/dist/cjs/utils/createErrorAccumulator/createErrorAccumulator.js +54 -0
- package/dist/cjs/utils/createErrorAccumulator/index.d.ts +2 -0
- package/dist/cjs/utils/createErrorAccumulator/index.d.ts.map +1 -0
- package/dist/cjs/utils/createErrorAccumulator/index.js +1 -0
- package/dist/esm/charts/barChart/barChart.type.d.ts +4 -0
- package/dist/esm/charts/barChart/barChart.type.d.ts.map +1 -1
- package/dist/esm/charts/barChart/barChartStructure.d.ts.map +1 -1
- package/dist/esm/charts/barChart/barChartStructure.js +9 -2
- package/dist/esm/charts/barChart/context/buildBarContextValues.d.ts +3 -1
- package/dist/esm/charts/barChart/context/buildBarContextValues.d.ts.map +1 -1
- package/dist/esm/charts/barChart/context/buildBarContextValues.js +177 -16
- package/dist/esm/charts/barChart/fragments/barChartPath.d.ts +6 -0
- package/dist/esm/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/barChartPath.js +38 -4
- package/dist/esm/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/barChartSeparator.js +52 -2
- package/dist/esm/charts/barChart/fragments/barChartXAxis.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/barChartXAxis.js +2 -1
- package/dist/esm/charts/barChart/fragments/barChartYAxis.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/barChartYAxis.js +2 -1
- package/dist/esm/charts/barChart/fragments/fixture/barContextData.d.ts.map +1 -1
- package/dist/esm/charts/barChart/fragments/fixture/barContextData.js +1 -0
- package/dist/esm/charts/barChart/utils/getBarDataValue.d.ts.map +1 -1
- package/dist/esm/charts/barChart/utils/getBarDataValue.js +5 -0
- package/dist/esm/charts/constants/chartDefaults.d.ts +77 -0
- package/dist/esm/charts/constants/chartDefaults.d.ts.map +1 -0
- package/dist/esm/charts/constants/chartDefaults.js +76 -0
- package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts +3 -1
- package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/context/buildLineContextValue.js +162 -46
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts +1 -0
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.js +1 -0
- package/dist/esm/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartPath.js +34 -1
- package/dist/esm/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartProjection.js +44 -0
- package/dist/esm/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartSeparator.js +52 -2
- package/dist/esm/charts/lineChart/lineChart.type.d.ts +2 -1
- package/dist/esm/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/lineChartStructure.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/lineChartStructure.js +15 -11
- package/dist/esm/types/errors.type.d.ts +14 -1
- package/dist/esm/types/errors.type.d.ts.map +1 -1
- package/dist/esm/types/errors.type.js +18 -0
- package/dist/esm/utils/buildErrors/buildErrors.d.ts +63 -0
- package/dist/esm/utils/buildErrors/buildErrors.d.ts.map +1 -1
- package/dist/esm/utils/buildErrors/buildErrors.js +32 -0
- package/dist/esm/utils/buildErrors/charts/buildBarChartErrors.d.ts +17 -0
- package/dist/esm/utils/buildErrors/charts/buildBarChartErrors.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/charts/buildBarChartErrors.js +16 -0
- package/dist/esm/utils/buildErrors/charts/buildLineChartErrors.d.ts +13 -0
- package/dist/esm/utils/buildErrors/charts/buildLineChartErrors.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/charts/buildLineChartErrors.js +12 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts +19 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/barChartErrorMessages.js +23 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts +25 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.js +29 -0
- package/dist/esm/utils/buildErrors/constants/errors/barChartErrors.d.ts +20 -0
- package/dist/esm/utils/buildErrors/constants/errors/barChartErrors.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/constants/errors/barChartErrors.js +28 -0
- package/dist/esm/utils/buildErrors/constants/errors/lineChartErrors.d.ts +26 -0
- package/dist/esm/utils/buildErrors/constants/errors/lineChartErrors.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/constants/errors/lineChartErrors.js +34 -0
- package/dist/esm/utils/buildErrors/index.d.ts +2 -0
- package/dist/esm/utils/buildErrors/index.d.ts.map +1 -0
- package/dist/esm/utils/buildErrors/index.js +2 -0
- package/dist/esm/utils/createErrorAccumulator/createErrorAccumulator.d.ts +7 -0
- package/dist/esm/utils/createErrorAccumulator/createErrorAccumulator.d.ts.map +1 -0
- package/dist/esm/utils/createErrorAccumulator/createErrorAccumulator.js +54 -0
- package/dist/esm/utils/createErrorAccumulator/index.d.ts +2 -0
- package/dist/esm/utils/createErrorAccumulator/index.d.ts.map +1 -0
- package/dist/esm/utils/createErrorAccumulator/index.js +1 -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.type.d.ts +4 -0
- package/dist/types/charts/barChart/barChart.type.d.ts.map +1 -1
- package/dist/types/charts/barChart/barChartStructure.d.ts.map +1 -1
- package/dist/types/charts/barChart/context/buildBarContextValues.d.ts +3 -1
- package/dist/types/charts/barChart/context/buildBarContextValues.d.ts.map +1 -1
- package/dist/types/charts/barChart/fragments/barChartPath.d.ts +6 -0
- package/dist/types/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
- package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
- package/dist/types/charts/barChart/fragments/barChartXAxis.d.ts.map +1 -1
- package/dist/types/charts/barChart/fragments/barChartYAxis.d.ts.map +1 -1
- package/dist/types/charts/barChart/fragments/fixture/barContextData.d.ts.map +1 -1
- package/dist/types/charts/barChart/utils/getBarDataValue.d.ts.map +1 -1
- package/dist/types/charts/constants/chartDefaults.d.ts +77 -0
- package/dist/types/charts/constants/chartDefaults.d.ts.map +1 -0
- package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts +3 -1
- package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts +1 -0
- package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
- package/dist/types/charts/lineChart/lineChart.type.d.ts +2 -1
- package/dist/types/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/types/charts/lineChart/lineChartStructure.d.ts.map +1 -1
- package/dist/types/types/errors.type.d.ts +14 -1
- package/dist/types/types/errors.type.d.ts.map +1 -1
- package/dist/types/utils/buildErrors/buildErrors.d.ts +63 -0
- package/dist/types/utils/buildErrors/buildErrors.d.ts.map +1 -1
- package/dist/types/utils/buildErrors/charts/buildBarChartErrors.d.ts +17 -0
- package/dist/types/utils/buildErrors/charts/buildBarChartErrors.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/charts/buildLineChartErrors.d.ts +13 -0
- package/dist/types/utils/buildErrors/charts/buildLineChartErrors.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts +19 -0
- package/dist/types/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts +25 -0
- package/dist/types/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/constants/errors/barChartErrors.d.ts +20 -0
- package/dist/types/utils/buildErrors/constants/errors/barChartErrors.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/constants/errors/lineChartErrors.d.ts +26 -0
- package/dist/types/utils/buildErrors/constants/errors/lineChartErrors.d.ts.map +1 -0
- package/dist/types/utils/buildErrors/index.d.ts +2 -0
- package/dist/types/utils/buildErrors/index.d.ts.map +1 -0
- package/dist/types/utils/createErrorAccumulator/createErrorAccumulator.d.ts +7 -0
- package/dist/types/utils/createErrorAccumulator/createErrorAccumulator.d.ts.map +1 -0
- package/dist/types/utils/createErrorAccumulator/index.d.ts +2 -0
- package/dist/types/utils/createErrorAccumulator/index.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared default configuration constants for chart components.
|
|
3
|
+
*
|
|
4
|
+
* These constants provide standardized default values that are common across
|
|
5
|
+
* different chart types, as well as type-specific constants with clear naming.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default canvas dimensions used as fallback when invalid dimensions are provided
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHART_CANVAS_DEFAULTS: {
|
|
11
|
+
/** Default canvas height when invalid height is provided */
|
|
12
|
+
readonly SAFE_HEIGHT: 100;
|
|
13
|
+
/** Default canvas width when invalid width is provided */
|
|
14
|
+
readonly SAFE_WIDTH: 100;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Axis validation constants for tick values and positioning
|
|
18
|
+
*/
|
|
19
|
+
export declare const AXIS_VALIDATION: {
|
|
20
|
+
/** Minimum number of tick values required for a valid axis */
|
|
21
|
+
readonly MIN_TICK_COUNT: 2;
|
|
22
|
+
/** Number used to detect when all tick values are identical */
|
|
23
|
+
readonly UNIQUE_VALUE_THRESHOLD: 1;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Default spacing and positioning values
|
|
27
|
+
*/
|
|
28
|
+
export declare const CHART_SPACING_DEFAULTS: {
|
|
29
|
+
/** Default spacing value when no spacing is specified */
|
|
30
|
+
readonly DEFAULT_SPACE: 0;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Break axis default values
|
|
34
|
+
*/
|
|
35
|
+
export declare const BREAK_AXIS_DEFAULTS: {
|
|
36
|
+
/** Default value when no custom break axis is specified */
|
|
37
|
+
readonly DEFAULT_BREAK_VALUE: 0;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Shared fallback data points used across different chart types
|
|
41
|
+
*/
|
|
42
|
+
export declare const SHARED_FALLBACK_DATA: {
|
|
43
|
+
/** First fallback primary key value (used for axis labels) */
|
|
44
|
+
readonly FALLBACK_PKEY_FIRST: "0";
|
|
45
|
+
/** Second fallback primary key value (used for axis labels) */
|
|
46
|
+
readonly FALLBACK_PKEY_SECOND: "1";
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Bar Chart specific default configuration values
|
|
50
|
+
*/
|
|
51
|
+
export declare const BAR_CHART_DEFAULTS: {
|
|
52
|
+
/** Default width for bar elements when not specified */
|
|
53
|
+
readonly BAR_WIDTH: 20;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Bar Chart specific fallback data points used when bar chart data is invalid or empty
|
|
57
|
+
*/
|
|
58
|
+
export declare const BAR_CHART_FALLBACK_DATA: {
|
|
59
|
+
/** Default x value for fallback data points */
|
|
60
|
+
readonly DEFAULT_X_VALUE: 0;
|
|
61
|
+
/** Generic secondary key for fallback data when dataKey is needed */
|
|
62
|
+
readonly FALLBACK_SECONDARY_KEY: "fallbackData";
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Line Chart specific fallback data points used when line chart data is invalid or empty
|
|
66
|
+
*/
|
|
67
|
+
export declare const LINE_CHART_FALLBACK_DATA: {
|
|
68
|
+
/** First X value for line chart fallback data */
|
|
69
|
+
readonly FALLBACK_X_FIRST: "0";
|
|
70
|
+
/** Second X value for line chart fallback data */
|
|
71
|
+
readonly FALLBACK_X_SECOND: "1";
|
|
72
|
+
/** First Y value for line chart fallback data */
|
|
73
|
+
readonly FALLBACK_Y_FIRST: 0;
|
|
74
|
+
/** Second Y value for line chart fallback data */
|
|
75
|
+
readonly FALLBACK_Y_SECOND: 1;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=chartDefaults.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared default configuration constants for chart components.
|
|
3
|
+
*
|
|
4
|
+
* These constants provide standardized default values that are common across
|
|
5
|
+
* different chart types, as well as type-specific constants with clear naming.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default canvas dimensions used as fallback when invalid dimensions are provided
|
|
9
|
+
*/
|
|
10
|
+
export const CHART_CANVAS_DEFAULTS = {
|
|
11
|
+
/** Default canvas height when invalid height is provided */
|
|
12
|
+
SAFE_HEIGHT: 100,
|
|
13
|
+
/** Default canvas width when invalid width is provided */
|
|
14
|
+
SAFE_WIDTH: 100,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Axis validation constants for tick values and positioning
|
|
18
|
+
*/
|
|
19
|
+
export const AXIS_VALIDATION = {
|
|
20
|
+
/** Minimum number of tick values required for a valid axis */
|
|
21
|
+
MIN_TICK_COUNT: 2,
|
|
22
|
+
/** Number used to detect when all tick values are identical */
|
|
23
|
+
UNIQUE_VALUE_THRESHOLD: 1,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Default spacing and positioning values
|
|
27
|
+
*/
|
|
28
|
+
export const CHART_SPACING_DEFAULTS = {
|
|
29
|
+
/** Default spacing value when no spacing is specified */
|
|
30
|
+
DEFAULT_SPACE: 0,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Break axis default values
|
|
34
|
+
*/
|
|
35
|
+
export const BREAK_AXIS_DEFAULTS = {
|
|
36
|
+
/** Default value when no custom break axis is specified */
|
|
37
|
+
DEFAULT_BREAK_VALUE: 0,
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Shared fallback data points used across different chart types
|
|
41
|
+
*/
|
|
42
|
+
export const SHARED_FALLBACK_DATA = {
|
|
43
|
+
/** First fallback primary key value (used for axis labels) */
|
|
44
|
+
FALLBACK_PKEY_FIRST: '0',
|
|
45
|
+
/** Second fallback primary key value (used for axis labels) */
|
|
46
|
+
FALLBACK_PKEY_SECOND: '1',
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Bar Chart specific default configuration values
|
|
50
|
+
*/
|
|
51
|
+
export const BAR_CHART_DEFAULTS = {
|
|
52
|
+
/** Default width for bar elements when not specified */
|
|
53
|
+
BAR_WIDTH: 20,
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Bar Chart specific fallback data points used when bar chart data is invalid or empty
|
|
57
|
+
*/
|
|
58
|
+
export const BAR_CHART_FALLBACK_DATA = {
|
|
59
|
+
/** Default x value for fallback data points */
|
|
60
|
+
DEFAULT_X_VALUE: 0,
|
|
61
|
+
/** Generic secondary key for fallback data when dataKey is needed */
|
|
62
|
+
FALLBACK_SECONDARY_KEY: 'fallbackData',
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Line Chart specific fallback data points used when line chart data is invalid or empty
|
|
66
|
+
*/
|
|
67
|
+
export const LINE_CHART_FALLBACK_DATA = {
|
|
68
|
+
/** First X value for line chart fallback data */
|
|
69
|
+
FALLBACK_X_FIRST: '0',
|
|
70
|
+
/** Second X value for line chart fallback data */
|
|
71
|
+
FALLBACK_X_SECOND: '1',
|
|
72
|
+
/** First Y value for line chart fallback data */
|
|
73
|
+
FALLBACK_Y_FIRST: 0,
|
|
74
|
+
/** Second Y value for line chart fallback data */
|
|
75
|
+
FALLBACK_Y_SECOND: 1,
|
|
76
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ChartError, ErrorType } from '../../../types/errors.type';
|
|
1
2
|
import type { ChildrenType, IDataPoint, LineChartContextType } from '../lineChart.type';
|
|
2
3
|
interface BuildContextValue {
|
|
3
4
|
children: ChildrenType;
|
|
@@ -8,6 +9,7 @@ interface BuildContextValue {
|
|
|
8
9
|
canvasHeight: number;
|
|
9
10
|
canvasWidth: number;
|
|
10
11
|
viewBox: string;
|
|
12
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
11
13
|
}
|
|
12
14
|
type OmitProps = 'data' | 'xKey' | 'canvasHeight' | 'canvasWidth' | 'canvasExtraSpace' | 'xBreakAxis' | 'yBreakAxis' | 'xCursor' | 'yCursor';
|
|
13
15
|
/**
|
|
@@ -16,6 +18,6 @@ type OmitProps = 'data' | 'xKey' | 'canvasHeight' | 'canvasWidth' | 'canvasExtra
|
|
|
16
18
|
* @param {BuildContextValue} options - The options for building the context value.
|
|
17
19
|
* @returns {LineContextValue} - The built context value.
|
|
18
20
|
*/
|
|
19
|
-
export declare const buildLineContextValue: ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }: BuildContextValue) => Omit<LineChartContextType, OmitProps>;
|
|
21
|
+
export declare const buildLineContextValue: ({ addError, ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }: BuildContextValue) => Omit<LineChartContextType, OmitProps>;
|
|
20
22
|
export {};
|
|
21
23
|
//# sourceMappingURL=buildLineContextValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildLineContextValue.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/context/buildLineContextValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildLineContextValue.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/context/buildLineContextValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAkBjE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGxF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,OAAO,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACzF;AAED,KAAK,SAAS,GACV,MAAM,GACN,MAAM,GACN,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,SAAS,CAAC;AAEd;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,6FAUnC,iBAAiB,KAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAoR1D,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ErrorType } from '../../../types/errors.type';
|
|
1
2
|
import { Positions } from '../../../types/position.enum';
|
|
2
|
-
import { BuildError, buildError } from '../../../utils/buildErrors/buildErrors';
|
|
3
|
+
import { BuildError, buildCanvasDimensionsError, buildError, } from '../../../utils/buildErrors/buildErrors';
|
|
3
4
|
import { getXCoordinates, getYCoordinates } from '../../../utils/getCoordinates/getCoordinates';
|
|
4
5
|
import { getPoints } from '../../../utils/getPoints/getPoints';
|
|
5
6
|
import { getXTicks, getYTicks } from '../../../utils/getTicks/getTicks';
|
|
7
|
+
import { AXIS_VALIDATION, BREAK_AXIS_DEFAULTS, CHART_CANVAS_DEFAULTS, LINE_CHART_FALLBACK_DATA, SHARED_FALLBACK_DATA, } from '../../constants/chartDefaults';
|
|
6
8
|
import { getExtraSpacing } from '../utils/getExtraSpacing';
|
|
7
9
|
/**
|
|
8
10
|
* Builds the context value for the line chart.
|
|
@@ -10,18 +12,56 @@ import { getExtraSpacing } from '../utils/getExtraSpacing';
|
|
|
10
12
|
* @param {BuildContextValue} options - The options for building the context value.
|
|
11
13
|
* @returns {LineContextValue} - The built context value.
|
|
12
14
|
*/
|
|
13
|
-
export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
|
|
15
|
+
export const buildLineContextValue = ({ addError, ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
|
|
14
16
|
let error = undefined;
|
|
17
|
+
// 1. Validate data exists
|
|
18
|
+
if (!data || data.length === 0) {
|
|
19
|
+
const dataError = {
|
|
20
|
+
error: buildError(BuildError.LINE_CHART_NO_DATA),
|
|
21
|
+
};
|
|
22
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', dataError);
|
|
23
|
+
error = dataError;
|
|
24
|
+
}
|
|
25
|
+
if (data && data.length === 1) {
|
|
26
|
+
const singlePointError = {
|
|
27
|
+
error: buildError(BuildError.LINE_CHART_SINGLE_POINT),
|
|
28
|
+
};
|
|
29
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', singlePointError);
|
|
30
|
+
error = singlePointError;
|
|
31
|
+
}
|
|
32
|
+
// 2. Validate canvas dimensions
|
|
33
|
+
if (canvasWidth <= 0 || canvasHeight <= 0) {
|
|
34
|
+
const canvasError = {
|
|
35
|
+
error: buildCanvasDimensionsError(canvasWidth, canvasHeight),
|
|
36
|
+
};
|
|
37
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', canvasError);
|
|
38
|
+
error = canvasError;
|
|
39
|
+
}
|
|
40
|
+
// Use safe defaults for data processing if there are critical errors
|
|
41
|
+
const safeData = data && data.length > 0
|
|
42
|
+
? data
|
|
43
|
+
: [
|
|
44
|
+
{
|
|
45
|
+
[xKey]: LINE_CHART_FALLBACK_DATA.FALLBACK_X_FIRST,
|
|
46
|
+
y: LINE_CHART_FALLBACK_DATA.FALLBACK_Y_FIRST,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
[xKey]: LINE_CHART_FALLBACK_DATA.FALLBACK_X_SECOND,
|
|
50
|
+
y: LINE_CHART_FALLBACK_DATA.FALLBACK_Y_SECOND,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
const safeCanvasWidth = canvasWidth > 0 ? canvasWidth : CHART_CANVAS_DEFAULTS.SAFE_WIDTH;
|
|
54
|
+
const safeCanvasHeight = canvasHeight > 0 ? canvasHeight : CHART_CANVAS_DEFAULTS.SAFE_HEIGHT;
|
|
15
55
|
/**
|
|
16
56
|
* Get the extra spacings for the line chart.
|
|
17
57
|
*/
|
|
18
58
|
const { extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, lineChartXPosition, lineChartYPosition, securityXSpace, securityYSpace, xAxisText, xBreakAxis, xData, yAxisText, yBreakAxis, yData, } = getExtraSpacing({
|
|
19
59
|
ajustedX,
|
|
20
60
|
ajustedY,
|
|
21
|
-
canvasHeight,
|
|
22
|
-
canvasWidth,
|
|
61
|
+
canvasHeight: safeCanvasHeight,
|
|
62
|
+
canvasWidth: safeCanvasWidth,
|
|
23
63
|
children,
|
|
24
|
-
data,
|
|
64
|
+
data: safeData,
|
|
25
65
|
viewBox,
|
|
26
66
|
xKey,
|
|
27
67
|
});
|
|
@@ -32,15 +72,41 @@ export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvas
|
|
|
32
72
|
const yAxisSpace = extraSpaceLeftX + extraSpaceRightX;
|
|
33
73
|
const xTickValues = getXTicks({
|
|
34
74
|
initPos: extraSpaceLeftX,
|
|
35
|
-
maxSpaceAvailable:
|
|
75
|
+
maxSpaceAvailable: safeCanvasWidth,
|
|
36
76
|
otherAxisSpace: yAxisSpace,
|
|
37
77
|
securitySpace: securityXSpace,
|
|
38
78
|
tickValues: xData,
|
|
39
79
|
});
|
|
40
80
|
if ((xTickValues ?? []).some(({ position }) => isNaN(position))) {
|
|
41
|
-
|
|
81
|
+
const xTickError = {
|
|
42
82
|
error: buildError(BuildError.INVALID_X_TICK),
|
|
43
83
|
};
|
|
84
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', xTickError);
|
|
85
|
+
error = xTickError;
|
|
86
|
+
}
|
|
87
|
+
// Validate X-axis tick values
|
|
88
|
+
if (xTickValues) {
|
|
89
|
+
const hasInsufficientTicks = xTickValues.length < AXIS_VALIDATION.MIN_TICK_COUNT;
|
|
90
|
+
const hasIdenticalValues = xTickValues.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
|
|
91
|
+
new Set(xTickValues.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
|
|
92
|
+
if (hasInsufficientTicks) {
|
|
93
|
+
const xAxisError = {
|
|
94
|
+
error: buildError(BuildError.LINE_CHART_X_AXIS_INSUFFICIENT_TICKS),
|
|
95
|
+
};
|
|
96
|
+
addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
|
|
97
|
+
if (!error) {
|
|
98
|
+
error = xAxisError;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (hasIdenticalValues) {
|
|
102
|
+
const xAxisError = {
|
|
103
|
+
error: buildError(BuildError.LINE_CHART_X_AXIS_IDENTICAL_VALUES),
|
|
104
|
+
};
|
|
105
|
+
addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
|
|
106
|
+
if (!error) {
|
|
107
|
+
error = xAxisError;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
44
110
|
}
|
|
45
111
|
/**
|
|
46
112
|
* Calculate the tick values for the Y Axis.
|
|
@@ -48,23 +114,51 @@ export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvas
|
|
|
48
114
|
const crossYAxis = lineChartYPosition !== Positions.LEFT && lineChartYPosition !== Positions.RIGHT;
|
|
49
115
|
const otherAxisSpace = extraSpaceTopY + extraSpaceBottomY;
|
|
50
116
|
const yTickValues = getYTicks({
|
|
51
|
-
initPos:
|
|
52
|
-
maxSpaceAvailable:
|
|
117
|
+
initPos: safeCanvasHeight - extraSpaceBottomY,
|
|
118
|
+
maxSpaceAvailable: safeCanvasHeight,
|
|
53
119
|
otherAxisSpace,
|
|
54
120
|
securitySpace: securityYSpace,
|
|
55
121
|
tickValues: yData,
|
|
56
122
|
});
|
|
123
|
+
// Validate Y-axis tick values
|
|
124
|
+
if (yTickValues) {
|
|
125
|
+
const hasInsufficientTicks = yTickValues.length < AXIS_VALIDATION.MIN_TICK_COUNT;
|
|
126
|
+
const hasIdenticalValues = yTickValues.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
|
|
127
|
+
new Set(yTickValues.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
|
|
128
|
+
if (hasInsufficientTicks) {
|
|
129
|
+
const yAxisError = {
|
|
130
|
+
error: buildError(BuildError.LINE_CHART_Y_AXIS_INSUFFICIENT_TICKS),
|
|
131
|
+
};
|
|
132
|
+
addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
|
|
133
|
+
if (!error) {
|
|
134
|
+
error = yAxisError;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (hasIdenticalValues) {
|
|
138
|
+
const yAxisError = {
|
|
139
|
+
error: buildError(BuildError.LINE_CHART_Y_AXIS_IDENTICAL_VALUES),
|
|
140
|
+
};
|
|
141
|
+
addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
|
|
142
|
+
if (!error) {
|
|
143
|
+
error = yAxisError;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
57
147
|
/**
|
|
58
148
|
* Calculate the custom breakAxis for the X and Y Axis.
|
|
59
149
|
*/
|
|
60
|
-
const customBreakXAxis = crossXAxis
|
|
61
|
-
|
|
150
|
+
const customBreakXAxis = crossXAxis
|
|
151
|
+
? getPoints(yTickValues || [], [String(xBreakAxis)])[0]
|
|
152
|
+
: BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE;
|
|
153
|
+
const customBreakYAxis = crossYAxis
|
|
154
|
+
? getPoints(xTickValues || [], [String(yBreakAxis)])[0]
|
|
155
|
+
: BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE;
|
|
62
156
|
/**
|
|
63
157
|
* Calculate the X coordinates for the line chart.
|
|
64
158
|
*/
|
|
65
159
|
const xCoordinates = getXCoordinates({
|
|
66
|
-
canvasHeight,
|
|
67
|
-
canvasWidth,
|
|
160
|
+
canvasHeight: safeCanvasHeight,
|
|
161
|
+
canvasWidth: safeCanvasWidth,
|
|
68
162
|
customBreakAxis: Number(customBreakXAxis),
|
|
69
163
|
extraSpaceBottomY,
|
|
70
164
|
extraSpaceLeftX,
|
|
@@ -77,8 +171,8 @@ export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvas
|
|
|
77
171
|
* Calculate the Y coordinates for the line chart.
|
|
78
172
|
*/
|
|
79
173
|
const yCoordinates = getYCoordinates({
|
|
80
|
-
canvasHeight,
|
|
81
|
-
canvasWidth,
|
|
174
|
+
canvasHeight: safeCanvasHeight,
|
|
175
|
+
canvasWidth: safeCanvasWidth,
|
|
82
176
|
customBreakAxis: Number(customBreakYAxis),
|
|
83
177
|
extraSpaceBottomY,
|
|
84
178
|
extraSpaceLeftX,
|
|
@@ -87,37 +181,27 @@ export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvas
|
|
|
87
181
|
position: lineChartYPosition,
|
|
88
182
|
securityYSpace,
|
|
89
183
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
coordinates: xCoordinates,
|
|
104
|
-
tickValues: [
|
|
105
|
-
{ position: 0, value: '0' },
|
|
106
|
-
{ position: canvasWidth, value: '1' },
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
xAxisText,
|
|
110
|
-
yAxisCoordinates: {
|
|
111
|
-
coordinates: yCoordinates,
|
|
112
|
-
tickValues: [
|
|
113
|
-
{ position: canvasHeight, value: '0' },
|
|
114
|
-
{ position: 0, value: '1' },
|
|
115
|
-
],
|
|
116
|
-
},
|
|
117
|
-
yAxisText,
|
|
184
|
+
// Validate axis coordinates for zero-length axes
|
|
185
|
+
if (xCoordinates.x1 === xCoordinates.x2) {
|
|
186
|
+
const xAxisError = {
|
|
187
|
+
error: buildError(BuildError.LINE_CHART_X_AXIS_ZERO_LENGTH),
|
|
188
|
+
};
|
|
189
|
+
addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
|
|
190
|
+
if (!error) {
|
|
191
|
+
error = xAxisError;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (yCoordinates.y1 === yCoordinates.y2) {
|
|
195
|
+
const yAxisError = {
|
|
196
|
+
error: buildError(BuildError.LINE_CHART_Y_AXIS_ZERO_LENGTH),
|
|
118
197
|
};
|
|
198
|
+
addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
|
|
199
|
+
if (!error) {
|
|
200
|
+
error = yAxisError;
|
|
201
|
+
}
|
|
119
202
|
}
|
|
120
|
-
|
|
203
|
+
const baseContext = {
|
|
204
|
+
addError,
|
|
121
205
|
crossXAxis,
|
|
122
206
|
crossYAxis,
|
|
123
207
|
extraSpaceBottomY,
|
|
@@ -126,9 +210,41 @@ export const buildLineContextValue = ({ ajustedX, ajustedY, canvasHeight, canvas
|
|
|
126
210
|
extraSpaceTopY,
|
|
127
211
|
securityXSpace,
|
|
128
212
|
securityYSpace,
|
|
129
|
-
xAxisCoordinates: {
|
|
213
|
+
xAxisCoordinates: {
|
|
214
|
+
coordinates: xCoordinates,
|
|
215
|
+
tickValues: xTickValues ||
|
|
216
|
+
(error
|
|
217
|
+
? [
|
|
218
|
+
{
|
|
219
|
+
position: BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE,
|
|
220
|
+
value: LINE_CHART_FALLBACK_DATA.FALLBACK_X_FIRST,
|
|
221
|
+
},
|
|
222
|
+
{ position: safeCanvasWidth, value: LINE_CHART_FALLBACK_DATA.FALLBACK_X_SECOND },
|
|
223
|
+
]
|
|
224
|
+
: []),
|
|
225
|
+
},
|
|
130
226
|
xAxisText,
|
|
131
|
-
yAxisCoordinates: {
|
|
227
|
+
yAxisCoordinates: {
|
|
228
|
+
coordinates: yCoordinates,
|
|
229
|
+
tickValues: yTickValues ||
|
|
230
|
+
(error
|
|
231
|
+
? [
|
|
232
|
+
{ position: safeCanvasHeight, value: SHARED_FALLBACK_DATA.FALLBACK_PKEY_FIRST },
|
|
233
|
+
{
|
|
234
|
+
position: BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE,
|
|
235
|
+
value: SHARED_FALLBACK_DATA.FALLBACK_PKEY_SECOND,
|
|
236
|
+
},
|
|
237
|
+
]
|
|
238
|
+
: []),
|
|
239
|
+
},
|
|
132
240
|
yAxisText,
|
|
133
241
|
};
|
|
242
|
+
// Add error only if it exists
|
|
243
|
+
if (error) {
|
|
244
|
+
return {
|
|
245
|
+
...baseContext,
|
|
246
|
+
error: { ...error, type: ErrorType.LINE_CHART_CONTEXT_ERROR },
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return baseContext;
|
|
134
250
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextData.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/lineChart/fragments/fixture/contextData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"contextData.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/lineChart/fragments/fixture/contextData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;oBAyBA,QAAQ,EAAE;;;;;;;;;;;;oBAWV,QAAQ,EAAE;;;;CAI7B,CAAC"}
|
|
@@ -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;
|
|
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,CAwLhD,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { useContext, useEffect, useRef } from 'react';
|
|
|
3
3
|
import { Line } from '../../../components/line/line';
|
|
4
4
|
import { Node } from '../../../components/node/node';
|
|
5
5
|
import { Path } from '../../../components/path/path';
|
|
6
|
+
import { BuildError, buildDataKeyNotFoundError, buildError } from '../../../utils/buildErrors/buildErrors';
|
|
6
7
|
import { getPoints } from '../../../utils/getPoints/getPoints';
|
|
7
8
|
import { pickCustomAttributes } from '../../../utils/pickCustomAttributes/pickCustomAttributes';
|
|
8
9
|
import { LineChartContext } from '../context/lineChartContext';
|
|
@@ -17,7 +18,39 @@ const getAxisData = (data, key) => {
|
|
|
17
18
|
};
|
|
18
19
|
export const LineChartPath = ({ ariaLabel, closestClick, curved, getNodeFocusInfo, getNodesCoords, indicatorConfig, lineProjection, onClick, ...props }) => {
|
|
19
20
|
// recovery the context values
|
|
20
|
-
const { xAxisCoordinates, yAxisCoordinates, ...context } = useContext(LineChartContext);
|
|
21
|
+
const { addError, xAxisCoordinates, yAxisCoordinates, ...context } = useContext(LineChartContext);
|
|
22
|
+
// Path error validations
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
// Invalid dataKey validation
|
|
25
|
+
if (!props.dataKey || typeof props.dataKey !== 'string') {
|
|
26
|
+
addError?.('LINE_CHART_PATH_ERROR', {
|
|
27
|
+
error: buildError(BuildError.LINE_CHART_PATH_INVALID_DATAKEY),
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Check if dataKey exists in dataset
|
|
32
|
+
if (context.data.length > 0 &&
|
|
33
|
+
!Object.prototype.hasOwnProperty.call(context.data[0], props.dataKey)) {
|
|
34
|
+
addError?.('LINE_CHART_PATH_ERROR', {
|
|
35
|
+
error: buildDataKeyNotFoundError(props.dataKey),
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Curved path calculation errors
|
|
40
|
+
if (curved && context.data.length < 2) {
|
|
41
|
+
addError?.('LINE_CHART_PATH_ERROR', {
|
|
42
|
+
error: buildError(BuildError.LINE_CHART_PATH_INSUFFICIENT_POINTS),
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Path rendering errors - validate coordinates
|
|
47
|
+
const yData = getAxisData(context.data, props.dataKey);
|
|
48
|
+
if (yData.length > 0 && yData.every(val => val === null || val === undefined)) {
|
|
49
|
+
addError?.('LINE_CHART_PATH_ERROR', {
|
|
50
|
+
error: buildError(BuildError.LINE_CHART_PATH_ALL_VALUES_NULL),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [props.dataKey, curved, context.data, addError]);
|
|
21
54
|
// the node indicator logic
|
|
22
55
|
const { indicatorRef, pathRef } = useIndicator(context.xCursor, !!indicatorConfig);
|
|
23
56
|
const showIndicator = !!indicatorConfig && context.xCursor !== -Infinity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineChartProjection.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/fragments/lineChartProjection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
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,CA4E5D,CAAC"}
|
|
@@ -1,12 +1,56 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect } from 'react';
|
|
3
|
+
import { buildProjectionBoundsError, buildProjectionXOutOfRangeError, buildProjectionYOutOfRangeError, } from '../../../utils/buildErrors/charts/buildLineChartErrors';
|
|
4
|
+
import { LineChartContext } from '../context/lineChartContext';
|
|
2
5
|
import { getProjection } from '../utils/getProjection';
|
|
3
6
|
import './lineChartPath.css';
|
|
4
7
|
export const LineChartProjection = ({ curved, lineProjection, points, svgHeight, }) => {
|
|
8
|
+
const { addError } = useContext(LineChartContext);
|
|
5
9
|
const { lower, shapeColor, upper } = lineProjection;
|
|
6
10
|
const { xProjection: xUp, yProjection: yUp, ...upperProps } = upper || {};
|
|
7
11
|
const { xProjection: xDw, yProjection: yDw, ...lowerProps } = lower || {};
|
|
8
12
|
const upperProjection = xUp || yUp ? { x: xUp, y: yUp } : undefined;
|
|
9
13
|
const lowerProjection = xDw || yDw ? { x: xDw, y: yDw } : undefined;
|
|
14
|
+
// Projection error validations
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
// Invalid projection bounds - upper/lower overlap
|
|
17
|
+
if (upperProjection && lowerProjection) {
|
|
18
|
+
const upperY = upperProjection.y || 0;
|
|
19
|
+
const lowerY = lowerProjection.y || 0;
|
|
20
|
+
if (upperY >= lowerY) {
|
|
21
|
+
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
22
|
+
error: buildProjectionBoundsError(upperY, lowerY),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Projection coordinates outside chart area
|
|
27
|
+
if (upperProjection) {
|
|
28
|
+
const { x: upperX, y: upperY } = upperProjection;
|
|
29
|
+
if (upperX !== undefined && (upperX < 0 || upperX > 100)) {
|
|
30
|
+
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
31
|
+
error: buildProjectionXOutOfRangeError(upperX, true),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (upperY !== undefined && (upperY < 0 || upperY > svgHeight)) {
|
|
35
|
+
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
36
|
+
error: buildProjectionYOutOfRangeError(upperY, svgHeight, true),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (lowerProjection) {
|
|
41
|
+
const { x: lowerX, y: lowerY } = lowerProjection;
|
|
42
|
+
if (lowerX !== undefined && (lowerX < 0 || lowerX > 100)) {
|
|
43
|
+
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
44
|
+
error: buildProjectionXOutOfRangeError(lowerX, false),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (lowerY !== undefined && (lowerY < 0 || lowerY > svgHeight)) {
|
|
48
|
+
addError?.('LINE_CHART_PROJECTION_ERROR', {
|
|
49
|
+
error: buildProjectionYOutOfRangeError(lowerY, svgHeight, false),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [upperProjection, lowerProjection, svgHeight, addError]);
|
|
10
54
|
const { downPath, shapePath, upPath } = getProjection({
|
|
11
55
|
curved,
|
|
12
56
|
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,
|
|
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,CA0F1D,CAAC"}
|