@kubit-ui-web/react-charts 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
  2. package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  3. package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +64 -128
  4. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
  5. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  6. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +8 -6
  7. package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +3 -3
  8. package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
  9. package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.js +3 -8
  10. package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
  11. package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.js +9 -9
  12. package/dist/cjs/charts/lineChart/lineChart.type.d.ts +12 -7
  13. package/dist/cjs/charts/lineChart/lineChart.type.d.ts.map +1 -1
  14. package/dist/cjs/charts/lineChart/lineChartStructure.js +11 -10
  15. package/dist/cjs/charts/lineChart/utils/getCoordinates.d.ts +25 -0
  16. package/dist/cjs/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
  17. package/dist/cjs/charts/lineChart/utils/getCoordinates.js +55 -0
  18. package/dist/cjs/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
  19. package/dist/cjs/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
  20. package/dist/cjs/charts/lineChart/utils/getExtraSpacing.js +68 -51
  21. package/dist/cjs/charts/lineChart/utils/getTicks.d.ts +21 -0
  22. package/dist/cjs/charts/lineChart/utils/getTicks.d.ts.map +1 -0
  23. package/dist/cjs/charts/lineChart/utils/getTicks.js +36 -0
  24. package/dist/cjs/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
  25. package/dist/cjs/charts/lineChart/utils/handleNodesFocus.js +14 -25
  26. package/dist/cjs/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
  27. package/dist/cjs/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
  28. package/dist/cjs/charts/lineChart/utils/tickTextPosition.js +109 -0
  29. package/dist/cjs/charts/lineChart/utils/validations.d.ts +54 -0
  30. package/dist/cjs/charts/lineChart/utils/validations.d.ts.map +1 -0
  31. package/dist/cjs/charts/lineChart/utils/validations.js +117 -0
  32. package/dist/cjs/components/chartText/chartText.d.ts.map +1 -1
  33. package/dist/cjs/components/chartText/chartText.js +2 -2
  34. package/dist/cjs/components/line/line.d.ts.map +1 -1
  35. package/dist/cjs/components/line/line.js +2 -2
  36. package/dist/cjs/components/line/line.types.d.ts +2 -0
  37. package/dist/cjs/components/line/line.types.d.ts.map +1 -1
  38. package/dist/cjs/components/node/node.d.ts.map +1 -1
  39. package/dist/cjs/components/node/node.js +1 -1
  40. package/dist/cjs/components/node/node.types.d.ts +2 -0
  41. package/dist/cjs/components/node/node.types.d.ts.map +1 -1
  42. package/dist/cjs/components/path/path.js +1 -1
  43. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
  44. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
  45. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
  46. package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
  47. package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  48. package/dist/esm/charts/lineChart/context/buildLineContextValue.js +64 -128
  49. package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
  50. package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  51. package/dist/esm/charts/lineChart/fragments/fixture/contextData.js +8 -6
  52. package/dist/esm/charts/lineChart/fragments/lineChartPath.js +3 -3
  53. package/dist/esm/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
  54. package/dist/esm/charts/lineChart/fragments/lineChartXAxis.js +3 -8
  55. package/dist/esm/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
  56. package/dist/esm/charts/lineChart/fragments/lineChartYAxis.js +9 -9
  57. package/dist/esm/charts/lineChart/lineChart.type.d.ts +12 -7
  58. package/dist/esm/charts/lineChart/lineChart.type.d.ts.map +1 -1
  59. package/dist/esm/charts/lineChart/lineChartStructure.js +11 -10
  60. package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts +25 -0
  61. package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
  62. package/dist/esm/charts/lineChart/utils/getCoordinates.js +55 -0
  63. package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
  64. package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
  65. package/dist/esm/charts/lineChart/utils/getExtraSpacing.js +68 -51
  66. package/dist/esm/charts/lineChart/utils/getTicks.d.ts +21 -0
  67. package/dist/esm/charts/lineChart/utils/getTicks.d.ts.map +1 -0
  68. package/dist/esm/charts/lineChart/utils/getTicks.js +36 -0
  69. package/dist/esm/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
  70. package/dist/esm/charts/lineChart/utils/handleNodesFocus.js +14 -25
  71. package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
  72. package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
  73. package/dist/esm/charts/lineChart/utils/tickTextPosition.js +109 -0
  74. package/dist/esm/charts/lineChart/utils/validations.d.ts +54 -0
  75. package/dist/esm/charts/lineChart/utils/validations.d.ts.map +1 -0
  76. package/dist/esm/charts/lineChart/utils/validations.js +117 -0
  77. package/dist/esm/components/chartText/chartText.d.ts.map +1 -1
  78. package/dist/esm/components/chartText/chartText.js +2 -2
  79. package/dist/esm/components/line/line.d.ts.map +1 -1
  80. package/dist/esm/components/line/line.js +2 -2
  81. package/dist/esm/components/line/line.types.d.ts +2 -0
  82. package/dist/esm/components/line/line.types.d.ts.map +1 -1
  83. package/dist/esm/components/node/node.d.ts.map +1 -1
  84. package/dist/esm/components/node/node.js +1 -1
  85. package/dist/esm/components/node/node.types.d.ts +2 -0
  86. package/dist/esm/components/node/node.types.d.ts.map +1 -1
  87. package/dist/esm/components/path/path.js +1 -1
  88. package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
  89. package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
  90. package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
  91. package/dist/kubit-ui-web-react-charts.cjs.js +1 -1
  92. package/dist/kubit-ui-web-react-charts.es.js +1 -1
  93. package/dist/kubit-ui-web-react-charts.umd.js +1 -1
  94. package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
  95. package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  96. package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
  97. package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  98. package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
  99. package/dist/types/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
  100. package/dist/types/charts/lineChart/lineChart.type.d.ts +12 -7
  101. package/dist/types/charts/lineChart/lineChart.type.d.ts.map +1 -1
  102. package/dist/types/charts/lineChart/utils/getCoordinates.d.ts +25 -0
  103. package/dist/types/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
  104. package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
  105. package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
  106. package/dist/types/charts/lineChart/utils/getTicks.d.ts +21 -0
  107. package/dist/types/charts/lineChart/utils/getTicks.d.ts.map +1 -0
  108. package/dist/types/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
  109. package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
  110. package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
  111. package/dist/types/charts/lineChart/utils/validations.d.ts +54 -0
  112. package/dist/types/charts/lineChart/utils/validations.d.ts.map +1 -0
  113. package/dist/types/components/chartText/chartText.d.ts.map +1 -1
  114. package/dist/types/components/line/line.d.ts.map +1 -1
  115. package/dist/types/components/line/line.types.d.ts +2 -0
  116. package/dist/types/components/line/line.types.d.ts.map +1 -1
  117. package/dist/types/components/node/node.d.ts.map +1 -1
  118. package/dist/types/components/node/node.types.d.ts +2 -0
  119. package/dist/types/components/node/node.types.d.ts.map +1 -1
  120. package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
  121. package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
  122. package/package.json +1 -1
