@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.
Files changed (196) hide show
  1. package/dist/cjs/charts/barChart/barChart.type.d.ts +4 -0
  2. package/dist/cjs/charts/barChart/barChart.type.d.ts.map +1 -1
  3. package/dist/cjs/charts/barChart/barChartStructure.d.ts.map +1 -1
  4. package/dist/cjs/charts/barChart/barChartStructure.js +9 -2
  5. package/dist/cjs/charts/barChart/context/buildBarContextValues.d.ts +3 -1
  6. package/dist/cjs/charts/barChart/context/buildBarContextValues.d.ts.map +1 -1
  7. package/dist/cjs/charts/barChart/context/buildBarContextValues.js +177 -16
  8. package/dist/cjs/charts/barChart/fragments/barChartPath.d.ts +6 -0
  9. package/dist/cjs/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
  10. package/dist/cjs/charts/barChart/fragments/barChartPath.js +38 -4
  11. package/dist/cjs/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
  12. package/dist/cjs/charts/barChart/fragments/barChartSeparator.js +52 -2
  13. package/dist/cjs/charts/barChart/fragments/barChartXAxis.d.ts.map +1 -1
  14. package/dist/cjs/charts/barChart/fragments/barChartXAxis.js +2 -1
  15. package/dist/cjs/charts/barChart/fragments/barChartYAxis.d.ts.map +1 -1
  16. package/dist/cjs/charts/barChart/fragments/barChartYAxis.js +2 -1
  17. package/dist/cjs/charts/barChart/fragments/fixture/barContextData.d.ts.map +1 -1
  18. package/dist/cjs/charts/barChart/fragments/fixture/barContextData.js +1 -0
  19. package/dist/cjs/charts/barChart/utils/getBarDataValue.d.ts.map +1 -1
  20. package/dist/cjs/charts/barChart/utils/getBarDataValue.js +5 -0
  21. package/dist/cjs/charts/constants/chartDefaults.d.ts +77 -0
  22. package/dist/cjs/charts/constants/chartDefaults.d.ts.map +1 -0
  23. package/dist/cjs/charts/constants/chartDefaults.js +76 -0
  24. package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts +3 -1
  25. package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  26. package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +162 -46
  27. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts +1 -0
  28. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  29. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +1 -0
  30. package/dist/cjs/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
  31. package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +34 -1
  32. package/dist/cjs/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
  33. package/dist/cjs/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
  34. package/dist/cjs/charts/lineChart/fragments/lineChartProjection.js +44 -0
  35. package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
  36. package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.js +52 -2
  37. package/dist/cjs/charts/lineChart/lineChart.type.d.ts +2 -1
  38. package/dist/cjs/charts/lineChart/lineChart.type.d.ts.map +1 -1
  39. package/dist/cjs/charts/lineChart/lineChartStructure.d.ts.map +1 -1
  40. package/dist/cjs/charts/lineChart/lineChartStructure.js +15 -11
  41. package/dist/cjs/types/errors.type.d.ts +14 -1
  42. package/dist/cjs/types/errors.type.d.ts.map +1 -1
  43. package/dist/cjs/types/errors.type.js +18 -0
  44. package/dist/cjs/utils/buildErrors/buildErrors.d.ts +63 -0
  45. package/dist/cjs/utils/buildErrors/buildErrors.d.ts.map +1 -1
  46. package/dist/cjs/utils/buildErrors/buildErrors.js +32 -0
  47. package/dist/cjs/utils/buildErrors/charts/buildBarChartErrors.d.ts +17 -0
  48. package/dist/cjs/utils/buildErrors/charts/buildBarChartErrors.d.ts.map +1 -0
  49. package/dist/cjs/utils/buildErrors/charts/buildBarChartErrors.js +16 -0
  50. package/dist/cjs/utils/buildErrors/charts/buildLineChartErrors.d.ts +13 -0
  51. package/dist/cjs/utils/buildErrors/charts/buildLineChartErrors.d.ts.map +1 -0
  52. package/dist/cjs/utils/buildErrors/charts/buildLineChartErrors.js +12 -0
  53. package/dist/cjs/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts +19 -0
  54. package/dist/cjs/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts.map +1 -0
  55. package/dist/cjs/utils/buildErrors/constants/errorMessages/barChartErrorMessages.js +23 -0
  56. package/dist/cjs/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts +25 -0
  57. package/dist/cjs/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts.map +1 -0
  58. package/dist/cjs/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.js +29 -0
  59. package/dist/cjs/utils/buildErrors/constants/errors/barChartErrors.d.ts +20 -0
  60. package/dist/cjs/utils/buildErrors/constants/errors/barChartErrors.d.ts.map +1 -0
  61. package/dist/cjs/utils/buildErrors/constants/errors/barChartErrors.js +28 -0
  62. package/dist/cjs/utils/buildErrors/constants/errors/lineChartErrors.d.ts +26 -0
  63. package/dist/cjs/utils/buildErrors/constants/errors/lineChartErrors.d.ts.map +1 -0
  64. package/dist/cjs/utils/buildErrors/constants/errors/lineChartErrors.js +34 -0
  65. package/dist/cjs/utils/buildErrors/index.d.ts +2 -0
  66. package/dist/cjs/utils/buildErrors/index.d.ts.map +1 -0
  67. package/dist/cjs/utils/buildErrors/index.js +2 -0
  68. package/dist/cjs/utils/createErrorAccumulator/createErrorAccumulator.d.ts +7 -0
  69. package/dist/cjs/utils/createErrorAccumulator/createErrorAccumulator.d.ts.map +1 -0
  70. package/dist/cjs/utils/createErrorAccumulator/createErrorAccumulator.js +54 -0
  71. package/dist/cjs/utils/createErrorAccumulator/index.d.ts +2 -0
  72. package/dist/cjs/utils/createErrorAccumulator/index.d.ts.map +1 -0
  73. package/dist/cjs/utils/createErrorAccumulator/index.js +1 -0
  74. package/dist/esm/charts/barChart/barChart.type.d.ts +4 -0
  75. package/dist/esm/charts/barChart/barChart.type.d.ts.map +1 -1
  76. package/dist/esm/charts/barChart/barChartStructure.d.ts.map +1 -1
  77. package/dist/esm/charts/barChart/barChartStructure.js +9 -2
  78. package/dist/esm/charts/barChart/context/buildBarContextValues.d.ts +3 -1
  79. package/dist/esm/charts/barChart/context/buildBarContextValues.d.ts.map +1 -1
  80. package/dist/esm/charts/barChart/context/buildBarContextValues.js +177 -16
  81. package/dist/esm/charts/barChart/fragments/barChartPath.d.ts +6 -0
  82. package/dist/esm/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
  83. package/dist/esm/charts/barChart/fragments/barChartPath.js +38 -4
  84. package/dist/esm/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
  85. package/dist/esm/charts/barChart/fragments/barChartSeparator.js +52 -2
  86. package/dist/esm/charts/barChart/fragments/barChartXAxis.d.ts.map +1 -1
  87. package/dist/esm/charts/barChart/fragments/barChartXAxis.js +2 -1
  88. package/dist/esm/charts/barChart/fragments/barChartYAxis.d.ts.map +1 -1
  89. package/dist/esm/charts/barChart/fragments/barChartYAxis.js +2 -1
  90. package/dist/esm/charts/barChart/fragments/fixture/barContextData.d.ts.map +1 -1
  91. package/dist/esm/charts/barChart/fragments/fixture/barContextData.js +1 -0
  92. package/dist/esm/charts/barChart/utils/getBarDataValue.d.ts.map +1 -1
  93. package/dist/esm/charts/barChart/utils/getBarDataValue.js +5 -0
  94. package/dist/esm/charts/constants/chartDefaults.d.ts +77 -0
  95. package/dist/esm/charts/constants/chartDefaults.d.ts.map +1 -0
  96. package/dist/esm/charts/constants/chartDefaults.js +76 -0
  97. package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts +3 -1
  98. package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  99. package/dist/esm/charts/lineChart/context/buildLineContextValue.js +162 -46
  100. package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts +1 -0
  101. package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  102. package/dist/esm/charts/lineChart/fragments/fixture/contextData.js +1 -0
  103. package/dist/esm/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
  104. package/dist/esm/charts/lineChart/fragments/lineChartPath.js +34 -1
  105. package/dist/esm/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
  106. package/dist/esm/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
  107. package/dist/esm/charts/lineChart/fragments/lineChartProjection.js +44 -0
  108. package/dist/esm/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
  109. package/dist/esm/charts/lineChart/fragments/lineChartSeparator.js +52 -2
  110. package/dist/esm/charts/lineChart/lineChart.type.d.ts +2 -1
  111. package/dist/esm/charts/lineChart/lineChart.type.d.ts.map +1 -1
  112. package/dist/esm/charts/lineChart/lineChartStructure.d.ts.map +1 -1
  113. package/dist/esm/charts/lineChart/lineChartStructure.js +15 -11
  114. package/dist/esm/types/errors.type.d.ts +14 -1
  115. package/dist/esm/types/errors.type.d.ts.map +1 -1
  116. package/dist/esm/types/errors.type.js +18 -0
  117. package/dist/esm/utils/buildErrors/buildErrors.d.ts +63 -0
  118. package/dist/esm/utils/buildErrors/buildErrors.d.ts.map +1 -1
  119. package/dist/esm/utils/buildErrors/buildErrors.js +32 -0
  120. package/dist/esm/utils/buildErrors/charts/buildBarChartErrors.d.ts +17 -0
  121. package/dist/esm/utils/buildErrors/charts/buildBarChartErrors.d.ts.map +1 -0
  122. package/dist/esm/utils/buildErrors/charts/buildBarChartErrors.js +16 -0
  123. package/dist/esm/utils/buildErrors/charts/buildLineChartErrors.d.ts +13 -0
  124. package/dist/esm/utils/buildErrors/charts/buildLineChartErrors.d.ts.map +1 -0
  125. package/dist/esm/utils/buildErrors/charts/buildLineChartErrors.js +12 -0
  126. package/dist/esm/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts +19 -0
  127. package/dist/esm/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts.map +1 -0
  128. package/dist/esm/utils/buildErrors/constants/errorMessages/barChartErrorMessages.js +23 -0
  129. package/dist/esm/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts +25 -0
  130. package/dist/esm/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts.map +1 -0
  131. package/dist/esm/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.js +29 -0
  132. package/dist/esm/utils/buildErrors/constants/errors/barChartErrors.d.ts +20 -0
  133. package/dist/esm/utils/buildErrors/constants/errors/barChartErrors.d.ts.map +1 -0
  134. package/dist/esm/utils/buildErrors/constants/errors/barChartErrors.js +28 -0
  135. package/dist/esm/utils/buildErrors/constants/errors/lineChartErrors.d.ts +26 -0
  136. package/dist/esm/utils/buildErrors/constants/errors/lineChartErrors.d.ts.map +1 -0
  137. package/dist/esm/utils/buildErrors/constants/errors/lineChartErrors.js +34 -0
  138. package/dist/esm/utils/buildErrors/index.d.ts +2 -0
  139. package/dist/esm/utils/buildErrors/index.d.ts.map +1 -0
  140. package/dist/esm/utils/buildErrors/index.js +2 -0
  141. package/dist/esm/utils/createErrorAccumulator/createErrorAccumulator.d.ts +7 -0
  142. package/dist/esm/utils/createErrorAccumulator/createErrorAccumulator.d.ts.map +1 -0
  143. package/dist/esm/utils/createErrorAccumulator/createErrorAccumulator.js +54 -0
  144. package/dist/esm/utils/createErrorAccumulator/index.d.ts +2 -0
  145. package/dist/esm/utils/createErrorAccumulator/index.d.ts.map +1 -0
  146. package/dist/esm/utils/createErrorAccumulator/index.js +1 -0
  147. package/dist/kubit-ui-web-react-charts.cjs.js +1 -1
  148. package/dist/kubit-ui-web-react-charts.es.js +1 -1
  149. package/dist/kubit-ui-web-react-charts.umd.js +1 -1
  150. package/dist/types/charts/barChart/barChart.type.d.ts +4 -0
  151. package/dist/types/charts/barChart/barChart.type.d.ts.map +1 -1
  152. package/dist/types/charts/barChart/barChartStructure.d.ts.map +1 -1
  153. package/dist/types/charts/barChart/context/buildBarContextValues.d.ts +3 -1
  154. package/dist/types/charts/barChart/context/buildBarContextValues.d.ts.map +1 -1
  155. package/dist/types/charts/barChart/fragments/barChartPath.d.ts +6 -0
  156. package/dist/types/charts/barChart/fragments/barChartPath.d.ts.map +1 -1
  157. package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts.map +1 -1
  158. package/dist/types/charts/barChart/fragments/barChartXAxis.d.ts.map +1 -1
  159. package/dist/types/charts/barChart/fragments/barChartYAxis.d.ts.map +1 -1
  160. package/dist/types/charts/barChart/fragments/fixture/barContextData.d.ts.map +1 -1
  161. package/dist/types/charts/barChart/utils/getBarDataValue.d.ts.map +1 -1
  162. package/dist/types/charts/constants/chartDefaults.d.ts +77 -0
  163. package/dist/types/charts/constants/chartDefaults.d.ts.map +1 -0
  164. package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts +3 -1
  165. package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  166. package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts +1 -0
  167. package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  168. package/dist/types/charts/lineChart/fragments/lineChartPath.d.ts.map +1 -1
  169. package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts.map +1 -1
  170. package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts.map +1 -1
  171. package/dist/types/charts/lineChart/lineChart.type.d.ts +2 -1
  172. package/dist/types/charts/lineChart/lineChart.type.d.ts.map +1 -1
  173. package/dist/types/charts/lineChart/lineChartStructure.d.ts.map +1 -1
  174. package/dist/types/types/errors.type.d.ts +14 -1
  175. package/dist/types/types/errors.type.d.ts.map +1 -1
  176. package/dist/types/utils/buildErrors/buildErrors.d.ts +63 -0
  177. package/dist/types/utils/buildErrors/buildErrors.d.ts.map +1 -1
  178. package/dist/types/utils/buildErrors/charts/buildBarChartErrors.d.ts +17 -0
  179. package/dist/types/utils/buildErrors/charts/buildBarChartErrors.d.ts.map +1 -0
  180. package/dist/types/utils/buildErrors/charts/buildLineChartErrors.d.ts +13 -0
  181. package/dist/types/utils/buildErrors/charts/buildLineChartErrors.d.ts.map +1 -0
  182. package/dist/types/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts +19 -0
  183. package/dist/types/utils/buildErrors/constants/errorMessages/barChartErrorMessages.d.ts.map +1 -0
  184. package/dist/types/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts +25 -0
  185. package/dist/types/utils/buildErrors/constants/errorMessages/lineChartErrorMessages.d.ts.map +1 -0
  186. package/dist/types/utils/buildErrors/constants/errors/barChartErrors.d.ts +20 -0
  187. package/dist/types/utils/buildErrors/constants/errors/barChartErrors.d.ts.map +1 -0
  188. package/dist/types/utils/buildErrors/constants/errors/lineChartErrors.d.ts +26 -0
  189. package/dist/types/utils/buildErrors/constants/errors/lineChartErrors.d.ts.map +1 -0
  190. package/dist/types/utils/buildErrors/index.d.ts +2 -0
  191. package/dist/types/utils/buildErrors/index.d.ts.map +1 -0
  192. package/dist/types/utils/createErrorAccumulator/createErrorAccumulator.d.ts +7 -0
  193. package/dist/types/utils/createErrorAccumulator/createErrorAccumulator.d.ts.map +1 -0
  194. package/dist/types/utils/createErrorAccumulator/index.d.ts +2 -0
  195. package/dist/types/utils/createErrorAccumulator/index.d.ts.map +1 -0
  196. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineChartErrors.d.ts","sourceRoot":"","sources":["../../../../../../src/utils/buildErrors/constants/errors/lineChartErrors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;CAgClB,CAAC;AAEX,eAAO,MAAM,qBAAqB,i3BAMjC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { LineChartErrorMessages } from '../errorMessages/lineChartErrorMessages';
