@kubit-ui-web/react-charts 1.5.1 → 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 (274) 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/focusRing/components/FocusRingInline.d.ts +25 -0
  35. package/dist/cjs/components/focusRing/components/FocusRingInline.d.ts.map +1 -0
  36. package/dist/cjs/components/focusRing/components/FocusRingInline.js +37 -0
  37. package/dist/cjs/components/focusRing/components/FocusRingRenderer.d.ts +13 -0
  38. package/dist/cjs/components/focusRing/components/FocusRingRenderer.d.ts.map +1 -0
  39. package/dist/cjs/components/focusRing/components/FocusRingRenderer.js +25 -0
  40. package/dist/cjs/components/focusRing/components/FocusRingSeparate.d.ts +40 -0
  41. package/dist/cjs/components/focusRing/components/FocusRingSeparate.d.ts.map +1 -0
  42. package/dist/cjs/components/focusRing/components/FocusRingSeparate.js +45 -0
  43. package/dist/cjs/components/focusRing/focusRing.css +14 -0
  44. package/dist/cjs/components/focusRing/focusRing.d.ts +35 -0
  45. package/dist/cjs/components/focusRing/focusRing.d.ts.map +1 -0
  46. package/dist/cjs/components/focusRing/focusRing.js +44 -0
  47. package/dist/cjs/components/focusRing/focusRing.types.d.ts +40 -0
  48. package/dist/cjs/components/focusRing/focusRing.types.d.ts.map +1 -0
  49. package/dist/cjs/components/focusRing/focusRing.types.js +1 -0
  50. package/dist/cjs/components/focusRing/hooks/useFocusRingData.d.ts +27 -0
  51. package/dist/cjs/components/focusRing/hooks/useFocusRingData.d.ts.map +1 -0
  52. package/dist/cjs/components/focusRing/hooks/useFocusRingData.js +67 -0
  53. package/dist/cjs/components/focusRing/index.d.ts +3 -0
  54. package/dist/cjs/components/focusRing/index.d.ts.map +1 -0
  55. package/dist/cjs/components/focusRing/index.js +1 -0
  56. package/dist/cjs/components/focusRing/utils/composeRefs.d.ts +7 -0
  57. package/dist/cjs/components/focusRing/utils/composeRefs.d.ts.map +1 -0
  58. package/dist/cjs/components/focusRing/utils/composeRefs.js +16 -0
  59. package/dist/cjs/components/focusRing/utils/createAdaptiveFocusRings.d.ts +24 -0
  60. package/dist/cjs/components/focusRing/utils/createAdaptiveFocusRings.d.ts.map +1 -0
  61. package/dist/cjs/components/focusRing/utils/createAdaptiveFocusRings.js +141 -0
  62. package/dist/cjs/components/focusRing/utils/createBoundingBoxFocusRings.d.ts +33 -0
  63. package/dist/cjs/components/focusRing/utils/createBoundingBoxFocusRings.d.ts.map +1 -0
  64. package/dist/cjs/components/focusRing/utils/createBoundingBoxFocusRings.js +126 -0
  65. package/dist/cjs/components/focusRing/utils/utils.types.d.ts +52 -0
  66. package/dist/cjs/components/focusRing/utils/utils.types.d.ts.map +1 -0
  67. package/dist/cjs/components/focusRing/utils/utils.types.js +1 -0
  68. package/dist/cjs/components/index.d.ts +1 -0
  69. package/dist/cjs/components/index.d.ts.map +1 -1
  70. package/dist/cjs/components/index.js +1 -0
  71. package/dist/cjs/components/line/line.d.ts.map +1 -1
  72. package/dist/cjs/components/line/line.js +2 -2
  73. package/dist/cjs/components/line/line.types.d.ts +2 -0
  74. package/dist/cjs/components/line/line.types.d.ts.map +1 -1
  75. package/dist/cjs/components/node/node.d.ts.map +1 -1
  76. package/dist/cjs/components/node/node.js +1 -1
  77. package/dist/cjs/components/node/node.types.d.ts +2 -0
  78. package/dist/cjs/components/node/node.types.d.ts.map +1 -1
  79. package/dist/cjs/components/path/path.js +1 -1
  80. package/dist/cjs/components/plot/plot.d.ts.map +1 -1
  81. package/dist/cjs/components/plot/plot.js +7 -19
  82. package/dist/cjs/components/zoomArea/components/SelectionArea.d.ts +3 -23
  83. package/dist/cjs/components/zoomArea/components/SelectionArea.d.ts.map +1 -1
  84. package/dist/cjs/components/zoomArea/components/SelectionArea.js +7 -39
  85. package/dist/cjs/components/zoomArea/components/ZoomHandler.d.ts +3 -3
  86. package/dist/cjs/components/zoomArea/components/ZoomHandler.d.ts.map +1 -1
  87. package/dist/cjs/components/zoomArea/components/ZoomHandler.js +2 -15
  88. package/dist/cjs/components/zoomArea/components/index.d.ts +1 -1
  89. package/dist/cjs/components/zoomArea/components/index.d.ts.map +1 -1
  90. package/dist/cjs/components/zoomArea/components/index.js +1 -1
  91. package/dist/cjs/components/zoomArea/zoomArea.js +6 -6
  92. package/dist/cjs/components/zoomArea/zoomArea.type.d.ts +1 -1
  93. package/dist/cjs/components/zoomArea/zoomArea.type.d.ts.map +1 -1
  94. package/dist/cjs/types/focusConfig.type.d.ts +15 -3
  95. package/dist/cjs/types/focusConfig.type.d.ts.map +1 -1
  96. package/dist/cjs/types/focusConfig.type.js +14 -1
  97. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
  98. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
  99. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
  100. package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
  101. package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  102. package/dist/esm/charts/lineChart/context/buildLineContextValue.js +64 -128
  103. package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
  104. package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  105. package/dist/esm/charts/lineChart/fragments/fixture/contextData.js +8 -6
  106. package/dist/esm/charts/lineChart/fragments/lineChartPath.js +3 -3
  107. package/dist/esm/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
  108. package/dist/esm/charts/lineChart/fragments/lineChartXAxis.js +3 -8
  109. package/dist/esm/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
  110. package/dist/esm/charts/lineChart/fragments/lineChartYAxis.js +9 -9
  111. package/dist/esm/charts/lineChart/lineChart.type.d.ts +12 -7
  112. package/dist/esm/charts/lineChart/lineChart.type.d.ts.map +1 -1
  113. package/dist/esm/charts/lineChart/lineChartStructure.js +11 -10
  114. package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts +25 -0
  115. package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
  116. package/dist/esm/charts/lineChart/utils/getCoordinates.js +55 -0
  117. package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
  118. package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
  119. package/dist/esm/charts/lineChart/utils/getExtraSpacing.js +68 -51
  120. package/dist/esm/charts/lineChart/utils/getTicks.d.ts +21 -0
  121. package/dist/esm/charts/lineChart/utils/getTicks.d.ts.map +1 -0
  122. package/dist/esm/charts/lineChart/utils/getTicks.js +36 -0
  123. package/dist/esm/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
  124. package/dist/esm/charts/lineChart/utils/handleNodesFocus.js +14 -25
  125. package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
  126. package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
  127. package/dist/esm/charts/lineChart/utils/tickTextPosition.js +109 -0
  128. package/dist/esm/charts/lineChart/utils/validations.d.ts +54 -0
  129. package/dist/esm/charts/lineChart/utils/validations.d.ts.map +1 -0
  130. package/dist/esm/charts/lineChart/utils/validations.js +117 -0
  131. package/dist/esm/components/chartText/chartText.d.ts.map +1 -1
  132. package/dist/esm/components/chartText/chartText.js +2 -2
  133. package/dist/esm/components/focusRing/components/FocusRingInline.d.ts +25 -0
  134. package/dist/esm/components/focusRing/components/FocusRingInline.d.ts.map +1 -0
  135. package/dist/esm/components/focusRing/components/FocusRingInline.js +37 -0
  136. package/dist/esm/components/focusRing/components/FocusRingRenderer.d.ts +13 -0
  137. package/dist/esm/components/focusRing/components/FocusRingRenderer.d.ts.map +1 -0
  138. package/dist/esm/components/focusRing/components/FocusRingRenderer.js +25 -0
  139. package/dist/esm/components/focusRing/components/FocusRingSeparate.d.ts +40 -0
  140. package/dist/esm/components/focusRing/components/FocusRingSeparate.d.ts.map +1 -0
  141. package/dist/esm/components/focusRing/components/FocusRingSeparate.js +45 -0
  142. package/dist/esm/components/focusRing/focusRing.css +14 -0
  143. package/dist/esm/components/focusRing/focusRing.d.ts +35 -0
  144. package/dist/esm/components/focusRing/focusRing.d.ts.map +1 -0
  145. package/dist/esm/components/focusRing/focusRing.js +44 -0
  146. package/dist/esm/components/focusRing/focusRing.types.d.ts +40 -0
  147. package/dist/esm/components/focusRing/focusRing.types.d.ts.map +1 -0
  148. package/dist/esm/components/focusRing/focusRing.types.js +1 -0
  149. package/dist/esm/components/focusRing/hooks/useFocusRingData.d.ts +27 -0
  150. package/dist/esm/components/focusRing/hooks/useFocusRingData.d.ts.map +1 -0
  151. package/dist/esm/components/focusRing/hooks/useFocusRingData.js +67 -0
  152. package/dist/esm/components/focusRing/index.d.ts +3 -0
  153. package/dist/esm/components/focusRing/index.d.ts.map +1 -0
  154. package/dist/esm/components/focusRing/index.js +1 -0
  155. package/dist/esm/components/focusRing/utils/composeRefs.d.ts +7 -0
  156. package/dist/esm/components/focusRing/utils/composeRefs.d.ts.map +1 -0
  157. package/dist/esm/components/focusRing/utils/composeRefs.js +16 -0
  158. package/dist/esm/components/focusRing/utils/createAdaptiveFocusRings.d.ts +24 -0
  159. package/dist/esm/components/focusRing/utils/createAdaptiveFocusRings.d.ts.map +1 -0
  160. package/dist/esm/components/focusRing/utils/createAdaptiveFocusRings.js +141 -0
  161. package/dist/esm/components/focusRing/utils/createBoundingBoxFocusRings.d.ts +33 -0
  162. package/dist/esm/components/focusRing/utils/createBoundingBoxFocusRings.d.ts.map +1 -0
  163. package/dist/esm/components/focusRing/utils/createBoundingBoxFocusRings.js +126 -0
  164. package/dist/esm/components/focusRing/utils/utils.types.d.ts +52 -0
  165. package/dist/esm/components/focusRing/utils/utils.types.d.ts.map +1 -0
  166. package/dist/esm/components/focusRing/utils/utils.types.js +1 -0
  167. package/dist/esm/components/index.d.ts +1 -0
  168. package/dist/esm/components/index.d.ts.map +1 -1
  169. package/dist/esm/components/index.js +1 -0
  170. package/dist/esm/components/line/line.d.ts.map +1 -1
  171. package/dist/esm/components/line/line.js +2 -2
  172. package/dist/esm/components/line/line.types.d.ts +2 -0
  173. package/dist/esm/components/line/line.types.d.ts.map +1 -1
  174. package/dist/esm/components/node/node.d.ts.map +1 -1
  175. package/dist/esm/components/node/node.js +1 -1
  176. package/dist/esm/components/node/node.types.d.ts +2 -0
  177. package/dist/esm/components/node/node.types.d.ts.map +1 -1
  178. package/dist/esm/components/path/path.js +1 -1
  179. package/dist/esm/components/plot/plot.d.ts.map +1 -1
  180. package/dist/esm/components/plot/plot.js +7 -19
  181. package/dist/esm/components/zoomArea/components/SelectionArea.d.ts +3 -23
  182. package/dist/esm/components/zoomArea/components/SelectionArea.d.ts.map +1 -1
  183. package/dist/esm/components/zoomArea/components/SelectionArea.js +7 -39
  184. package/dist/esm/components/zoomArea/components/ZoomHandler.d.ts +3 -3
  185. package/dist/esm/components/zoomArea/components/ZoomHandler.d.ts.map +1 -1
  186. package/dist/esm/components/zoomArea/components/ZoomHandler.js +2 -15
  187. package/dist/esm/components/zoomArea/components/index.d.ts +1 -1
  188. package/dist/esm/components/zoomArea/components/index.d.ts.map +1 -1
  189. package/dist/esm/components/zoomArea/components/index.js +1 -1
  190. package/dist/esm/components/zoomArea/zoomArea.js +6 -6
  191. package/dist/esm/components/zoomArea/zoomArea.type.d.ts +1 -1
  192. package/dist/esm/components/zoomArea/zoomArea.type.d.ts.map +1 -1
  193. package/dist/esm/types/focusConfig.type.d.ts +15 -3
  194. package/dist/esm/types/focusConfig.type.d.ts.map +1 -1
  195. package/dist/esm/types/focusConfig.type.js +14 -1
  196. package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
  197. package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
  198. package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
  199. package/dist/kubit-ui-web-react-charts.cjs.js +1 -1
  200. package/dist/kubit-ui-web-react-charts.es.js +1 -1
  201. package/dist/kubit-ui-web-react-charts.umd.js +1 -1
  202. package/dist/react-charts.css +1 -1
  203. package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
  204. package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
  205. package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
  206. package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
  207. package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
  208. package/dist/types/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
  209. package/dist/types/charts/lineChart/lineChart.type.d.ts +12 -7
  210. package/dist/types/charts/lineChart/lineChart.type.d.ts.map +1 -1
  211. package/dist/types/charts/lineChart/utils/getCoordinates.d.ts +25 -0
  212. package/dist/types/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
  213. package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
  214. package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
  215. package/dist/types/charts/lineChart/utils/getTicks.d.ts +21 -0
  216. package/dist/types/charts/lineChart/utils/getTicks.d.ts.map +1 -0
  217. package/dist/types/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
  218. package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
  219. package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
  220. package/dist/types/charts/lineChart/utils/validations.d.ts +54 -0
  221. package/dist/types/charts/lineChart/utils/validations.d.ts.map +1 -0
  222. package/dist/types/components/chartText/chartText.d.ts.map +1 -1
  223. package/dist/types/components/focusRing/components/FocusRingInline.d.ts +25 -0
  224. package/dist/types/components/focusRing/components/FocusRingInline.d.ts.map +1 -0
  225. package/dist/types/components/focusRing/components/FocusRingRenderer.d.ts +13 -0
  226. package/dist/types/components/focusRing/components/FocusRingRenderer.d.ts.map +1 -0
  227. package/dist/types/components/focusRing/components/FocusRingSeparate.d.ts +40 -0
  228. package/dist/types/components/focusRing/components/FocusRingSeparate.d.ts.map +1 -0
  229. package/dist/types/components/focusRing/focusRing.d.ts +34 -0
  230. package/dist/types/components/focusRing/focusRing.d.ts.map +1 -0
  231. package/dist/types/components/focusRing/focusRing.types.d.ts +40 -0
  232. package/dist/types/components/focusRing/focusRing.types.d.ts.map +1 -0
  233. package/dist/types/components/focusRing/hooks/useFocusRingData.d.ts +27 -0
  234. package/dist/types/components/focusRing/hooks/useFocusRingData.d.ts.map +1 -0
  235. package/dist/types/components/focusRing/index.d.ts +3 -0
  236. package/dist/types/components/focusRing/index.d.ts.map +1 -0
  237. package/dist/types/components/focusRing/utils/composeRefs.d.ts +7 -0
  238. package/dist/types/components/focusRing/utils/composeRefs.d.ts.map +1 -0
  239. package/dist/types/components/focusRing/utils/createAdaptiveFocusRings.d.ts +24 -0
  240. package/dist/types/components/focusRing/utils/createAdaptiveFocusRings.d.ts.map +1 -0
  241. package/dist/types/components/focusRing/utils/createBoundingBoxFocusRings.d.ts +33 -0
  242. package/dist/types/components/focusRing/utils/createBoundingBoxFocusRings.d.ts.map +1 -0
  243. package/dist/types/components/focusRing/utils/utils.types.d.ts +52 -0
  244. package/dist/types/components/focusRing/utils/utils.types.d.ts.map +1 -0
  245. package/dist/types/components/index.d.ts +1 -0
  246. package/dist/types/components/index.d.ts.map +1 -1
  247. package/dist/types/components/line/line.d.ts.map +1 -1
  248. package/dist/types/components/line/line.types.d.ts +2 -0
  249. package/dist/types/components/line/line.types.d.ts.map +1 -1
  250. package/dist/types/components/node/node.d.ts.map +1 -1
  251. package/dist/types/components/node/node.types.d.ts +2 -0
  252. package/dist/types/components/node/node.types.d.ts.map +1 -1
  253. package/dist/types/components/plot/plot.d.ts.map +1 -1
  254. package/dist/types/components/zoomArea/components/SelectionArea.d.ts +3 -23
  255. package/dist/types/components/zoomArea/components/SelectionArea.d.ts.map +1 -1
  256. package/dist/types/components/zoomArea/components/ZoomHandler.d.ts +3 -3
  257. package/dist/types/components/zoomArea/components/ZoomHandler.d.ts.map +1 -1
  258. package/dist/types/components/zoomArea/components/index.d.ts +1 -1
  259. package/dist/types/components/zoomArea/components/index.d.ts.map +1 -1
  260. package/dist/types/components/zoomArea/zoomArea.type.d.ts +1 -1
  261. package/dist/types/components/zoomArea/zoomArea.type.d.ts.map +1 -1
  262. package/dist/types/types/focusConfig.type.d.ts +15 -3
  263. package/dist/types/types/focusConfig.type.d.ts.map +1 -1
  264. package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
  265. package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
  266. package/package.json +1 -1
  267. package/dist/cjs/utils/calculateFocusOutline/calculateFocusOutline.d.ts +0 -73
  268. package/dist/cjs/utils/calculateFocusOutline/calculateFocusOutline.d.ts.map +0 -1
  269. package/dist/cjs/utils/calculateFocusOutline/calculateFocusOutline.js +0 -80
  270. package/dist/esm/utils/calculateFocusOutline/calculateFocusOutline.d.ts +0 -73
  271. package/dist/esm/utils/calculateFocusOutline/calculateFocusOutline.d.ts.map +0 -1
  272. package/dist/esm/utils/calculateFocusOutline/calculateFocusOutline.js +0 -80
  273. package/dist/types/utils/calculateFocusOutline/calculateFocusOutline.d.ts +0 -73
  274. package/dist/types/utils/calculateFocusOutline/calculateFocusOutline.d.ts.map +0 -1