@@ -0,0 +1,117 @@
1
+ import { BuildError, buildCanvasDimensionsError, buildError, } from '../../../utils/buildErrors/buildErrors';
2
+ import { AXIS_VALIDATION } from '../../constants/chartDefaults';
3
+ export const validateData = ({ data, addError }) => {
4
+ let error = undefined;
5
+ if (!data || data.length === 0) {
6
+ const dataError = {
7
+ error: buildError(BuildError.LINE_CHART_NO_DATA),
8
+ };
9
+ addError?.('LINE_CHART_CONTEXT_ERROR', dataError);
10
+ error = dataError;
11
+ }
12
+ if (data && data.length === 1) {
13
+ const singlePointError = {
14
+ error: buildError(BuildError.LINE_CHART_SINGLE_POINT),
15
+ };
16
+ addError?.('LINE_CHART_CONTEXT_ERROR', singlePointError);
17
+ error = singlePointError;
18
+ }
19
+ return { error };
20
+ };
21
+ export const validateCanvasDimensions = ({ canvasWidth, canvasHeight, addError, }) => {
22
+ let error = undefined;
23
+ if (canvasWidth <= 0 || canvasHeight <= 0) {
24
+ const canvasError = {
25
+ error: buildCanvasDimensionsError(canvasWidth, canvasHeight),
26
+ };
27
+ addError?.('LINE_CHART_CONTEXT_ERROR', canvasError);
28
+ error = canvasError;
29
+ }
30
+ return { error };
31
+ };
32
+ export const validateYTickValues = ({ yTickValues, addError }) => {
33
+ let error = undefined;
34
+ if (yTickValues) {
35
+ const hasInsufficientTicks = yTickValues.length < AXIS_VALIDATION.MIN_TICK_COUNT;
36
+ const hasIdenticalValues = yTickValues.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
37
+ new Set(yTickValues.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
38
+ if (hasInsufficientTicks) {
39
+ const yAxisError = {
40
+ error: buildError(BuildError.LINE_CHART_Y_AXIS_INSUFFICIENT_TICKS),
41
+ };
42
+ addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
43
+ if (!error) {
44
+ error = yAxisError;
45
+ }
46
+ }
47
+ if (hasIdenticalValues) {
48
+ const yAxisError = {
49
+ error: buildError(BuildError.LINE_CHART_Y_AXIS_IDENTICAL_VALUES),
50
+ };
51
+ addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
52
+ if (!error) {
53
+ error = yAxisError;
54
+ }
55
+ }
56
+ }
57
+ return { error };
58
+ };
59
+ export const validateXTickValues = ({ xTickValues, addError }) => {
60
+ let error = undefined;
61
+ // Validate X-axis tick values
62
+ if (xTickValues) {
63
+ if ((xTickValues ?? []).some(({ position }) => isNaN(position))) {
64
+ const xTickError = {
65
+ error: buildError(BuildError.INVALID_X_TICK),
66
+ };
67
+ addError?.('LINE_CHART_CONTEXT_ERROR', xTickError);
68
+ error = xTickError;
69
+ }
70
+ const hasInsufficientTicks = xTickValues.length < AXIS_VALIDATION.MIN_TICK_COUNT;
71
+ const hasIdenticalValues = xTickValues.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
72
+ new Set(xTickValues.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
73
+ if (hasInsufficientTicks) {
74
+ const xAxisError = {
75
+ error: buildError(BuildError.LINE_CHART_X_AXIS_INSUFFICIENT_TICKS),
76
+ };
77
+ addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
78
+ if (!error) {
79
+ error = xAxisError;
80
+ }
81
+ }
82
+ if (hasIdenticalValues) {
83
+ const xAxisError = {
84
+ error: buildError(BuildError.LINE_CHART_X_AXIS_IDENTICAL_VALUES),
85
+ };
86
+ addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
87
+ if (!error) {
88
+ error = xAxisError;
89
+ }
90
+ }
91
+ }
92
+ return { error };
93
+ };
94
+ export const validateXCoordinates = ({ xCoordinates, addError }) => {
95
+ let error = undefined;
96
+ if (xCoordinates.x1 === xCoordinates.x2) {
97
+ const xAxisError = {
98
+ error: buildError(BuildError.LINE_CHART_X_AXIS_ZERO_LENGTH),
99
+ };
100
+ addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
101
+ error = xAxisError;
102
+ }
103
+ return { error };
104
+ };
105
+ export const validateYCoordinates = ({ yCoordinates, addError }) => {
106
+ let error = undefined;
107
+ if (yCoordinates.y1 === yCoordinates.y2) {
108
+ const yAxisError = {
109
+ error: buildError(BuildError.LINE_CHART_Y_AXIS_ZERO_LENGTH),
110
+ };
111
+ addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
112
+ if (!error) {
113
+ error = yAxisError;
114
+ }
115
+ }
116
+ return { error };
117
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"chartText.d.ts","sourceRoot":"","sources":["../../../../src/components/chartText/chartText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAWxC,CAAC"}
1
+ {"version":3,"file":"chartText.d.ts","sourceRoot":"","sources":["../../../../src/components/chartText/chartText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAMxC,CAAC"}
@@ -13,6 +13,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  * @param {React.ReactNode} props.children - The text content to be rendered within the `<text>` element.
14
14
  * @returns {React.ReactElement} A React element representing the SVG text.
15
15
  */
16
- export const ChartText = ({ children, className = 'circle', tabIndex = -1, ...props }) => {
17
- return (_jsx("text", { className: className, tabIndex: tabIndex, ...props, children: children }));
16
+ export const ChartText = ({ children, className = 'circle', ...props }) => {
17
+ return (_jsx("text", { className: className, ...props, children: children }));
18
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/components/line/line.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAgB9B,CAAC"}
1
+ {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/components/line/line.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAE9B,CAAC"}
@@ -4,6 +4,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  *
5
5
  * @returns A `line` SVG element with the specified properties and attributes.
6
6
  */
7
- export const Line = ({ ariaLabel = '', className = 'line', dataTestId, tabIndex = -1, ...props }) => {
8
- return (_jsx("line", { ...props, "aria-label": ariaLabel, className: className, "data-testid": dataTestId, tabIndex: tabIndex }));
7
+ export const Line = ({ ariaLabel, className = 'line', dataTestId, ...props }) => {
8
+ return _jsx("line", { ...props, "aria-label": ariaLabel, className: className, "data-testid": dataTestId });
9
9
  };
@@ -1,3 +1,4 @@
1
+ import type { HTMLAttributes } from 'react';
1
2
  /**
2
3
  * Props for the `Line` component, defining the visual appearance and behavior of a line element.
3
4
  *
@@ -38,6 +39,7 @@ export interface LineProps {
38
39
  className?: string;
39
40
  tabIndex?: number;
40
41
  ariaLabel?: string;
42
+ role?: HTMLAttributes<SVGElement>['role'];
41
43
  dataTestId?: string;
42
44
  }
43
45
  //# sourceMappingURL=line.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"line.types.d.ts","sourceRoot":"","sources":["../../../../src/components/line/line.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa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
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/components/node/node.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,cAAc,CAAC;AA4IxD,eAAO,MAAM,IAAI,EAAgC,CAC/C,KAAK,EAAE,SAAS,GAAG;IACjB,GAAG,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;CACnC,KACE,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/components/node/node.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,cAAc,CAAC;AA2IxD,eAAO,MAAM,IAAI,EAAgC,CAC/C,KAAK,EAAE,SAAS,GAAG;IACjB,GAAG,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;CACnC,KACE,GAAG,CAAC,OAAO,CAAC"}
@@ -93,6 +93,6 @@ const NodeComponent = ({ dataTestId = 'node', haloConfig, hasHalo = false, onBlu
93
93
  strokeWidth: haloConfig?.strokeWidth || props.strokeWidth,
94
94
  };
95
95
  const InnerNode = Component[type];
96
- return (_jsxs(_Fragment, { children: [hasHalo && (_jsx(InnerNode, { ...haloProps, "aria-hidden": "true", dataTestId: `${dataTestId}-halo`, position: position, size: size + size / 2, tabIndex: -1 })), _jsx(InnerNode, { ...nodeProps, ref: clickRef, dataTestId: dataTestId, position: position, size: size })] }));
96
+ return (_jsxs(_Fragment, { children: [hasHalo && (_jsx(InnerNode, { ...haloProps, "aria-hidden": "true", dataTestId: `${dataTestId}-halo`, position: position, size: size + size / 2 })), _jsx(InnerNode, { ...nodeProps, ref: clickRef, dataTestId: dataTestId, position: position, size: size })] }));
97
97
  };
98
98
  export const Node = forwardRef(NodeComponent);
@@ -1,3 +1,4 @@
1
+ import type { HTMLAttributes } from 'react';
1
2
  /**
2
3
  * Enum for node types.
3
4
  *
@@ -61,6 +62,7 @@ export interface NodeProps {
61
62
  y: number;
62
63
  };
63
64
  };
65
+ role?: HTMLAttributes<SVGElement>['role'];
64
66
  onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, data?: {
65
67
  index?: number;
66
68
  dataValue?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"node.types.d.ts","sourceRoot":"","sources":["../../../../src/components/node/node.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;;;;;;;;CAQX,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CA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,CAAC;QAAC,SAAS,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KACxE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;CAC9E"}
@@ -100,7 +100,7 @@ const PathComponent = ({ classNames = '', fill = 'transparent', stroke = '#0000F
100
100
  ...(isFocused && focusConfig),
101
101
  ...(isHovered && hoverConfig),
102
102
  };
103
- return (_jsxs("g", { ref: mainRef, tabIndex: -1, children: [gradientSvgElement && gradientSvgElement, mergedProps.shadowSvgConfig && (_jsx(ShadowSvg, { id: SHADOW_FILTER_ID, shadowSvgConfig: mergedProps.shadowSvgConfig })), _jsxs("g", { "aria-label": mergedProps.ariaLabel, className: mergedProps.classNames, "data-draw": true, filter: mergedProps.shadowSvgConfig && mergedProps.filter, opacity: mergedProps.opacity, orientation: mergedProps.orientation, role: mergedProps.role, rotate: mergedProps.rotate, tabIndex: mergedProps.tabIndex, transform: mergedProps.transform, visibility: mergedProps.visibility, ...customAttributes, onBlur: handleBlur, onClick: handleClick, onDoubleClick: handleDoubleClick, onFocus: handleFocus, onKeyDown: handleKeyDown, onMouseDown: handleMouseDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [_jsx("path", { ref: pathRef, d: mergedProps.d, "data-testid": mergedProps.dataTestId, fill: mergedProps.dFill ? 'transparent' : mergedProps.fill, fillOpacity: mergedProps.fillOpacity, fillRule: mergedProps.fillRule, stroke: mergedProps.stroke, strokeDasharray: mergedProps.strokeDasharray, strokeDashoffset: mergedProps.strokeDashoffset, strokeLinecap: mergedProps.strokeLinecap, strokeLinejoin: mergedProps.strokeLinejoin, strokeMiterlimit: mergedProps.strokeMiterlimit, strokeOpacity: mergedProps.strokeOpacity, strokeWidth: mergedProps.strokeWidth, children: mergedProps.title && _jsx("title", { children: mergedProps.title }) }), mergedProps.dFill && (_jsx("path", { d: mergedProps.dFill, fill: mergedProps.fill, fillOpacity: mergedProps.fillOpacity, fillRule: mergedProps.fillRule }))] }), mergedProps.points &&
103
+ return (_jsxs("g", { ref: mainRef, children: [gradientSvgElement && gradientSvgElement, mergedProps.shadowSvgConfig && (_jsx(ShadowSvg, { id: SHADOW_FILTER_ID, shadowSvgConfig: mergedProps.shadowSvgConfig })), _jsxs("g", { "aria-label": mergedProps.ariaLabel, className: mergedProps.classNames, "data-draw": true, filter: mergedProps.shadowSvgConfig && mergedProps.filter, opacity: mergedProps.opacity, orientation: mergedProps.orientation, role: mergedProps.role, rotate: mergedProps.rotate, tabIndex: mergedProps.tabIndex, transform: mergedProps.transform, visibility: mergedProps.visibility, ...customAttributes, onBlur: handleBlur, onClick: handleClick, onDoubleClick: handleDoubleClick, onFocus: handleFocus, onKeyDown: handleKeyDown, onMouseDown: handleMouseDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [_jsx("path", { ref: pathRef, d: mergedProps.d, "data-testid": mergedProps.dataTestId, fill: mergedProps.dFill ? 'transparent' : mergedProps.fill, fillOpacity: mergedProps.fillOpacity, fillRule: mergedProps.fillRule, stroke: mergedProps.stroke, strokeDasharray: mergedProps.strokeDasharray, strokeDashoffset: mergedProps.strokeDashoffset, strokeLinecap: mergedProps.strokeLinecap, strokeLinejoin: mergedProps.strokeLinejoin, strokeMiterlimit: mergedProps.strokeMiterlimit, strokeOpacity: mergedProps.strokeOpacity, strokeWidth: mergedProps.strokeWidth, children: mergedProps.title && _jsx("title", { children: mergedProps.title }) }), mergedProps.dFill && (_jsx("path", { d: mergedProps.dFill, fill: mergedProps.fill, fillOpacity: mergedProps.fillOpacity, fillRule: mergedProps.fillRule }))] }), mergedProps.points &&
104
104
  mergedProps.nodeConfig &&
105
105
  mergedProps.points.map(([x, y], index) => {
106
106
  const nodeData = {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Filters and extracts only aria-* and data-* attributes from a given object,
2
+ * Filters and extracts only aria-*, data-* and role attributes from a given object,
3
3
  * converting all values to strings for HTML compatibility.
4
4
  *
5
5
  * This function is useful for extracting accessibility and data attributes
@@ -10,8 +10,8 @@
10
10
  * - Keys can be strings representing attribute names.
11
11
  * - Values can be strings, booleans, numbers, or any other type.
12
12
  *
13
- * @returns A new object containing only aria-* and data-* attributes:
14
- * - Only includes attributes that start with `aria-` or `data-`.
13
+ * @returns A new object containing only aria-*, data-* and role attributes:
14
+ * - Only includes attributes that start with `aria-` or `data-` or are exactly `role`.
15
15
  * - All values are converted to strings for HTML compatibility.
16
16
  * - Null and undefined values are excluded.
17
17
  *
@@ -20,13 +20,14 @@
20
20
  * const props = {
21
21
  * 'aria-label': 'Button',
22
22
  * 'data-testid': 'my-button',
23
- * 'onClick': () => {},
23
+ * 'onClick': () => {},g
24
24
  * 'className': 'btn',
25
- * 'aria-hidden': true
25
+ * 'aria-hidden': true,
26
+ * 'role': 'button',
26
27
  * };
27
28
  *
28
29
  * const result = pickCustomAttributes(props);
29
- * // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true' }
30
+ * // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true', 'role': 'button' }
30
31
  * ```
31
32
  */
32
33
  export declare const pickCustomAttributes: (attributes?: Record<string, any>) => Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"pickCustomAttributes.d.ts","sourceRoot":"","sources":["../../../../src/utils/pickCustomAttributes/pickCustomAttributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,oBAAoB,GAE/B,aAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAkBvB,CAAC"}
1
+ {"version":3,"file":"pickCustomAttributes.d.ts","sourceRoot":"","sources":["../../../../src/utils/pickCustomAttributes/pickCustomAttributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,oBAAoB,GAE/B,aAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAkBvB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Filters and extracts only aria-* and data-* attributes from a given object,
2
+ * Filters and extracts only aria-*, data-* and role attributes from a given object,
3
3
  * converting all values to strings for HTML compatibility.
4
4
  *
5
5
  * This function is useful for extracting accessibility and data attributes
@@ -10,8 +10,8 @@
10
10
  * - Keys can be strings representing attribute names.
11
11
  * - Values can be strings, booleans, numbers, or any other type.
12
12
  *
13
- * @returns A new object containing only aria-* and data-* attributes:
14
- * - Only includes attributes that start with `aria-` or `data-`.
13
+ * @returns A new object containing only aria-*, data-* and role attributes:
14
+ * - Only includes attributes that start with `aria-` or `data-` or are exactly `role`.
15
15
  * - All values are converted to strings for HTML compatibility.
16
16
  * - Null and undefined values are excluded.
17
17
  *
@@ -20,13 +20,14 @@
20
20
  * const props = {
21
21
  * 'aria-label': 'Button',
22
22
  * 'data-testid': 'my-button',
23
- * 'onClick': () => {},
23
+ * 'onClick': () => {},g
24
24
  * 'className': 'btn',
25
- * 'aria-hidden': true
25
+ * 'aria-hidden': true,
26
+ * 'role': 'button',
26
27
  * };
27
28
  *
28
29
  * const result = pickCustomAttributes(props);
29
- * // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true' }
30
+ * // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true', 'role': 'button' }
30
31
  * ```
31
32
  */
32
33
  export const pickCustomAttributes = (
@@ -36,7 +37,7 @@ attributes) => {
36
37
  return {};
37
38
  }
38
39
  return Object.entries(attributes).reduce((acc, [key, value]) => {
39
- if ((key.startsWith('aria-') || key.startsWith('data-')) &&
40
+ if ((key.startsWith('aria-') || key.startsWith('data-') || key === 'role') &&
40
41
  value !== null &&
41
42
  value !== undefined) {
42
43
  acc[key] = String(value);
@@ -4,8 +4,6 @@ interface BuildContextValue {
4
4
  children: ChildrenType;
5
5
  data: IDataPoint[];
6
6
  xKey: string;
7
- ajustedX: number;
8
- ajustedY: number;
9
7
  canvasHeight: number;
10
8
  canvasWidth: number;
11
9
  viewBox: string;
@@ -18,6 +16,6 @@ type OmitProps = 'data' | 'xKey' | 'canvasHeight' | 'canvasWidth' | 'canvasExtra
18
16
  * @param {BuildContextValue} options - The options for building the context value.
19
17
  * @returns {LineContextValue} - The built context value.
20
18
  */
21
- export declare const buildLineContextValue: ({ addError, ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }: BuildContextValue) => Omit<LineChartContextType, OmitProps>;
19
+ export declare const buildLineContextValue: ({ addError, canvasHeight, canvasWidth, children, data, viewBox, xKey, }: BuildContextValue) => Omit<LineChartContextType, OmitProps>;
22
20
  export {};
23
21
  //# sourceMappingURL=buildLineContextValue.d.ts.map
@@ -1 +1 @@
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
+ {"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;AAUjE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAaxF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,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,yEAQnC,iBAAiB,KAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAkN1D,CAAC"}
@@ -1,40 +1,29 @@
1
1
  import { ErrorType } from '../../../types/errors.type';
2
2
  import { Positions } from '../../../types/position.enum';
3
- import { BuildError, buildCanvasDimensionsError, buildError, } from '../../../utils/buildErrors/buildErrors';
4
- import { getXCoordinates, getYCoordinates } from '../../../utils/getCoordinates/getCoordinates';
5
3
  import { getPoints } from '../../../utils/getPoints/getPoints';
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';
4
+ import { BREAK_AXIS_DEFAULTS, CHART_CANVAS_DEFAULTS, LINE_CHART_FALLBACK_DATA, SHARED_FALLBACK_DATA, } from '../../constants/chartDefaults';
5
+ import { getXCoordinates, getYCoordinates } from '../utils/getCoordinates';
8
6
  import { getExtraSpacing } from '../utils/getExtraSpacing';
7
+ import { getXTicks, getYTicks } from '../utils/getTicks';
8
+ import { validateCanvasDimensions, validateData, validateXCoordinates, validateXTickValues, validateYCoordinates, validateYTickValues, } from '../utils/validations';
9
9
  /**
10
10
  * Builds the context value for the line chart.
11
11
  *
12
12
  * @param {BuildContextValue} options - The options for building the context value.
13
13
  * @returns {LineContextValue} - The built context value.
14
14
  */
15
- export const buildLineContextValue = ({ addError, ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
15
+ export const buildLineContextValue = ({ addError, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
16
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);
17
+ const { error: dataError } = validateData({ data, addError });
18
+ if (dataError) {
23
19
  error = dataError;
24
20
  }
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);
21
+ const { error: canvasError } = validateCanvasDimensions({
22
+ canvasWidth,
23
+ canvasHeight,
24
+ addError,
25
+ });
26
+ if (canvasError) {
38
27
  error = canvasError;
39
28
  }
40
29
  // Use safe defaults for data processing if there are critical errors
@@ -55,9 +44,7 @@ export const buildLineContextValue = ({ addError, ajustedX, ajustedY, canvasHeig
55
44
  /**
56
45
  * Get the extra spacings for the line chart.
57
46
  */
58
- const { extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, lineChartXPosition, lineChartYPosition, securityXSpace, securityYSpace, xAxisText, xBreakAxis, xData, yAxisText, yBreakAxis, yData, } = getExtraSpacing({
59
- ajustedX,
60
- ajustedY,
47
+ const { xAxisLeftSpacing, xAxisTopSpacing, xAxisRightSpacing, xAxisBottomSpacing, yAxisLeftSpacing, yAxisTopSpacing, yAxisRightSpacing, yAxisBottomSpacing, lineChartXPosition, lineChartYPosition, xAxisText, xBreakAxis, xData, yAxisText, yBreakAxis, yData, } = getExtraSpacing({
61
48
  canvasHeight: safeCanvasHeight,
62
49
  canvasWidth: safeCanvasWidth,
63
50
  children,
@@ -65,85 +52,35 @@ export const buildLineContextValue = ({ addError, ajustedX, ajustedY, canvasHeig
65
52
  viewBox,
66
53
  xKey,
67
54
  });
68
- /**
69
- * Calculate the tick values for the X Axis.
70
- */
71
- const crossXAxis = lineChartXPosition !== Positions.TOP && lineChartXPosition !== Positions.BOTTOM;
72
- const yAxisSpace = extraSpaceLeftX + extraSpaceRightX;
73
55
  const xTickValues = getXTicks({
74
- initPos: extraSpaceLeftX,
75
- maxSpaceAvailable: safeCanvasWidth,
76
- otherAxisSpace: yAxisSpace,
77
- securitySpace: securityXSpace,
78
56
  tickValues: xData,
57
+ maxSpaceAvailable: safeCanvasWidth,
58
+ xAxisLeftSpacing,
59
+ xAxisRightSpacing,
60
+ yAxisLeftSpacing,
61
+ yAxisRightSpacing,
79
62
  });
80
- if ((xTickValues ?? []).some(({ position }) => isNaN(position))) {
81
- const xTickError = {
82
- error: buildError(BuildError.INVALID_X_TICK),
83
- };
84
- addError?.('LINE_CHART_CONTEXT_ERROR', xTickError);
63
+ const { error: xTickError } = validateXTickValues({ xTickValues, addError });
64
+ if (!error && xTickError) {
85
65
  error = xTickError;
86
66
  }
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
- }
110
- }
111
67
  /**
112
68
  * Calculate the tick values for the Y Axis.
113
69
  */
114
- const crossYAxis = lineChartYPosition !== Positions.LEFT && lineChartYPosition !== Positions.RIGHT;
115
- const otherAxisSpace = extraSpaceTopY + extraSpaceBottomY;
116
70
  const yTickValues = getYTicks({
117
- initPos: safeCanvasHeight - extraSpaceBottomY,
118
71
  maxSpaceAvailable: safeCanvasHeight,
119
- otherAxisSpace,
120
- securitySpace: securityYSpace,
121
72
  tickValues: yData,
73
+ xAxisTopSpacing,
74
+ xAxisBottomSpacing,
75
+ yAxisTopSpacing,
76
+ yAxisBottomSpacing,
122
77
  });
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
- }
78
+ const { error: yTickError } = validateYTickValues({ yTickValues, addError });
79
+ if (!error && yTickError) {
80
+ error = yTickError;
146
81
  }
82
+ const crossXAxis = lineChartXPosition !== Positions.TOP && lineChartXPosition !== Positions.BOTTOM;
83
+ const crossYAxis = lineChartYPosition !== Positions.LEFT && lineChartYPosition !== Positions.RIGHT;
147
84
  /**
148
85
  * Calculate the custom breakAxis for the X and Y Axis.
149
86
  */
@@ -160,12 +97,16 @@ export const buildLineContextValue = ({ addError, ajustedX, ajustedY, canvasHeig
160
97
  canvasHeight: safeCanvasHeight,
161
98
  canvasWidth: safeCanvasWidth,
162
99
  customBreakAxis: Number(customBreakXAxis),
163
- extraSpaceBottomY,
164
- extraSpaceLeftX,
165
- extraSpaceRightX,
166
- extraSpaceTopY,
167
- position: lineChartXPosition,
168
- securityYSpace,
100
+ lineChartXPosition,
101
+ lineChartYPosition,
102
+ xAxisLeftSpacing,
103
+ xAxisTopSpacing,
104
+ xAxisRightSpacing,
105
+ xAxisBottomSpacing,
106
+ yAxisLeftSpacing,
107
+ yAxisTopSpacing,
108
+ yAxisRightSpacing,
109
+ yAxisBottomSpacing,
169
110
  });
170
111
  /**
171
112
  * Calculate the Y coordinates for the line chart.
@@ -174,42 +115,37 @@ export const buildLineContextValue = ({ addError, ajustedX, ajustedY, canvasHeig
174
115
  canvasHeight: safeCanvasHeight,
175
116
  canvasWidth: safeCanvasWidth,
176
117
  customBreakAxis: Number(customBreakYAxis),
177
- extraSpaceBottomY,
178
- extraSpaceLeftX,
179
- extraSpaceRightX,
180
- extraSpaceTopY,
181
- position: lineChartYPosition,
182
- securityYSpace,
118
+ lineChartXPosition,
119
+ lineChartYPosition,
120
+ xAxisLeftSpacing,
121
+ xAxisTopSpacing,
122
+ xAxisRightSpacing,
123
+ xAxisBottomSpacing,
124
+ yAxisLeftSpacing,
125
+ yAxisTopSpacing,
126
+ yAxisRightSpacing,
127
+ yAxisBottomSpacing,
183
128
  });
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
- }
129
+ const { error: xCoordinatesError } = validateXCoordinates({ xCoordinates, addError });
130
+ if (!error && xCoordinatesError) {
131
+ error = xCoordinatesError;
193
132
  }
194
- if (yCoordinates.y1 === yCoordinates.y2) {
195
- const yAxisError = {
196
- error: buildError(BuildError.LINE_CHART_Y_AXIS_ZERO_LENGTH),
197
- };
198
- addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
199
- if (!error) {
200
- error = yAxisError;
201
- }
133
+ const { error: yCoordinatesError } = validateYCoordinates({ yCoordinates, addError });
134
+ if (!error && yCoordinatesError) {
135
+ error = yCoordinatesError;
202
136
  }
203
137
  const baseContext = {
204
138
  addError,
205
139
  crossXAxis,
206
140
  crossYAxis,
207
- extraSpaceBottomY,
208
- extraSpaceLeftX,
209
- extraSpaceRightX,
210
- extraSpaceTopY,
211
- securityXSpace,
212
- securityYSpace,
141
+ xAxisLeftSpacing,
142
+ xAxisTopSpacing,
143
+ xAxisRightSpacing,
144
+ xAxisBottomSpacing,
145
+ yAxisLeftSpacing,
146
+ yAxisTopSpacing,
147
+ yAxisRightSpacing,
148
+ yAxisBottomSpacing,
213
149
  xAxisCoordinates: {
214
150
  coordinates: xCoordinates,
215
151
  tickValues: xTickValues ||
@@ -1,44 +1,3 @@
1
- import type { TickData } from '../../../../components/tick/tick.types';
2
- export declare const CONTEXT: {
3
- addError: undefined;
4
- canvasExtraSpace: number;
5
- canvasHeight: number;
6
- canvasWidth: number;
7
- crossXAxis: boolean;
8
- crossYAxis: boolean;
9
- data: {
10
- testKey: number;
11
- xKey: number;
12
- }[];
13
- dataTestId: string;
14
- extraSpaceBottomY: number;
15
- extraSpaceLeftX: number;
16
- extraSpaceRightX: number;
17
- extraSpaceTopY: number;
18
- securityXSpace: number;
19
- securityYSpace: number;
20
- xAxisCoordinates: {
21
- coordinates: {
22
- x1: number;
23
- x2: number;
24
- y1: number;
25
- y2: number;
26
- };
27
- tickValues: TickData[];
28
- };
29
- xAxisText: number;
30
- xCursor: number;
31
- xKey: string;
32
- yAxisCoordinates: {
33
- coordinates: {
34
- x1: number;
35
- x2: number;
36
- y1: number;
37
- y2: number;
38
- };
39
- tickValues: TickData[];
40
- };
41
- yAxisText: number;
42
- yCursor: number;
43
- };
1
+ import type { LineChartContextType } from '../../lineChart.type';
2
+ export declare const CONTEXT: LineChartContextType;
44
3
  //# sourceMappingURL=contextData.d.ts.map