2
+ export const LineChartErrors = {
3
+ // LineChart Context Errors
4
+ LINE_CHART_INVALID_CANVAS: 'LINE_CHART_INVALID_CANVAS',
5
+ LINE_CHART_NO_DATA: 'LINE_CHART_NO_DATA',
6
+ // LineChart Path Errors
7
+ LINE_CHART_PATH_ALL_VALUES_NULL: 'LINE_CHART_PATH_ALL_VALUES_NULL',
8
+ LINE_CHART_PATH_INSUFFICIENT_POINTS: 'LINE_CHART_PATH_INSUFFICIENT_POINTS',
9
+ LINE_CHART_PATH_INVALID_DATAKEY: 'LINE_CHART_PATH_INVALID_DATAKEY',
10
+ // LineChart Projection Errors
11
+ LINE_CHART_PROJECTION_INVALID_BOUNDS: 'LINE_CHART_PROJECTION_INVALID_BOUNDS',
12
+ LINE_CHART_PROJECTION_LOWER_X_OUT_OF_RANGE: 'LINE_CHART_PROJECTION_LOWER_X_OUT_OF_RANGE',
13
+ LINE_CHART_PROJECTION_LOWER_Y_OUT_OF_RANGE: 'LINE_CHART_PROJECTION_LOWER_Y_OUT_OF_RANGE',
14
+ LINE_CHART_PROJECTION_UPPER_X_OUT_OF_RANGE: 'LINE_CHART_PROJECTION_UPPER_X_OUT_OF_RANGE',
15
+ LINE_CHART_PROJECTION_UPPER_Y_OUT_OF_RANGE: 'LINE_CHART_PROJECTION_UPPER_Y_OUT_OF_RANGE',
16
+ // LineChart Separator Errors
17
+ LINE_CHART_SEPARATOR_INVALID_COORDINATES: 'LINE_CHART_SEPARATOR_INVALID_COORDINATES',
18
+ LINE_CHART_SEPARATOR_INVALID_X_BREAK_AXIS: 'LINE_CHART_SEPARATOR_INVALID_X_BREAK_AXIS',
19
+ LINE_CHART_SEPARATOR_INVALID_Y_BREAK_AXIS: 'LINE_CHART_SEPARATOR_INVALID_Y_BREAK_AXIS',
20
+ LINE_CHART_SEPARATOR_X_OUT_OF_RANGE: 'LINE_CHART_SEPARATOR_X_OUT_OF_RANGE',
21
+ LINE_CHART_SEPARATOR_Y_OUT_OF_RANGE: 'LINE_CHART_SEPARATOR_Y_OUT_OF_RANGE',
22
+ LINE_CHART_SINGLE_POINT: 'LINE_CHART_SINGLE_POINT',
23
+ // LineChart Axis Errors
24
+ LINE_CHART_X_AXIS_IDENTICAL_VALUES: 'LINE_CHART_X_AXIS_IDENTICAL_VALUES',
25
+ LINE_CHART_X_AXIS_INSUFFICIENT_TICKS: 'LINE_CHART_X_AXIS_INSUFFICIENT_TICKS',
26
+ LINE_CHART_X_AXIS_ZERO_LENGTH: 'LINE_CHART_X_AXIS_ZERO_LENGTH',
27
+ LINE_CHART_Y_AXIS_IDENTICAL_VALUES: 'LINE_CHART_Y_AXIS_IDENTICAL_VALUES',
28
+ LINE_CHART_Y_AXIS_INSUFFICIENT_TICKS: 'LINE_CHART_Y_AXIS_INSUFFICIENT_TICKS',
29
+ LINE_CHART_Y_AXIS_ZERO_LENGTH: 'LINE_CHART_Y_AXIS_ZERO_LENGTH',
30
+ };
31
+ export const LineChartErrorsRecord = Object.entries(LineChartErrorMessages).reduce((acc, [key, message]) => {
32
+ acc[key] = new Error(message);
33
+ return acc;
34
+ }, {});
@@ -0,0 +1,2 @@
1
+ export * from './buildErrors';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/buildErrors/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ // Re-export everything from the main buildErrors.ts file
2
+ export * from './buildErrors';
@@ -0,0 +1,7 @@
1
+ import type { ChartError, ChartErrorCollection, ErrorType } from '../../types/errors.type';
2
+ export declare const createErrorAccumulator: (onErrors?: (errors: ChartErrorCollection) => void) => {
3
+ addError: (errorType: keyof typeof ErrorType, error: Omit<ChartError, "type">) => void;
4
+ getAccumulatedErrors: () => ChartErrorCollection;
5
+ clearErrors: () => void;
6
+ };
7
+ //# sourceMappingURL=createErrorAccumulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createErrorAccumulator.d.ts","sourceRoot":"","sources":["../../../../src/utils/createErrorAccumulator/createErrorAccumulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEvF,eAAO,MAAM,sBAAsB,GACjC,WAAW,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,KAChD;IACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,OAAO,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACvF,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;IACjD,WAAW,EAAE,MAAM,IAAI,CAAC;CAqEzB,CAAC"}
@@ -0,0 +1,54 @@
1
+ export const createErrorAccumulator = (onErrors) => {
2
+ const errors = new Map();
3
+ const getAccumulatedErrors = () => {
4
+ const result = {};
5
+ // Return all errors by type as arrays (internal format)
6
+ errors.forEach((errorArray, errorType) => {
7
+ result[errorType] = errorArray;
8
+ });
9
+ return result;
10
+ };
11
+ const addError = (errorType, error) => {
12
+ if (!error) {
13
+ return;
14
+ }
15
+ // Create complete error with type
16
+ const completeError = { ...error, type: errorType };
17
+ // Get existing errors for this type or create new array
18
+ const existingErrors = errors.get(errorType) || [];
19
+ // Add new error to the array
20
+ existingErrors.push(completeError);
21
+ // Set the updated array back to the Map
22
+ errors.set(errorType, existingErrors);
23
+ // Call onErrors callback immediately if provided
24
+ if (onErrors) {
25
+ const accumulatedErrors = getAccumulatedErrors();
26
+ // BACKWARDS COMPATIBILITY: Detect if callback expects legacy format
27
+ // If there's only one error per type, we offer compatibility with previous format
28
+ const compatibleErrors = {};
29
+ Object.entries(accumulatedErrors).forEach(([key, errorArray]) => {
30
+ const keyType = key;
31
+ // If it's an error array and has only one, it might be compatible with legacy format
32
+ if (Array.isArray(errorArray) && errorArray.length === 1) {
33
+ // Try to determine if callback expects legacy format
34
+ // For maximum compatibility, we offer the array but could also
35
+ // offer the single element depending on context
36
+ compatibleErrors[keyType] = errorArray;
37
+ }
38
+ else {
39
+ // Multiple errors - only array format
40
+ compatibleErrors[keyType] = errorArray;
41
+ }
42
+ });
43
+ onErrors(compatibleErrors);
44
+ }
45
+ };
46
+ const clearErrors = () => {
47
+ errors.clear();
48
+ // Call onErrors with empty object when clearing if callback is provided
49
+ if (onErrors) {
50
+ onErrors({});
51
+ }
52
+ };
53
+ return { addError, clearErrors, getAccumulatedErrors };
54
+ };
@@ -0,0 +1,2 @@
1
+ export { createErrorAccumulator } from './createErrorAccumulator';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/createErrorAccumulator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export { createErrorAccumulator } from './createErrorAccumulator';
@@ -5,6 +5,7 @@ import type { BarChartStyles, BarOrientation } from '../../components/bar/bar.ty
5
5
  import type { PathProps, StyleProps } from '../../components/path/path.types';