@@ -0,0 +1,55 @@
1
+ import { Positions } from '../../../types/position.enum';
2
+ export const getXCoordinates = ({ lineChartXPosition, lineChartYPosition, canvasHeight, canvasWidth, customBreakAxis, xAxisLeftSpacing, xAxisTopSpacing, xAxisRightSpacing, xAxisBottomSpacing, yAxisLeftSpacing, yAxisTopSpacing, yAxisRightSpacing, yAxisBottomSpacing, }) => {
3
+ const x1 = lineChartYPosition === Positions.LEFT ? Math.max(yAxisLeftSpacing, xAxisLeftSpacing) : 0;
4
+ const x2 = lineChartYPosition === Positions.RIGHT
5
+ ? canvasWidth - Math.max(yAxisRightSpacing, xAxisRightSpacing)
6
+ : canvasWidth;
7
+ if (lineChartXPosition === Positions.TOP) {
8
+ return {
9
+ x1,
10
+ x2,
11
+ y1: Math.max(yAxisTopSpacing, xAxisTopSpacing),
12
+ y2: Math.max(yAxisTopSpacing, xAxisTopSpacing),
13
+ };
14
+ }
15
+ if (lineChartXPosition === Positions.CENTER) {
16
+ return { x1, x2, y1: canvasHeight / 2, y2: canvasHeight / 2 };
17
+ }
18
+ if (lineChartXPosition === Positions.CUSTOM) {
19
+ return { x1, x2, y1: customBreakAxis, y2: customBreakAxis };
20
+ }
21
+ // BOTTOM
22
+ return {
23
+ x1,
24
+ x2,
25
+ y1: canvasHeight - Math.max(yAxisBottomSpacing, xAxisBottomSpacing),
26
+ y2: canvasHeight - Math.max(yAxisBottomSpacing, xAxisBottomSpacing),
27
+ };
28
+ };
29
+ export const getYCoordinates = ({ lineChartXPosition, lineChartYPosition, canvasHeight, canvasWidth, customBreakAxis, xAxisLeftSpacing, xAxisTopSpacing, xAxisRightSpacing, xAxisBottomSpacing, yAxisLeftSpacing, yAxisTopSpacing, yAxisRightSpacing, yAxisBottomSpacing, }) => {
30
+ const y1 = lineChartXPosition === Positions.TOP ? Math.max(yAxisTopSpacing, xAxisTopSpacing) : 0;
31
+ const y2 = lineChartXPosition === Positions.BOTTOM
32
+ ? canvasHeight - Math.max(yAxisBottomSpacing, xAxisBottomSpacing)
33
+ : canvasHeight;
34
+ if (lineChartYPosition === Positions.RIGHT) {
35
+ return {
36
+ x1: canvasWidth - Math.max(yAxisRightSpacing, xAxisRightSpacing),
37
+ x2: canvasWidth - Math.max(yAxisRightSpacing, xAxisRightSpacing),
38
+ y1,
39
+ y2,
40
+ };
41
+ }
42
+ if (lineChartYPosition === Positions.CENTER) {
43
+ return { x1: canvasWidth / 2, x2: canvasWidth / 2, y1, y2 };
44
+ }
45
+ if (lineChartYPosition === Positions.CUSTOM) {
46
+ return { x1: customBreakAxis, x2: customBreakAxis, y1, y2 };
47
+ }
48
+ // LEFT
49
+ return {
50
+ x1: Math.max(yAxisLeftSpacing, xAxisLeftSpacing),
51
+ x2: Math.max(yAxisLeftSpacing, xAxisLeftSpacing),
52
+ y1,
53
+ y2,
54
+ };
55
+ };
@@ -3,8 +3,6 @@ interface GetExtraSpacing {
3
3
  children: ChildrenType;
4
4
  data: IDataPoint[];
5
5
  xKey: string;
6
- ajustedX: number;
7
- ajustedY: number;
8
6
  viewBox: string;
9
7
  canvasHeight: number;
10
8
  canvasWidth: number;
@@ -14,6 +12,6 @@ interface GetExtraSpacing {
14
12
  * @param {GetExtraSpacing} options - The options for calculating extra spacing.
15
13
  * @returns {LineChartExtraSpacings} - The calculated extra spacings for the line chart.
16
14
  */
17
- export declare const getExtraSpacing: ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }: GetExtraSpacing) => LineChartExtraSpacings;
15
+ export declare const getExtraSpacing: ({ canvasHeight, canvasWidth, children, data, viewBox, xKey, }: GetExtraSpacing) => LineChartExtraSpacings;
18
16
  export {};