6
6
  import type { TickData } from '../../components/tick/tick.types';
7
7
  import type { CanvasConfig } from '../../types/canvas.type';
8
+ import type { ChartError, ChartErrorCollection, ErrorType } from '../../types/errors.type';
8
9
  import type { Positions } from '../../types/position.enum';
9
10
  export type BarChartChildrenType = ReactNode | ReactElement<PathProps | XAxisProps | YAxisProps>;
10
11
  export interface BarChartIDataPoint {
@@ -51,6 +52,8 @@ export type BarChartContextType = Omit<BarChartExtraSpacings, OmitLineProps> & {
51
52
  barChildrenCount: number;
52
53
  gapBetweenBars?: number;
53
54
  orientation: (typeof BarOrientation)[keyof typeof BarOrientation];
55
+ error?: ChartError;
56
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
54
57
  };
55
58
  export interface BarChartProps {
56
59
  children: BarChartChildrenType;
@@ -74,6 +77,7 @@ export interface BarChartProps {
74
77
  onBlur?: (event: React.FocusEvent<SVGElement>) => void;
75
78
  onKeyDown?: (event: React.KeyboardEvent<SVGSVGElement>) => void;
76
79
  onKeyUp?: (event: React.KeyboardEvent<SVGSVGElement>) => void;
80
+ onErrors?: (errors: ChartErrorCollection) => void;
77
81
  }
78
82
  export interface BarChartTickNumeric {
79
83
  max: number;
@@ -1 +1 @@
1
- {"version":3,"file":"barChart.type.d.ts","sourceRoot":"","sources":["../../../../src/charts/barChart/barChart.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,YAAY,CAAC,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;AAEjG,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,eAA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AU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"barChartStructure.d.ts","sourceRoot":"","sources":["../../../../src/charts/barChart/barChartStructure.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOrD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAyFrD,CAAC"}
1
+ {"version":3,"file":"barChartStructure.d.ts","sourceRoot":"","sources":["../../../../src/charts/barChart/barChartStructure.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOrD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAoGrD,CAAC"}
@@ -3,6 +3,7 @@ import { Children, 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';
6
7
  import { getDataFingerprint } from '../../utils/getDataFingerprint/getDataFingerprint';
7
8
  import { parseStringToNumberPx } from '../../utils/parseStringToNumberPx.ts/parseStringToNumberPx';
8
9
  import { BarChartContext } from './context/barChartContext';
@@ -10,7 +11,7 @@ import { buildBarContextValue } from './context/buildBarContextValues';
10
11
  import { BarChartXAxis } from './fragments/barChartXAxis';
11
12
  import { BarChartYAxis } from './fragments/barChartYAxis';
12
13
  import { countBarChildren } from './utils/countBarChildren';
13
- export const BarChartStructure = ({ canvasConfig = DefaultCanvasConfig, caption, children, classNames, data, dataTestId, gapBetweenBars = 0, height = '100%', orientation, pKey, role, tabIndex, width = '100%', ...props }) => {
14
+ export const BarChartStructure = ({ canvasConfig = DefaultCanvasConfig, caption, children, classNames, data, dataTestId, gapBetweenBars = 0, height = '100%', onErrors, orientation, pKey, role, tabIndex, width = '100%', ...props }) => {
14
15
  // Extracts and sets default values for canvas configuration
15
16
  const { extraSpace: canvasExtraSpace, height: canvasHeight, width: canvasWidth } = canvasConfig;
16
17
  const parsedCanvasWidth = parseStringToNumberPx(canvasWidth);
@@ -32,11 +33,17 @@ export const BarChartStructure = ({ canvasConfig = DefaultCanvasConfig, caption,
32
33
  const maxValue = Math.max(parsedCanvasWidth, parsedCanvasHeight, parsedCanvasExtraSpace ?? 0);
33
34
  const ajustedX = parsedCanvasWidth / maxValue;
34
35
  const ajustedY = parsedCanvasHeight / maxValue;
36
+ const errorAccumulator = useMemo(() => createErrorAccumulator(onErrors), [onErrors]);
35
37
  // Create a fingerprint of the data to avoid unnecessary contextValue updates
36
38
  const dataFingerprint = getDataFingerprint(data);
37
39
  // Build the context value
38
40
  const contextValue = useMemo(() => {
41
+ // Clear previous errors before building new context
42
+ errorAccumulator.clearErrors();
39
43
  return buildBarContextValue({
44
+ addError: (errorType, error) => {
45
+ errorAccumulator.addError(errorType, error);
46
+ },
40
47
  ajustedX,
41
48
  ajustedY,
42
49
  canvasHeight: parsedCanvasHeight,
@@ -48,7 +55,7 @@ export const BarChartStructure = ({ canvasConfig = DefaultCanvasConfig, caption,
48
55
  pKey,
49
56
  viewBox,
50
57
  });
51
- }, [canvasHeight, canvasWidth, dataFingerprint, pKey, orientation]);
58
+ }, [canvasHeight, canvasWidth, dataFingerprint, pKey, orientation, errorAccumulator.addError]);
52
59
  return (_jsx(SvgContainer, { caption: caption, className: classNames, dataTestId: dataTestId, height: height, role: role, tabIndex: tabIndex, viewBox: viewBox, width: width, ...props, children: _jsx(BarChartContext.Provider, { value: {
53
60
  ...contextValue,
54
61
  barChildrenCount,
@@ -1,4 +1,5 @@
1
1
  import { BarOrientation } from '../../../components/bar/bar.type';
2
+ import { type ChartError, ErrorType } from '../../../types/errors.type';
2
3
  import type { BarChartChildrenType, BarChartContextType, BarChartIDataPoint } from '../barChart.type';
3
4
  interface BuildContextValue {
4
5
  children: BarChartChildrenType;
@@ -11,6 +12,7 @@ interface BuildContextValue {
11
12
  gapBetweenBars: number;
12
13
  orientation: (typeof BarOrientation)[keyof typeof BarOrientation];
13
14
  viewBox: string;
15
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
14
16
  }
15
17
  type OmitProps = 'data' | 'pKey' | 'canvasHeight' | 'canvasWidth' | 'canvasExtraSpace' | 'xBreakAxis' | 'yBreakAxis' | 'xCursor' | 'yCursor' | 'barChildrenCount' | 'orientation';
16
18
  /**
@@ -19,6 +21,6 @@ type OmitProps = 'data' | 'pKey' | 'canvasHeight' | 'canvasWidth' | 'canvasExtra
19
21
  * @param {BuildContextValue} options - The options for building the context value.
20
22
  * @returns {LineContextValue} - The built context value.
21
23
  */
22
- export declare const buildBarContextValue: ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, gapBetweenBars, orientation, pKey, viewBox, }: BuildContextValue) => Omit<BarChartContextType, OmitProps>;
24
+ export declare const buildBarContextValue: ({ addError, ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, gapBetweenBars, orientation, pKey, viewBox, }: BuildContextValue) => Omit<BarChartContextType, OmitProps>;
23
25
  export {};
24
26
  //# sourceMappingURL=buildBarContextValues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildBarContextValues.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/context/buildBarContextValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAO3D,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,UAAU,iBAAiB;IACzB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,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,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,KAAK,SAAS,GACV,MAAM,GACN,MAAM,GACN,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,SAAS,GACT,kBAAkB,GAClB,aAAa,CAAC;AAElB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,gHAWlC,iBAAiB,KAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CA2GzD,CAAC"}
1
+ {"version":3,"file":"buildBarContextValues.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/context/buildBarContextValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAoBjE,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAI1B,UAAU,iBAAiB;IACzB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,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,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAClE,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,GACT,kBAAkB,GAClB,aAAa,CAAC;AAElB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,0HAYlC,iBAAiB,KAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAkSzD,CAAC"}
@@ -1,8 +1,12 @@
1
1
  import { BarOrientation } from '../../../components/bar/bar.type';
2
+ import { ErrorType } from '../../../types/errors.type';
2
3
  import { Positions } from '../../../types/position.enum';
4
+ import { BuildError, buildBarDistributionError, buildCanvasDimensionsError, buildError, } from '../../../utils/buildErrors/buildErrors';
3
5
  import { getXCoordinates, getYCoordinates } from '../../../utils/getCoordinates/getCoordinates';
4
6
  import { getPoints } from '../../../utils/getPoints/getPoints';
5
7
  import { getXTicks, getYTicks } from '../../../utils/getTicks/getTicks';
8
+ import { AXIS_VALIDATION, BAR_CHART_DEFAULTS, BAR_CHART_FALLBACK_DATA, BREAK_AXIS_DEFAULTS, CHART_CANVAS_DEFAULTS, SHARED_FALLBACK_DATA, } from '../../constants/chartDefaults';
9
+ import { countBarChildren } from '../utils/countBarChildren';
6
10
  import { getAxisExtraSpacing } from '../utils/getAxisExtraSpacing';
7
11
  /**
8
12
  * Builds the context value for the line chart.
@@ -10,17 +14,62 @@ import { getAxisExtraSpacing } from '../utils/getAxisExtraSpacing';
10
14
  * @param {BuildContextValue} options - The options for building the context value.
11
15
  * @returns {LineContextValue} - The built context value.
12
16
  */
13
- export const buildBarContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, gapBetweenBars, orientation, pKey, viewBox, }) => {
17
+ export const buildBarContextValue = ({ addError, ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, gapBetweenBars, orientation, pKey, viewBox, }) => {
18
+ let error = undefined;
19
+ // 1. Validate data exists
20
+ if (!data || data.length === 0) {
21
+ const dataError = {
22
+ error: buildError(BuildError.BAR_CHART_NO_DATA),
23
+ };
24
+ addError?.('BAR_CHART_CONTEXT_ERROR', dataError);
25
+ error = dataError;
26
+ }
27
+ // 2. Validate canvas dimensions
28
+ if (canvasWidth <= 0 || canvasHeight <= 0) {
29
+ const canvasError = {
30
+ error: buildCanvasDimensionsError(canvasWidth, canvasHeight),
31
+ };
32
+ addError?.('BAR_CHART_CONTEXT_ERROR', canvasError);
33
+ error = canvasError;
34
+ }
35
+ // 3. Validate bar spacing and distribution
36
+ const barChildrenCount = countBarChildren(children);
37
+ const defaultBarWidth = BAR_CHART_DEFAULTS.BAR_WIDTH; // Default width used in BarChartPath
38
+ const requiredSpace = barChildrenCount * defaultBarWidth;
39
+ const totalGapSpace = (barChildrenCount - 1) * gapBetweenBars;
40
+ const availableSpace = orientation === BarOrientation.VERTICAL ? canvasWidth : canvasHeight;
41
+ if (requiredSpace + totalGapSpace > availableSpace) {
42
+ const distributionError = {
43
+ error: buildBarDistributionError('all', `Insufficient space: requires ${requiredSpace + totalGapSpace}px but only ${availableSpace}px available`),
44
+ };
45
+ addError?.('BAR_CHART_CONTEXT_ERROR', distributionError);
46
+ error = distributionError;
47
+ }
48
+ // Use safe defaults for data processing if there are critical errors
49
+ const safeData = data && data.length > 0
50
+ ? data
51
+ : [
52
+ {
53
+ [BAR_CHART_FALLBACK_DATA.FALLBACK_SECONDARY_KEY]: BAR_CHART_FALLBACK_DATA.DEFAULT_X_VALUE,
54
+ [pKey]: SHARED_FALLBACK_DATA.FALLBACK_PKEY_FIRST,
55
+ },
56
+ {
57
+ [BAR_CHART_FALLBACK_DATA.FALLBACK_SECONDARY_KEY]: BAR_CHART_FALLBACK_DATA.DEFAULT_X_VALUE,
58
+ [pKey]: SHARED_FALLBACK_DATA.FALLBACK_PKEY_SECOND,
59
+ },
60
+ ];
61
+ const safeCanvasWidth = canvasWidth > 0 ? canvasWidth : CHART_CANVAS_DEFAULTS.SAFE_WIDTH;
62
+ const safeCanvasHeight = canvasHeight > 0 ? canvasHeight : CHART_CANVAS_DEFAULTS.SAFE_HEIGHT;
14
63
  /**
15
64
  * Get the extra spacings for the line chart.
16
65
  */
17
66
  const { barChartXPosition, barChartYPosition, extraSpaceBottomY, extraSpaceLeftX, extraSpaceRightX, extraSpaceTopY, securityXSpace, securityYSpace, xAxisText, xBreakAxis, xData, yAxisText, yBreakAxis, yData, } = getAxisExtraSpacing({
18
67
  ajustedX,
19
68
  ajustedY,
20
- canvasHeight,
21
- canvasWidth,
69
+ canvasHeight: safeCanvasHeight,
70
+ canvasWidth: safeCanvasWidth,
22
71
  children,
23
- data,
72
+ data: safeData,
24
73
  gapBetweenBars,
25
74
  orientation,
26
75
  pKey,
@@ -33,35 +82,94 @@ export const buildBarContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasW
33
82
  const yAxisSpace = extraSpaceLeftX + extraSpaceRightX;
34
83
  const xTickValue = getXTicks({
35
84
  initPos: extraSpaceLeftX,
36
- maxSpaceAvailable: canvasWidth,
85
+ maxSpaceAvailable: safeCanvasWidth,
37
86
  otherAxisSpace: yAxisSpace,
38
87
  securitySpace: securityXSpace,
39
88
  tickValues: xData,
40
89
  });
90
+ if ((xTickValue ?? []).some(({ position }) => isNaN(position))) {
91
+ const xTickError = {
92
+ error: buildError(BuildError.INVALID_X_TICK),
93
+ };
94
+ addError?.('BAR_CHART_CONTEXT_ERROR', xTickError);
95
+ error = xTickError;
96
+ }
97
+ // Validate X-axis tick values
98
+ if (xTickValue) {
99
+ const hasInsufficientTicks = xTickValue.length < AXIS_VALIDATION.MIN_TICK_COUNT;
100
+ const hasIdenticalValues = xTickValue.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
101
+ new Set(xTickValue.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
102
+ if (hasInsufficientTicks) {
103
+ const xAxisError = {
104
+ error: buildError(BuildError.LINE_CHART_X_AXIS_INSUFFICIENT_TICKS),
105
+ };
106
+ addError?.('BAR_CHART_X_AXIS_ERROR', xAxisError);
107
+ if (!error) {
108
+ error = xAxisError;
109
+ }
110
+ }
111
+ if (hasIdenticalValues) {
112
+ const xAxisError = {
113
+ error: buildError(BuildError.LINE_CHART_X_AXIS_IDENTICAL_VALUES),
114
+ };
115
+ addError?.('BAR_CHART_X_AXIS_ERROR', xAxisError);
116
+ if (!error) {
117
+ error = xAxisError;
118
+ }
119
+ }
120
+ }
41
121
  /**
42
122
  * Calculate the tick values for the Y Axis.
43
123
  */
44
124
  const crossYAxis = barChartYPosition !== Positions.LEFT && barChartYPosition !== Positions.RIGHT;
45
125
  const otherAxisSpace = extraSpaceTopY + extraSpaceBottomY;
46
126
  const yTickValue = getYTicks({
47
- initPos: canvasHeight - extraSpaceBottomY,
48
- maxSpaceAvailable: canvasHeight,
127
+ initPos: safeCanvasHeight - extraSpaceBottomY,
128
+ maxSpaceAvailable: safeCanvasHeight,
49
129
  needAjusted: orientation === BarOrientation.HORIZONTAL,
50
130
  otherAxisSpace,
51
131
  securitySpace: securityYSpace,
52
132
  tickValues: yData,
53
133
  });
134
+ // Validate Y-axis tick values
135
+ if (yTickValue) {
136
+ const hasInsufficientTicks = yTickValue.length < AXIS_VALIDATION.MIN_TICK_COUNT;
137
+ const hasIdenticalValues = yTickValue.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
138
+ new Set(yTickValue.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
139
+ if (hasInsufficientTicks) {
140
+ const yAxisError = {
141
+ error: buildError(BuildError.LINE_CHART_Y_AXIS_INSUFFICIENT_TICKS),
142
+ };
143
+ addError?.('BAR_CHART_Y_AXIS_ERROR', yAxisError);
144
+ if (!error) {
145
+ error = yAxisError;
146
+ }
147
+ }
148
+ if (hasIdenticalValues) {
149
+ const yAxisError = {
150
+ error: buildError(BuildError.LINE_CHART_Y_AXIS_IDENTICAL_VALUES),
151
+ };
152
+ addError?.('BAR_CHART_Y_AXIS_ERROR', yAxisError);
153
+ if (!error) {
154
+ error = yAxisError;
155
+ }
156
+ }
157
+ }
54
158
  /**
55
159
  * Calculate the custom breakAxis for the X and Y Axis.
56
160
  */
57
- const customBreakXAxis = crossXAxis ? getPoints(yTickValue || [], [String(xBreakAxis)])[0] : 0;
58
- const customBreakYAxis = crossYAxis ? getPoints(xTickValue || [], [String(yBreakAxis)])[0] : 0;
161
+ const customBreakXAxis = crossXAxis
162
+ ? getPoints(yTickValue || [], [String(xBreakAxis)])[0]
163
+ : BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE;
164
+ const customBreakYAxis = crossYAxis
165
+ ? getPoints(xTickValue || [], [String(yBreakAxis)])[0]
166
+ : BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE;
59
167
  /**
60
168
  * Calculate the X coordinates for the line chart.
61
169
  */
62
170
  const xCoordinates = getXCoordinates({
63
- canvasHeight,
64
- canvasWidth,
171
+ canvasHeight: safeCanvasHeight,
172
+ canvasWidth: safeCanvasWidth,
65
173
  customBreakAxis: Number(customBreakXAxis),
66
174
  extraSpaceBottomY,
67
175
  extraSpaceLeftX,
@@ -74,8 +182,8 @@ export const buildBarContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasW
74
182
  * Calculate the Y coordinates for the line chart.
75
183
  */
76
184
  const yCoordinates = getYCoordinates({
77
- canvasHeight,
78
- canvasWidth,
185
+ canvasHeight: safeCanvasHeight,
186
+ canvasWidth: safeCanvasWidth,
79
187
  customBreakAxis: Number(customBreakYAxis),
80
188
  extraSpaceBottomY,
81
189
  extraSpaceLeftX,
@@ -84,18 +192,71 @@ export const buildBarContextValue = ({ ajustedX, ajustedY, canvasHeight, canvasW
84
192
  position: barChartYPosition,
85
193
  securityYSpace,
86
194
  });
87
- return {
195
+ // Validate axis coordinates for zero-length axes
196
+ if (xCoordinates.x1 === xCoordinates.x2) {
197
+ const xAxisError = {
198
+ error: buildError(BuildError.LINE_CHART_X_AXIS_ZERO_LENGTH),
199
+ };
200
+ addError?.('BAR_CHART_X_AXIS_ERROR', xAxisError);
201
+ if (!error) {
202
+ error = xAxisError;
203
+ }
204
+ }
205
+ if (yCoordinates.y1 === yCoordinates.y2) {
206
+ const yAxisError = {
207
+ error: buildError(BuildError.LINE_CHART_Y_AXIS_ZERO_LENGTH),
208
+ };
209
+ addError?.('BAR_CHART_Y_AXIS_ERROR', yAxisError);
210
+ if (!error) {
211
+ error = yAxisError;
212
+ }
213
+ }
214
+ const baseContext = {
215
+ addError,
88
216
  crossXAxis,
89
217
  crossYAxis,
218
+ data: safeData,
90
219
  extraSpaceBottomY,
91
220
  extraSpaceLeftX,
92
221
  extraSpaceRightX,
93
222
  extraSpaceTopY,
94
223
  securityXSpace,
95
224
  securityYSpace,
96
- xAxisCoordinates: { coordinates: xCoordinates, tickValues: xTickValue },
225
+ xAxisCoordinates: {
226
+ coordinates: xCoordinates,
227
+ tickValues: xTickValue ||
228
+ (error
229
+ ? [
230
+ {
231
+ position: BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE,
232
+ value: SHARED_FALLBACK_DATA.FALLBACK_PKEY_FIRST,
233
+ },
234
+ { position: safeCanvasWidth, value: SHARED_FALLBACK_DATA.FALLBACK_PKEY_SECOND },
235
+ ]
236
+ : []),
237
+ },
97
238
  xAxisText,
98
- yAxisCoordinates: { coordinates: yCoordinates, tickValues: yTickValue },
239
+ yAxisCoordinates: {
240
+ coordinates: yCoordinates,
241
+ tickValues: yTickValue ||
242
+ (error
243
+ ? [
244
+ { position: safeCanvasHeight, value: SHARED_FALLBACK_DATA.FALLBACK_PKEY_FIRST },
245
+ {
246
+ position: BREAK_AXIS_DEFAULTS.DEFAULT_BREAK_VALUE,
247
+ value: SHARED_FALLBACK_DATA.FALLBACK_PKEY_SECOND,
248
+ },
249
+ ]
250
+ : []),
251
+ },
99
252
  yAxisText,
100
253
  };
254
+ // Add error only if it exists
255
+ if (error) {
256
+ return {
257
+ ...baseContext,
258
+ error: { ...error, type: ErrorType.BAR_CHART_CONTEXT_ERROR },
259
+ };
260
+ }
261
+ return baseContext;
101
262
  };
@@ -1,3 +1,9 @@
1
1
  import type { BarChartPathProps } from '../barChart.type';
2
+ /**
3
+ * Extracts the values for a specific key from the dataset
4
+ * @param data Array of data points
5
+ * @param key Key to extract values from
6
+ * @returns Array of values for the given key
7
+ */
2
8
  export declare const BarChartPath: React.FC<BarChartPathProps>;
3
9
  //# sourceMappingURL=barChartPath.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"barChartPath.d.ts","sourceRoot":"","sources":["../../../../../src/charts/barChart/fragments/barChartPath.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6CpD,CAAC"}
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,CA8EpD,CAAC"}
@@ -1,18 +1,52 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useContext } from 'react';
2
+ import { useContext, useEffect } from 'react';
3
3
  import { Bar } from '../../../components/bar/bar';
4
4
  import { BarOrientation } from '../../../components/bar/bar.type';
5
+ import { buildBarNegativeValueError, buildBarValueError, buildDataKeyNotFoundError, } from '../../../utils/buildErrors/buildErrors';
5
6
  import { getPoints } from '../../../utils/getPoints/getPoints';
6
7
  import { BarChartContext } from '../context/barChartContext';
8
+ /**
9
+ * Extracts the values for a specific key from the dataset
10
+ * @param data Array of data points
11
+ * @param key Key to extract values from
12
+ * @returns Array of values for the given key
13
+ */
7
14
  export const BarChartPath = ({ barConfig, dataIdx, dataKey, order, ...props }) => {
8
- const { xAxisCoordinates, yAxisCoordinates, ...context } = useContext(BarChartContext);
15
+ const { addError, xAxisCoordinates, yAxisCoordinates, ...context } = useContext(BarChartContext);
9
16
  const { coordinates: xACoord, tickValues: xTickValues } = xAxisCoordinates;
10
17
  const { coordinates: yACoord, tickValues: yTickValues } = yAxisCoordinates;
11
18
  const isVertical = context.orientation === BarOrientation.VERTICAL;
12
19
  const xKey = isVertical ? context.pKey : dataKey;
13
20
  const yKey = isVertical ? dataKey : context.pKey;
14
- const xData = context.data[dataIdx][xKey];
15
- const yData = context.data[dataIdx][yKey];
21
+ // Safe data access
22
+ const dataItem = context.data[dataIdx];
23
+ const xData = dataItem?.[xKey];
24
+ const yData = dataItem?.[yKey];
25
+ // Path error validations - only validates the data for this specific bar
26
+ useEffect(() => {
27
+ // Validate dataKey exists in dataset
28
+ if (context.data.length > 0 &&
29
+ !Object.prototype.hasOwnProperty.call(context.data[0], dataKey)) {
30
+ addError?.('BAR_CHART_PATH_ERROR', {
31
+ error: buildDataKeyNotFoundError(dataKey),
32
+ });
33
+ return; // Stop validation if dataKey doesn't exist
34
+ }
35
+ // Validate bar value is numeric
36
+ const numericValue = Number(yData);
37
+ if (isNaN(numericValue)) {
38
+ addError?.('BAR_CHART_PATH_ERROR', {
39
+ error: buildBarValueError(yData, dataKey),
40
+ });
41
+ return;
42
+ }
43
+ // Validate negative values
44
+ if (numericValue < 0) {
45
+ addError?.('BAR_CHART_PATH_ERROR', {
46
+ error: buildBarNegativeValueError(numericValue, dataKey),
47
+ });
48
+ }
49
+ }, [addError, context.data, dataKey, yData]);
16
50
  const xPoint = getPoints(xTickValues, [String(xData)], true)[0];
17
51
  const yPoint = getPoints(yTickValues, [String(yData)])[0];
18
52
  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,EAAiC,MAAM,OAAO,CAAC;AAI/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAoCxD,CAAC"}
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,CA0FxD,CAAC"}