19
17
  //# sourceMappingURL=getExtraSpacing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getExtraSpacing.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getExtraSpacing.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAkH1F,UAAU,eAAe;IACvB,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,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,mFAS7B,eAAe,KAAG,sBAmCpB,CAAC"}
1
+ {"version":3,"file":"getExtraSpacing.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getExtraSpacing.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAiI1F,UAAU,eAAe;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,+DAO7B,eAAe,KAAG,sBAqCpB,CAAC"}
@@ -6,14 +6,20 @@ import { LineChartXAxis } from '../fragments/lineChartXAxis';
6
6
  import { LineChartYAxis } from '../fragments/lineChartYAxis';
7
7
  import { getDataValues } from './getDataValues';
8
8
  import { getYKeyRoundMaxValue } from './getRoundedMaxValue';
9
- const handleLineChartXAxis = (child, data, xKey, ajustedX, viewBox, canvasHeight, canvasWidth) => {
10
- const { position, tickText, tickValues, valueFormatter } = child.props;
9
+ import { getXAxisLeftTextSpacing, getXAxisRightTextSpacing, getYAxisLeftTextSpacing, getYAxisRightTextSpacing, } from './tickTextPosition';
10
+ const getBreakAxis = ({ tickValues, tickText }) => {
11
+ if (tickValues?.numeric) {
12
+ return tickValues.numeric.breakAxis ?? 0;
13
+ }
14
+ return tickText?.custom?.breakAxis ?? 0;
15
+ };
16
+ const handleLineChartXAxis = (child, data, xKey, viewBox, canvasHeight, canvasWidth) => {
17
+ const { position = Positions.BOTTOM, tickText, tickValues, valueFormatter } = child.props;
11
18
  const fontSize = tickText?.fontSize ?? 0;
12
- const spaceFontSize = fontSize * ajustedX;
13
19
  const xData = tickValues ? getDataValues(tickValues) : data.map(d => d[xKey]);
14
20
  // Apply the valueFormatter if provided to get the actual rendered text width
15
21
  const formattedXData = valueFormatter ? xData.map(valueFormatter) : xData;
16
- const securityXSpace = textBound({
22
+ const textWidth = textBound({
17
23
  bound: 'width',
18
24
  data: formattedXData,
19
25
  fontSize,
@@ -21,31 +27,36 @@ const handleLineChartXAxis = (child, data, xKey, ajustedX, viewBox, canvasHeight
21
27
  svgWidth: `${canvasWidth}`,
22
28
  viewBox,
23
29
  });
24
- const isBottomPosition = position === Positions.BOTTOM;
25
- const isTopPosition = position === Positions.TOP;
26
- const extraSpaceBottomY = isBottomPosition ? spaceFontSize + (tickText?.top ?? 0) : 0;
27
- const extraSpaceTopY = isTopPosition ? spaceFontSize + (tickText?.bottom ?? 0) : 0;
28
- const lineChartXPosition = (() => position || Positions.BOTTOM)();
29
- const getBreakAxis = () => {
30
- if (tickValues?.numeric) {
31
- return tickValues.numeric.breakAxis ?? 0;
32
- }
33
- return tickText?.custom?.breakAxis ?? 0;
34
- };
35
- const xBreakAxis = getBreakAxis();
30
+ const textHeight = textBound({
31
+ bound: 'height',
32
+ data: formattedXData,
33
+ fontSize,
34
+ svgHeight: `${canvasHeight}`,
35
+ svgWidth: `${canvasWidth}`,
36
+ viewBox,
37
+ });
38
+ const xAxisBottomSpacing = position === Positions.BOTTOM ? textHeight + (tickText?.top ?? 0) : 0;
39
+ const xAxisTopSpacing = position === Positions.TOP ? textHeight + (tickText?.bottom ?? 0) : 0;
40
+ const xBreakAxis = getBreakAxis({ tickValues, tickText });
36
41
  return {
37
- extraSpaceBottomY,
38
- extraSpaceTopY,
39
- lineChartXPosition,
40
- securityXSpace,
42
+ xAxisLeftSpacing: getXAxisLeftTextSpacing({
43
+ textWidth,
44
+ tickText,
45
+ }),
46
+ xAxisTopSpacing,
47
+ xAxisRightSpacing: getXAxisRightTextSpacing({
48
+ textWidth,
49
+ tickText,
50
+ }),
51
+ xAxisBottomSpacing,
52
+ lineChartXPosition: position,
41
53
  xBreakAxis,
42
54
  xData,
43
55
  };
44
56
  };
45
- const handleLineChartYAxis = (child, data, xKey, ajustedY, viewBox, canvasHeight, canvasWidth) => {
46
- const { position, tickText, tickValues, valueFormatter } = child.props;
47
- const fontSize = tickText?.fontSize ?? '0';
48
- const spaceFontSize = fontSize * ajustedY;
57
+ const handleLineChartYAxis = (child, data, xKey, viewBox, canvasHeight, canvasWidth) => {
58
+ const { position = Positions.LEFT, tickText, tickValues, valueFormatter } = child.props;
59
+ const fontSize = tickText?.fontSize ?? 0;
49
60
  const dataValues = tickValues ||
50
61
  buildTickValues([...new Set(getYKeyRoundMaxValue(data, xKey))]);
51
62
  const yData = getDataValues(dataValues);
@@ -59,26 +70,30 @@ const handleLineChartYAxis = (child, data, xKey, ajustedY, viewBox, canvasHeight
59
70
  svgWidth: `${canvasWidth}`,
60
71
  viewBox,
61
72
  });
62
- const securityYSpace = spaceFontSize;
63
- const isLeftPosition = position === Positions.LEFT;
64
- const isRightPosition = position === Positions.RIGHT;
65
- const extraSpaceLeftX = isLeftPosition ? yAxisText + (tickText?.right ?? 0) : 0;
66
- const extraSpaceRightX = isRightPosition ? yAxisText + (tickText?.left ?? 0) : 0;
67
- const lineChartYPosition = position || Positions.LEFT;
68
- const getBreakAxis = () => {
69
- if (tickValues?.numeric) {
70
- return tickValues.numeric.breakAxis ?? 0;
71
- }
72
- return tickText?.custom?.breakAxis ?? 0;
73
- };
74
- const yBreakAxis = getBreakAxis();
73
+ const textHeight = textBound({
74
+ bound: 'height',
75
+ data: formattedYData,
76
+ fontSize,
77
+ svgHeight: `${canvasHeight}`,
78
+ svgWidth: `${canvasWidth}`,
79
+ viewBox,
80
+ });
75
81
  return {
76
- extraSpaceLeftX,
77
- extraSpaceRightX,
78
- lineChartYPosition,
79
- securityYSpace,
82
+ yAxisLeftSpacing: getYAxisLeftTextSpacing({
83
+ tickText,
84
+ textWidth: yAxisText,
85
+ yAxisPosition: position,
86
+ }),
87
+ yAxisTopSpacing: textHeight,
88
+ yAxisRightSpacing: getYAxisRightTextSpacing({
89
+ tickText,
90
+ textWidth: yAxisText,
91
+ yAxisPosition: position,
92
+ }),
93
+ yAxisBottomSpacing: 0,
94
+ lineChartYPosition: position,
80
95
  yAxisText,
81
- yBreakAxis,
96
+ yBreakAxis: getBreakAxis({ tickValues, tickText }),
82
97
  yData,
83
98
  };
84
99
  };
@@ -87,16 +102,18 @@ const handleLineChartYAxis = (child, data, xKey, ajustedY, viewBox, canvasHeight
87
102
  * @param {GetExtraSpacing} options - The options for calculating extra spacing.
88
103
  * @returns {LineChartExtraSpacings} - The calculated extra spacings for the line chart.
89
104
  */
90
- export const getExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
105
+ export const getExtraSpacing = ({ canvasHeight, canvasWidth, children, data, viewBox, xKey, }) => {
91
106
  let result = {
92
- extraSpaceBottomY: 0,
93
- extraSpaceLeftX: 0,
94
- extraSpaceRightX: 0,
95
- extraSpaceTopY: 0,
107
+ xAxisLeftSpacing: 0,
108
+ xAxisTopSpacing: 0,
109
+ xAxisRightSpacing: 0,
110
+ xAxisBottomSpacing: 0,
111
+ yAxisLeftSpacing: 0,
112
+ yAxisTopSpacing: 0,
113
+ yAxisRightSpacing: 0,
114
+ yAxisBottomSpacing: 0,
96
115
  lineChartXPosition: Positions.BOTTOM,
97
116
  lineChartYPosition: Positions.LEFT,
98
- securityXSpace: 0,
99
- securityYSpace: 0,
100
117
  xAxisText: 0,
101
118
  xBreakAxis: 0,
102
119
  xData: [],
@@ -109,13 +126,13 @@ export const getExtraSpacing = ({ ajustedX, ajustedY, canvasHeight, canvasWidth,
109
126
  if (child.type === LineChartXAxis) {
110
127
  result = {
111
128
  ...result,
112
- ...handleLineChartXAxis(child, data, xKey, ajustedX, viewBox, canvasHeight, canvasWidth),
129
+ ...handleLineChartXAxis(child, data, xKey, viewBox, canvasHeight, canvasWidth),
113
130
  };
114
131
  }
115
132
  else if (child.type === LineChartYAxis) {
116
133
  result = {
117
134
  ...result,
118
- ...handleLineChartYAxis(child, data, xKey, ajustedY, viewBox, canvasHeight, canvasWidth),
135
+ ...handleLineChartYAxis(child, data, xKey, viewBox, canvasHeight, canvasWidth),
119
136
  };
120
137
  }
121
138
  }
@@ -0,0 +1,21 @@
1
+ import type { TickData } from '../../../components/tick/tick.types';
2
+ interface GetXTickProps {
3
+ tickValues: string[];
4
+ maxSpaceAvailable: number;
5
+ xAxisLeftSpacing: number;
6
+ xAxisRightSpacing: number;
7
+ yAxisLeftSpacing: number;
8
+ yAxisRightSpacing: number;
9
+ }
10
+ export declare const getXTicks: ({ tickValues, maxSpaceAvailable, xAxisLeftSpacing, xAxisRightSpacing, yAxisLeftSpacing, yAxisRightSpacing, }: GetXTickProps) => TickData[];
11
+ interface GetYTickProps {
12
+ tickValues: string[];
13
+ maxSpaceAvailable: number;
14
+ xAxisTopSpacing: number;
15
+ xAxisBottomSpacing: number;
16
+ yAxisTopSpacing: number;
17
+ yAxisBottomSpacing: number;
18
+ }
19
+ export declare const getYTicks: ({ maxSpaceAvailable, tickValues, xAxisTopSpacing, xAxisBottomSpacing, yAxisTopSpacing, yAxisBottomSpacing, }: GetYTickProps) => TickData[];
20
+ export {};
21
+ //# sourceMappingURL=getTicks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTicks.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/getTicks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,SAAS,GAAI,8GAOvB,aAAa,KAAG,QAAQ,EAkB1B,CAAC;AAEF,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS,GAAI,8GAOvB,aAAa,KAAG,QAAQ,EAkB1B,CAAC"}
@@ -0,0 +1,36 @@
1
+ export const getXTicks = ({ tickValues, maxSpaceAvailable, xAxisLeftSpacing, xAxisRightSpacing, yAxisLeftSpacing, yAxisRightSpacing, }) => {
2
+ const initPos = Math.max(yAxisLeftSpacing, xAxisLeftSpacing);
3
+ const endPos = maxSpaceAvailable - Math.max(xAxisRightSpacing, yAxisRightSpacing);
4
+ if (tickValues.length <= 1) {
5
+ return [
6
+ {
7
+ position: initPos,
8
+ value: tickValues[0],
9
+ },
10
+ ];
11
+ }
12
+ const step = (endPos - initPos) / (tickValues.length - 1);
13
+ const ticks = tickValues.map((value, idx) => {
14
+ const position = initPos + step * idx;
15
+ return { position, value };
16
+ });
17
+ return ticks;
18
+ };
19
+ export const getYTicks = ({ maxSpaceAvailable, tickValues, xAxisTopSpacing, xAxisBottomSpacing, yAxisTopSpacing, yAxisBottomSpacing, }) => {
20
+ const initPos = maxSpaceAvailable - Math.max(xAxisBottomSpacing, yAxisBottomSpacing);
21
+ const endPos = Math.max(yAxisTopSpacing, xAxisTopSpacing);
22
+ if (tickValues.length <= 1) {
23
+ return [
24
+ {
25
+ position: initPos,
26
+ value: tickValues[0],
27
+ },
28
+ ];
29
+ }
30
+ const step = (initPos - endPos) / (tickValues.length - 1);
31
+ const ticks = tickValues.map((value, idx) => {
32
+ const position = initPos - step * idx;
33
+ return { position, value };
34
+ });
35
+ return ticks;
36
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"handleNodesFocus.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/handleNodesFocus.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,UAAU,qBAAqB;IAC7B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,gBAAgB,GAAI,yCAK9B,qBAAqB,KAAG,sBA8C1B,CAAC"}
1
+ {"version":3,"file":"handleNodesFocus.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/handleNodesFocus.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,UAAU,qBAAqB;IAC7B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,gBAAgB,GAAI,yCAK9B,qBAAqB,KAAG,sBAoC1B,CAAC"}
@@ -1,45 +1,34 @@
1
1
  export const handleNodesFocus = ({ data, getNodeFocusInfo, nodes, ref, }) => {
2
- let refFocused = false;
3
2
  let currentNode = undefined;
4
3
  const g = ref.querySelector('[data-draw]');
5
- //* callbacks
6
4
  const handleKeyDown = (e) => {
7
- if (refFocused) {
8
- if (e.key === 'ArrowRight') {
9
- currentNode =
10
- currentNode === undefined || currentNode === nodes.length - 1 ? 0 : currentNode + 1;
11
- nodes[currentNode].focus();
12
- getNodeFocusInfo?.(data[currentNode]);
13
- }
14
- else if (e.key === 'ArrowLeft') {
15
- currentNode =
16
- currentNode === undefined || currentNode === 0 ? nodes.length - 1 : currentNode - 1;
5
+ let newCurrentNode = undefined;
6
+ if (e.key === 'ArrowRight') {
7
+ newCurrentNode =
8
+ currentNode === undefined || currentNode === nodes.length - 1 ? 0 : currentNode + 1;
9
+ }
10
+ else if (e.key === 'ArrowLeft') {
11
+ newCurrentNode =
12
+ currentNode === undefined || currentNode === 0 ? nodes.length - 1 : currentNode - 1;
13
+ }
14
+ if (newCurrentNode !== undefined) {
15
+ currentNode = newCurrentNode;
16
+ if (nodes[currentNode]) {
17
17
  nodes[currentNode].focus();
18
18
  getNodeFocusInfo?.(data[currentNode]);
19
19
  }
20
20
  }
21
21
  };
22
- const handleFocusin = () => {
23
- refFocused = true;
24
- };
25
- const handleFocusout = () => {
26
- refFocused = false;
27
- };
28
22
  const handleFocus = () => {
29
23
  currentNode = undefined;
30
24
  };
31
- //* listeners
32
25
  const mount = () => {
33
- ref.addEventListener('focusin', handleFocusin);
34
- ref.addEventListener('focusout', handleFocusout);
35
26
  g?.addEventListener('focus', handleFocus);
36
- window.addEventListener('keydown', (e) => handleKeyDown(e));
27
+ ref.addEventListener('keydown', (e) => handleKeyDown(e));
37
28
  };
38
29
  const unmount = () => {
39
- ref.removeEventListener('focusin', handleFocusin);
40
- ref.removeEventListener('focusout', handleFocusout);
41
30
  g?.removeEventListener('focus', handleFocus);
42
- window.removeEventListener('keydown', (e) => handleKeyDown(e));
31
+ ref.removeEventListener('keydown', (e) => handleKeyDown(e));
43
32
  };
44
33
  return { mount, unmount };
45
34
  };
@@ -0,0 +1,33 @@
1
+ import { Positions } from '../../../types/position.enum';
2
+ import type { LineChartXAxisProps, LineChartYAxisProps } from '../lineChart.type';
3
+ type GetYAxisTextXCoordinate = (params: {
4
+ tickText?: LineChartYAxisProps['tickText'];
5
+ yAxisPosition: LineChartYAxisProps['position'];
6
+ textWidth: number;
7
+ yAxisX1: number;
8
+ }) => number;
9
+ export declare const getYAxisTextXCoordinate: GetYAxisTextXCoordinate;
10
+ type GetYAxisLeftTextSpacing = (params: {
11
+ tickText?: LineChartYAxisProps['tickText'];
12
+ textWidth: number;
13
+ yAxisPosition: (typeof Positions)[keyof typeof Positions];
14
+ }) => number;
15
+ export declare const getYAxisLeftTextSpacing: GetYAxisLeftTextSpacing;
16
+ type GetYAxisRightTextSpacing = (params: {
17
+ tickText?: LineChartYAxisProps['tickText'];
18
+ textWidth: number;
19
+ yAxisPosition: (typeof Positions)[keyof typeof Positions];
20
+ }) => number;
21
+ export declare const getYAxisRightTextSpacing: GetYAxisRightTextSpacing;
22
+ type GetXAxisLeftTextSpacing = (params: {
23
+ tickText?: LineChartXAxisProps['tickText'];
24
+ textWidth: number;
25
+ }) => number;
26
+ export declare const getXAxisLeftTextSpacing: GetXAxisLeftTextSpacing;
27
+ type GetXAxisRightTextSpacing = (params: {
28
+ tickText?: LineChartXAxisProps['tickText'];
29
+ textWidth: number;
30
+ }) => number;
31
+ export declare const getXAxisRightTextSpacing: GetXAxisRightTextSpacing;
32
+ export {};
33
+ //# sourceMappingURL=tickTextPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tickTextPosition.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/tickTextPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,aAAa,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBA8BrC,CAAC;AAEF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;CAC3D,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBAmCrC,CAAC;AAEF,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE;IACvC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;CAC3D,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,wBAAwB,EAAE,wBAmCtC,CAAC;AAEF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBASrC,CAAC;AAEF,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE;IACvC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,wBAAwB,EAAE,wBAStC,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { Positions } from '../../../types/position.enum';
2
+ import { ajustedTextSpace } from '../../../utils/ajustedTextSpace/ajustedTextSpace';
3
+ import { getTickTextXCoordinate } from '../../../utils/getTickTextCoordinate/getTickTextCoordinates';
4
+ export const getYAxisTextXCoordinate = ({ tickText, yAxisPosition, textWidth, yAxisX1, }) => {
5
+ if (tickText?.useAxisAsOrigin) {
6
+ let xTickText = yAxisX1;
7
+ xTickText += tickText.right ?? 0;
8
+ xTickText -= tickText.left ?? 0;
9
+ return xTickText;
10
+ }
11
+ // TODO Review this logic, I don't understand the logic behind it
12
+ // Maybe it only makes sense when anchor is middle
13
+ // IMPORTANT: When changing or deleting this logic, review the getYAxisLeftTextSpacing and getYAxisRightTextSpacing functions
14
+ const textAnchor = tickText?.textAnchor || 'middle';
15
+ let ajustedSpace = 0;
16
+ if (yAxisPosition === Positions.RIGHT) {
17
+ ajustedSpace = tickText?.right ?? 0;
18
+ }
19
+ else if (yAxisPosition === Positions.LEFT) {
20
+ ajustedSpace = tickText?.left ?? 0;
21
+ }
22
+ const ajustedText = ajustedTextSpace(textAnchor, textWidth, ajustedSpace);
23
+ const xTickText = getTickTextXCoordinate(yAxisPosition, yAxisX1, ajustedText);
24
+ return xTickText;
25
+ };
26
+ export const getYAxisLeftTextSpacing = ({ tickText, textWidth, yAxisPosition, }) => {
27
+ if (yAxisPosition !== Positions.LEFT) {
28
+ return 0;
29
+ }
30
+ if (tickText?.useAxisAsOrigin) {
31
+ const { textAnchor = 'start' } = tickText;
32
+ let res = 0;
33
+ if (textAnchor === 'end') {
34
+ res = textWidth;
35
+ }
36
+ if (textAnchor === 'middle') {
37
+ res = textWidth / 2;
38
+ }
39
+ res += tickText.left ?? 0;
40
+ res -= tickText.right ?? 0;
41
+ return Math.max(0, res);
42
+ }
43
+ // TODO Review this logic, I don't understand the logic behind it
44
+ // This left spacing is applied because the logic in getYAxisTextXCoordinate
45
+ const textAnchor = tickText?.textAnchor;
46
+ const extraSpace = tickText?.left ?? 0;
47
+ if (textAnchor === 'start') {
48
+ return 0;
49
+ }
50
+ if (textAnchor === 'middle') {
51
+ return textWidth + extraSpace;
52
+ }
53
+ if (textAnchor === 'end') {
54
+ return 2 * textWidth + extraSpace;
55
+ }
56
+ return textWidth / 2 + extraSpace;
57
+ };
58
+ export const getYAxisRightTextSpacing = ({ tickText, textWidth, yAxisPosition, }) => {
59
+ if (yAxisPosition !== Positions.RIGHT) {
60
+ return 0;
61
+ }
62
+ if (tickText?.useAxisAsOrigin) {
63
+ const { textAnchor = 'start' } = tickText;
64
+ let res = textWidth;
65
+ if (textAnchor === 'end') {
66
+ res = 0;
67
+ }
68
+ if (textAnchor === 'middle') {
69
+ res = textWidth / 2;
70
+ }
71
+ res -= tickText.left ?? 0;
72
+ res += tickText.right ?? 0;
73
+ return Math.max(0, res);
74
+ }
75
+ // TODO Review this logic, I don't understand the logic behind it
76
+ // This size is applied because the logic in getYAxisTextXCoordinate
77
+ const textAnchor = tickText?.textAnchor;
78
+ const extraSpace = tickText?.right ?? 0;
79
+ if (textAnchor === 'start') {
80
+ return textWidth;
81
+ }
82
+ if (textAnchor === 'middle') {
83
+ return textWidth + extraSpace;
84
+ }
85
+ if (textAnchor === 'end') {
86
+ return textWidth + extraSpace;
87
+ }
88
+ return 2 * textWidth - textWidth / 2 + extraSpace;
89
+ };
90
+ export const getXAxisLeftTextSpacing = ({ tickText, textWidth }) => {
91
+ const textAnchor = tickText?.textAnchor ?? 'start';
92
+ if (textAnchor === 'start') {
93
+ return 0;
94
+ }
95
+ if (textAnchor === 'middle') {
96
+ return textWidth / 2;
97
+ }
98
+ return textWidth;
99
+ };
100
+ export const getXAxisRightTextSpacing = ({ tickText, textWidth }) => {
101
+ const textAnchor = tickText?.textAnchor ?? 'start';
102
+ if (textAnchor === 'end') {
103
+ return 0;
104
+ }
105
+ if (textAnchor === 'middle') {
106
+ return textWidth / 2;
107
+ }
108
+ return textWidth;
109
+ };
@@ -0,0 +1,54 @@
1
+ import type { TickData } from '../../../components/tick/tick.types';
2
+ import type { ChartError, ErrorType } from '../../../types/errors.type';
3
+ import type { IDataPoint } from '../lineChart.type';
4
+ type ValidateData = (params: {
5
+ data: IDataPoint[];
6
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
7
+ }) => {
8
+ error: Omit<ChartError, 'type'> | undefined;
9
+ };
10
+ export declare const validateData: ValidateData;
11
+ type ValidateCanvasDimensions = (params: {
12
+ canvasWidth: number;
13
+ canvasHeight: number;
14
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
15
+ }) => {
16
+ error: Omit<ChartError, 'type'> | undefined;
17
+ };
18
+ export declare const validateCanvasDimensions: ValidateCanvasDimensions;
19
+ type ValidateYTickValues = (params: {
20
+ yTickValues: TickData[];
21
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
22
+ }) => {
23
+ error: Omit<ChartError, 'type'> | undefined;
24
+ };
25
+ export declare const validateYTickValues: ValidateYTickValues;
26
+ type ValidateXTickValues = (params: {
27
+ xTickValues: TickData[];
28
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
29
+ }) => {
30
+ error: Omit<ChartError, 'type'> | undefined;
31
+ };
32
+ export declare const validateXTickValues: ValidateXTickValues;
33
+ type ValidateXCoordinates = (params: {
34
+ xCoordinates: {
35
+ x1: number;
36
+ x2: number;
37
+ };
38
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
39
+ }) => {
40
+ error: Omit<ChartError, 'type'> | undefined;
41
+ };
42
+ export declare const validateXCoordinates: ValidateXCoordinates;
43
+ type ValidateYCoordinates = (params: {
44
+ yCoordinates: {
45
+ y1: number;
46
+ y2: number;
47
+ };
48
+ addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
49
+ }) => {
50
+ error: Omit<ChartError, 'type'> | undefined;
51
+ };
52
+ export declare const validateYCoordinates: ValidateYCoordinates;
53
+ export {};
54
+ //# sourceMappingURL=validations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/validations.ts"],"names":[],"mappings":"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"}