@gravity-ui/charts 0.1.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 (521) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/cjs/components/Axis/AxisX.d.ts +20 -0
  4. package/dist/cjs/components/Axis/AxisX.js +108 -0
  5. package/dist/cjs/components/Axis/AxisY.d.ts +12 -0
  6. package/dist/cjs/components/Axis/AxisY.js +199 -0
  7. package/dist/cjs/components/Axis/index.d.ts +2 -0
  8. package/dist/cjs/components/Axis/index.js +2 -0
  9. package/dist/cjs/components/Axis/styles.css +17 -0
  10. package/dist/cjs/components/ChartInner/index.d.ts +10 -0
  11. package/dist/cjs/components/ChartInner/index.js +143 -0
  12. package/dist/cjs/components/ChartInner/styles.css +10 -0
  13. package/dist/cjs/components/Legend/index.d.ts +13 -0
  14. package/dist/cjs/components/Legend/index.js +278 -0
  15. package/dist/cjs/components/Legend/styles.css +47 -0
  16. package/dist/cjs/components/PlotTitle/index.d.ts +8 -0
  17. package/dist/cjs/components/PlotTitle/index.js +13 -0
  18. package/dist/cjs/components/PlotTitle/styles.css +5 -0
  19. package/dist/cjs/components/Title/index.d.ts +8 -0
  20. package/dist/cjs/components/Title/index.js +9 -0
  21. package/dist/cjs/components/Title/styles.css +5 -0
  22. package/dist/cjs/components/Tooltip/DefaultContent.d.ts +10 -0
  23. package/dist/cjs/components/Tooltip/DefaultContent.js +101 -0
  24. package/dist/cjs/components/Tooltip/index.d.ts +13 -0
  25. package/dist/cjs/components/Tooltip/index.js +29 -0
  26. package/dist/cjs/components/Tooltip/styles.css +29 -0
  27. package/dist/cjs/components/index.d.ts +18 -0
  28. package/dist/cjs/components/index.js +66 -0
  29. package/dist/cjs/constants/defaults/axis.d.ts +14 -0
  30. package/dist/cjs/constants/defaults/axis.js +18 -0
  31. package/dist/cjs/constants/defaults/index.d.ts +3 -0
  32. package/dist/cjs/constants/defaults/index.js +3 -0
  33. package/dist/cjs/constants/defaults/legend.d.ts +13 -0
  34. package/dist/cjs/constants/defaults/legend.js +12 -0
  35. package/dist/cjs/constants/defaults/series-options.d.ts +24 -0
  36. package/dist/cjs/constants/defaults/series-options.js +106 -0
  37. package/dist/cjs/constants/index.d.ts +46 -0
  38. package/dist/cjs/constants/index.js +71 -0
  39. package/dist/cjs/hooks/index.d.ts +10 -0
  40. package/dist/cjs/hooks/index.js +10 -0
  41. package/dist/cjs/hooks/useAxisScales/index.d.ts +25 -0
  42. package/dist/cjs/hooks/useAxisScales/index.js +183 -0
  43. package/dist/cjs/hooks/useChartDimensions/index.d.ts +16 -0
  44. package/dist/cjs/hooks/useChartDimensions/index.js +34 -0
  45. package/dist/cjs/hooks/useChartDimensions/utils.d.ts +10 -0
  46. package/dist/cjs/hooks/useChartDimensions/utils.js +32 -0
  47. package/dist/cjs/hooks/useChartOptions/chart.d.ts +6 -0
  48. package/dist/cjs/hooks/useChartOptions/chart.js +28 -0
  49. package/dist/cjs/hooks/useChartOptions/index.d.ts +7 -0
  50. package/dist/cjs/hooks/useChartOptions/index.js +21 -0
  51. package/dist/cjs/hooks/useChartOptions/title.d.ts +5 -0
  52. package/dist/cjs/hooks/useChartOptions/title.js +18 -0
  53. package/dist/cjs/hooks/useChartOptions/tooltip.d.ts +5 -0
  54. package/dist/cjs/hooks/useChartOptions/tooltip.js +5 -0
  55. package/dist/cjs/hooks/useChartOptions/types.d.ts +47 -0
  56. package/dist/cjs/hooks/useChartOptions/types.js +1 -0
  57. package/dist/cjs/hooks/useChartOptions/x-axis.d.ts +7 -0
  58. package/dist/cjs/hooks/useChartOptions/x-axis.js +115 -0
  59. package/dist/cjs/hooks/useChartOptions/y-axis.d.ts +7 -0
  60. package/dist/cjs/hooks/useChartOptions/y-axis.js +117 -0
  61. package/dist/cjs/hooks/useSeries/constants.d.ts +8 -0
  62. package/dist/cjs/hooks/useSeries/constants.js +19 -0
  63. package/dist/cjs/hooks/useSeries/index.d.ts +29 -0
  64. package/dist/cjs/hooks/useSeries/index.js +82 -0
  65. package/dist/cjs/hooks/useSeries/prepare-area.d.ts +19 -0
  66. package/dist/cjs/hooks/useSeries/prepare-area.js +63 -0
  67. package/dist/cjs/hooks/useSeries/prepare-bar-x.d.ts +10 -0
  68. package/dist/cjs/hooks/useSeries/prepare-bar-x.js +38 -0
  69. package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +10 -0
  70. package/dist/cjs/hooks/useSeries/prepare-bar-y.js +48 -0
  71. package/dist/cjs/hooks/useSeries/prepare-legend.d.ts +27 -0
  72. package/dist/cjs/hooks/useSeries/prepare-legend.js +144 -0
  73. package/dist/cjs/hooks/useSeries/prepare-line.d.ts +22 -0
  74. package/dist/cjs/hooks/useSeries/prepare-line.js +82 -0
  75. package/dist/cjs/hooks/useSeries/prepare-options.d.ts +3 -0
  76. package/dist/cjs/hooks/useSeries/prepare-options.js +5 -0
  77. package/dist/cjs/hooks/useSeries/prepare-pie.d.ts +9 -0
  78. package/dist/cjs/hooks/useSeries/prepare-pie.js +62 -0
  79. package/dist/cjs/hooks/useSeries/prepare-scatter.d.ts +11 -0
  80. package/dist/cjs/hooks/useSeries/prepare-scatter.js +46 -0
  81. package/dist/cjs/hooks/useSeries/prepare-treemap.d.ts +11 -0
  82. package/dist/cjs/hooks/useSeries/prepare-treemap.js +38 -0
  83. package/dist/cjs/hooks/useSeries/prepare-waterfall.d.ts +10 -0
  84. package/dist/cjs/hooks/useSeries/prepare-waterfall.js +37 -0
  85. package/dist/cjs/hooks/useSeries/prepareSeries.d.ts +10 -0
  86. package/dist/cjs/hooks/useSeries/prepareSeries.js +65 -0
  87. package/dist/cjs/hooks/useSeries/types.d.ts +253 -0
  88. package/dist/cjs/hooks/useSeries/types.js +1 -0
  89. package/dist/cjs/hooks/useSeries/utils.d.ts +7 -0
  90. package/dist/cjs/hooks/useSeries/utils.js +33 -0
  91. package/dist/cjs/hooks/useShapes/HtmlLayer.d.ts +8 -0
  92. package/dist/cjs/hooks/useShapes/HtmlLayer.js +22 -0
  93. package/dist/cjs/hooks/useShapes/area/index.d.ts +12 -0
  94. package/dist/cjs/hooks/useShapes/area/index.js +143 -0
  95. package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +12 -0
  96. package/dist/cjs/hooks/useShapes/area/prepare-data.js +158 -0
  97. package/dist/cjs/hooks/useShapes/area/types.d.ts +27 -0
  98. package/dist/cjs/hooks/useShapes/area/types.js +1 -0
  99. package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +13 -0
  100. package/dist/cjs/hooks/useShapes/bar-x/index.js +95 -0
  101. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +13 -0
  102. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +160 -0
  103. package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +12 -0
  104. package/dist/cjs/hooks/useShapes/bar-x/types.js +1 -0
  105. package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +12 -0
  106. package/dist/cjs/hooks/useShapes/bar-y/index.js +84 -0
  107. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +12 -0
  108. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +169 -0
  109. package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +13 -0
  110. package/dist/cjs/hooks/useShapes/bar-y/types.js +1 -0
  111. package/dist/cjs/hooks/useShapes/constants.d.ts +3 -0
  112. package/dist/cjs/hooks/useShapes/constants.js +3 -0
  113. package/dist/cjs/hooks/useShapes/index.d.ts +33 -0
  114. package/dist/cjs/hooks/useShapes/index.js +154 -0
  115. package/dist/cjs/hooks/useShapes/line/index.d.ts +12 -0
  116. package/dist/cjs/hooks/useShapes/line/index.js +130 -0
  117. package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +13 -0
  118. package/dist/cjs/hooks/useShapes/line/prepare-data.js +91 -0
  119. package/dist/cjs/hooks/useShapes/line/types.d.ts +29 -0
  120. package/dist/cjs/hooks/useShapes/line/types.js +1 -0
  121. package/dist/cjs/hooks/useShapes/marker.d.ts +14 -0
  122. package/dist/cjs/hooks/useShapes/marker.js +75 -0
  123. package/dist/cjs/hooks/useShapes/pie/index.d.ts +13 -0
  124. package/dist/cjs/hooks/useShapes/pie/index.js +171 -0
  125. package/dist/cjs/hooks/useShapes/pie/prepare-data.d.ts +9 -0
  126. package/dist/cjs/hooks/useShapes/pie/prepare-data.js +186 -0
  127. package/dist/cjs/hooks/useShapes/pie/types.d.ts +41 -0
  128. package/dist/cjs/hooks/useShapes/pie/types.js +1 -0
  129. package/dist/cjs/hooks/useShapes/pie/utils.d.ts +4 -0
  130. package/dist/cjs/hooks/useShapes/pie/utils.js +15 -0
  131. package/dist/cjs/hooks/useShapes/scatter/index.d.ts +12 -0
  132. package/dist/cjs/hooks/useShapes/scatter/index.js +69 -0
  133. package/dist/cjs/hooks/useShapes/scatter/prepare-data.d.ts +11 -0
  134. package/dist/cjs/hooks/useShapes/scatter/prepare-data.js +31 -0
  135. package/dist/cjs/hooks/useShapes/scatter/types.d.ts +17 -0
  136. package/dist/cjs/hooks/useShapes/scatter/types.js +1 -0
  137. package/dist/cjs/hooks/useShapes/styles.css +35 -0
  138. package/dist/cjs/hooks/useShapes/treemap/index.d.ts +12 -0
  139. package/dist/cjs/hooks/useShapes/treemap/index.js +98 -0
  140. package/dist/cjs/hooks/useShapes/treemap/prepare-data.d.ts +7 -0
  141. package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +114 -0
  142. package/dist/cjs/hooks/useShapes/treemap/types.d.ts +16 -0
  143. package/dist/cjs/hooks/useShapes/treemap/types.js +1 -0
  144. package/dist/cjs/hooks/useShapes/utils.d.ts +29 -0
  145. package/dist/cjs/hooks/useShapes/utils.js +53 -0
  146. package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +13 -0
  147. package/dist/cjs/hooks/useShapes/waterfall/index.js +127 -0
  148. package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +12 -0
  149. package/dist/cjs/hooks/useShapes/waterfall/prepare-data.js +133 -0
  150. package/dist/cjs/hooks/useShapes/waterfall/types.d.ts +14 -0
  151. package/dist/cjs/hooks/useShapes/waterfall/types.js +1 -0
  152. package/dist/cjs/hooks/useSplit/index.d.ts +14 -0
  153. package/dist/cjs/hooks/useSplit/index.js +57 -0
  154. package/dist/cjs/hooks/useSplit/types.d.ts +17 -0
  155. package/dist/cjs/hooks/useSplit/types.js +1 -0
  156. package/dist/cjs/hooks/useTooltip/index.d.ts +13 -0
  157. package/dist/cjs/hooks/useTooltip/index.js +17 -0
  158. package/dist/cjs/hooks/useTooltip/types.d.ts +1 -0
  159. package/dist/cjs/hooks/useTooltip/types.js +1 -0
  160. package/dist/cjs/i18n/index.d.ts +8 -0
  161. package/dist/cjs/i18n/index.js +10 -0
  162. package/dist/cjs/index.d.ts +2 -0
  163. package/dist/cjs/index.js +1 -0
  164. package/dist/cjs/libs/chart-error/index.d.ts +16 -0
  165. package/dist/cjs/libs/chart-error/index.js +19 -0
  166. package/dist/cjs/libs/format-number/i18n/en.json +17 -0
  167. package/dist/cjs/libs/format-number/i18n/i18n.d.ts +5 -0
  168. package/dist/cjs/libs/format-number/i18n/i18n.js +8 -0
  169. package/dist/cjs/libs/format-number/i18n/ru.json +17 -0
  170. package/dist/cjs/libs/format-number/index.d.ts +5 -0
  171. package/dist/cjs/libs/format-number/index.js +87 -0
  172. package/dist/cjs/libs/format-number/types.d.ts +14 -0
  173. package/dist/cjs/libs/format-number/types.js +1 -0
  174. package/dist/cjs/libs/index.d.ts +2 -0
  175. package/dist/cjs/libs/index.js +2 -0
  176. package/dist/cjs/types/chart/area.d.ts +76 -0
  177. package/dist/cjs/types/chart/area.js +1 -0
  178. package/dist/cjs/types/chart/axis.d.ts +85 -0
  179. package/dist/cjs/types/chart/axis.js +1 -0
  180. package/dist/cjs/types/chart/bar-x.d.ts +67 -0
  181. package/dist/cjs/types/chart/bar-x.js +1 -0
  182. package/dist/cjs/types/chart/bar-y.d.ts +60 -0
  183. package/dist/cjs/types/chart/bar-y.js +1 -0
  184. package/dist/cjs/types/chart/base.d.ts +48 -0
  185. package/dist/cjs/types/chart/base.js +1 -0
  186. package/dist/cjs/types/chart/chart.d.ts +15 -0
  187. package/dist/cjs/types/chart/chart.js +1 -0
  188. package/dist/cjs/types/chart/halo.d.ts +9 -0
  189. package/dist/cjs/types/chart/halo.js +1 -0
  190. package/dist/cjs/types/chart/legend.d.ts +92 -0
  191. package/dist/cjs/types/chart/legend.js +1 -0
  192. package/dist/cjs/types/chart/line.d.ts +57 -0
  193. package/dist/cjs/types/chart/line.js +1 -0
  194. package/dist/cjs/types/chart/marker.d.ts +12 -0
  195. package/dist/cjs/types/chart/marker.js +1 -0
  196. package/dist/cjs/types/chart/pie.d.ts +88 -0
  197. package/dist/cjs/types/chart/pie.js +1 -0
  198. package/dist/cjs/types/chart/scatter.d.ts +46 -0
  199. package/dist/cjs/types/chart/scatter.js +1 -0
  200. package/dist/cjs/types/chart/series.d.ts +226 -0
  201. package/dist/cjs/types/chart/series.js +1 -0
  202. package/dist/cjs/types/chart/split.d.ts +13 -0
  203. package/dist/cjs/types/chart/split.js +1 -0
  204. package/dist/cjs/types/chart/title.d.ts +5 -0
  205. package/dist/cjs/types/chart/title.js +1 -0
  206. package/dist/cjs/types/chart/tooltip.d.ts +67 -0
  207. package/dist/cjs/types/chart/tooltip.js +1 -0
  208. package/dist/cjs/types/chart/treemap.d.ts +46 -0
  209. package/dist/cjs/types/chart/treemap.js +1 -0
  210. package/dist/cjs/types/chart/waterfall.d.ts +40 -0
  211. package/dist/cjs/types/chart/waterfall.js +1 -0
  212. package/dist/cjs/types/chart-ui.d.ts +24 -0
  213. package/dist/cjs/types/chart-ui.js +1 -0
  214. package/dist/cjs/types/formatter.d.ts +14 -0
  215. package/dist/cjs/types/formatter.js +1 -0
  216. package/dist/cjs/types/index.d.ts +42 -0
  217. package/dist/cjs/types/index.js +19 -0
  218. package/dist/cjs/types/misc.d.ts +4 -0
  219. package/dist/cjs/types/misc.js +1 -0
  220. package/dist/cjs/utils/chart/axis-generators/bottom.d.ts +24 -0
  221. package/dist/cjs/utils/chart/axis-generators/bottom.js +126 -0
  222. package/dist/cjs/utils/chart/axis-generators/index.d.ts +1 -0
  223. package/dist/cjs/utils/chart/axis-generators/index.js +1 -0
  224. package/dist/cjs/utils/chart/axis.d.ts +31 -0
  225. package/dist/cjs/utils/chart/axis.js +71 -0
  226. package/dist/cjs/utils/chart/color.d.ts +10 -0
  227. package/dist/cjs/utils/chart/color.js +43 -0
  228. package/dist/cjs/utils/chart/get-closest-data.d.ts +15 -0
  229. package/dist/cjs/utils/chart/get-closest-data.js +172 -0
  230. package/dist/cjs/utils/chart/index.d.ts +78 -0
  231. package/dist/cjs/utils/chart/index.js +210 -0
  232. package/dist/cjs/utils/chart/labels.d.ts +6 -0
  233. package/dist/cjs/utils/chart/labels.js +44 -0
  234. package/dist/cjs/utils/chart/legend.d.ts +8 -0
  235. package/dist/cjs/utils/chart/legend.js +23 -0
  236. package/dist/cjs/utils/chart/math.d.ts +25 -0
  237. package/dist/cjs/utils/chart/math.js +51 -0
  238. package/dist/cjs/utils/chart/series/index.d.ts +1 -0
  239. package/dist/cjs/utils/chart/series/index.js +1 -0
  240. package/dist/cjs/utils/chart/series/waterfall.d.ts +4 -0
  241. package/dist/cjs/utils/chart/series/waterfall.js +25 -0
  242. package/dist/cjs/utils/chart/symbol.d.ts +3 -0
  243. package/dist/cjs/utils/chart/symbol.js +36 -0
  244. package/dist/cjs/utils/chart/text.d.ts +29 -0
  245. package/dist/cjs/utils/chart/text.js +139 -0
  246. package/dist/cjs/utils/chart/time.d.ts +3 -0
  247. package/dist/cjs/utils/chart/time.js +34 -0
  248. package/dist/cjs/utils/chart-ui/index.d.ts +4 -0
  249. package/dist/cjs/utils/chart-ui/index.js +4 -0
  250. package/dist/cjs/utils/chart-ui/pie-center-text.d.ts +7 -0
  251. package/dist/cjs/utils/chart-ui/pie-center-text.js +23 -0
  252. package/dist/cjs/utils/cn.d.ts +3 -0
  253. package/dist/cjs/utils/cn.js +4 -0
  254. package/dist/cjs/utils/d3-dispatcher.d.ts +1 -0
  255. package/dist/cjs/utils/d3-dispatcher.js +4 -0
  256. package/dist/cjs/utils/index.d.ts +5 -0
  257. package/dist/cjs/utils/index.js +5 -0
  258. package/dist/cjs/utils/misc.d.ts +2 -0
  259. package/dist/cjs/utils/misc.js +8 -0
  260. package/dist/cjs/validation/index.d.ts +2 -0
  261. package/dist/cjs/validation/index.js +220 -0
  262. package/dist/esm/components/Axis/AxisX.d.ts +20 -0
  263. package/dist/esm/components/Axis/AxisX.js +108 -0
  264. package/dist/esm/components/Axis/AxisY.d.ts +12 -0
  265. package/dist/esm/components/Axis/AxisY.js +199 -0
  266. package/dist/esm/components/Axis/index.d.ts +2 -0
  267. package/dist/esm/components/Axis/index.js +2 -0
  268. package/dist/esm/components/Axis/styles.css +17 -0
  269. package/dist/esm/components/ChartInner/index.d.ts +10 -0
  270. package/dist/esm/components/ChartInner/index.js +143 -0
  271. package/dist/esm/components/ChartInner/styles.css +10 -0
  272. package/dist/esm/components/Legend/index.d.ts +13 -0
  273. package/dist/esm/components/Legend/index.js +278 -0
  274. package/dist/esm/components/Legend/styles.css +47 -0
  275. package/dist/esm/components/PlotTitle/index.d.ts +8 -0
  276. package/dist/esm/components/PlotTitle/index.js +13 -0
  277. package/dist/esm/components/PlotTitle/styles.css +5 -0
  278. package/dist/esm/components/Title/index.d.ts +8 -0
  279. package/dist/esm/components/Title/index.js +9 -0
  280. package/dist/esm/components/Title/styles.css +5 -0
  281. package/dist/esm/components/Tooltip/DefaultContent.d.ts +10 -0
  282. package/dist/esm/components/Tooltip/DefaultContent.js +101 -0
  283. package/dist/esm/components/Tooltip/index.d.ts +13 -0
  284. package/dist/esm/components/Tooltip/index.js +29 -0
  285. package/dist/esm/components/Tooltip/styles.css +29 -0
  286. package/dist/esm/components/index.d.ts +18 -0
  287. package/dist/esm/components/index.js +66 -0
  288. package/dist/esm/constants/defaults/axis.d.ts +14 -0
  289. package/dist/esm/constants/defaults/axis.js +18 -0
  290. package/dist/esm/constants/defaults/index.d.ts +3 -0
  291. package/dist/esm/constants/defaults/index.js +3 -0
  292. package/dist/esm/constants/defaults/legend.d.ts +13 -0
  293. package/dist/esm/constants/defaults/legend.js +12 -0
  294. package/dist/esm/constants/defaults/series-options.d.ts +24 -0
  295. package/dist/esm/constants/defaults/series-options.js +106 -0
  296. package/dist/esm/constants/index.d.ts +46 -0
  297. package/dist/esm/constants/index.js +71 -0
  298. package/dist/esm/hooks/index.d.ts +10 -0
  299. package/dist/esm/hooks/index.js +10 -0
  300. package/dist/esm/hooks/useAxisScales/index.d.ts +25 -0
  301. package/dist/esm/hooks/useAxisScales/index.js +183 -0
  302. package/dist/esm/hooks/useChartDimensions/index.d.ts +16 -0
  303. package/dist/esm/hooks/useChartDimensions/index.js +34 -0
  304. package/dist/esm/hooks/useChartDimensions/utils.d.ts +10 -0
  305. package/dist/esm/hooks/useChartDimensions/utils.js +32 -0
  306. package/dist/esm/hooks/useChartOptions/chart.d.ts +6 -0
  307. package/dist/esm/hooks/useChartOptions/chart.js +28 -0
  308. package/dist/esm/hooks/useChartOptions/index.d.ts +7 -0
  309. package/dist/esm/hooks/useChartOptions/index.js +21 -0
  310. package/dist/esm/hooks/useChartOptions/title.d.ts +5 -0
  311. package/dist/esm/hooks/useChartOptions/title.js +18 -0
  312. package/dist/esm/hooks/useChartOptions/tooltip.d.ts +5 -0
  313. package/dist/esm/hooks/useChartOptions/tooltip.js +5 -0
  314. package/dist/esm/hooks/useChartOptions/types.d.ts +47 -0
  315. package/dist/esm/hooks/useChartOptions/types.js +1 -0
  316. package/dist/esm/hooks/useChartOptions/x-axis.d.ts +7 -0
  317. package/dist/esm/hooks/useChartOptions/x-axis.js +115 -0
  318. package/dist/esm/hooks/useChartOptions/y-axis.d.ts +7 -0
  319. package/dist/esm/hooks/useChartOptions/y-axis.js +117 -0
  320. package/dist/esm/hooks/useSeries/constants.d.ts +8 -0
  321. package/dist/esm/hooks/useSeries/constants.js +19 -0
  322. package/dist/esm/hooks/useSeries/index.d.ts +29 -0
  323. package/dist/esm/hooks/useSeries/index.js +82 -0
  324. package/dist/esm/hooks/useSeries/prepare-area.d.ts +19 -0
  325. package/dist/esm/hooks/useSeries/prepare-area.js +63 -0
  326. package/dist/esm/hooks/useSeries/prepare-bar-x.d.ts +10 -0
  327. package/dist/esm/hooks/useSeries/prepare-bar-x.js +38 -0
  328. package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +10 -0
  329. package/dist/esm/hooks/useSeries/prepare-bar-y.js +48 -0
  330. package/dist/esm/hooks/useSeries/prepare-legend.d.ts +27 -0
  331. package/dist/esm/hooks/useSeries/prepare-legend.js +144 -0
  332. package/dist/esm/hooks/useSeries/prepare-line.d.ts +22 -0
  333. package/dist/esm/hooks/useSeries/prepare-line.js +82 -0
  334. package/dist/esm/hooks/useSeries/prepare-options.d.ts +3 -0
  335. package/dist/esm/hooks/useSeries/prepare-options.js +5 -0
  336. package/dist/esm/hooks/useSeries/prepare-pie.d.ts +9 -0
  337. package/dist/esm/hooks/useSeries/prepare-pie.js +62 -0
  338. package/dist/esm/hooks/useSeries/prepare-scatter.d.ts +11 -0
  339. package/dist/esm/hooks/useSeries/prepare-scatter.js +46 -0
  340. package/dist/esm/hooks/useSeries/prepare-treemap.d.ts +11 -0
  341. package/dist/esm/hooks/useSeries/prepare-treemap.js +38 -0
  342. package/dist/esm/hooks/useSeries/prepare-waterfall.d.ts +10 -0
  343. package/dist/esm/hooks/useSeries/prepare-waterfall.js +37 -0
  344. package/dist/esm/hooks/useSeries/prepareSeries.d.ts +10 -0
  345. package/dist/esm/hooks/useSeries/prepareSeries.js +65 -0
  346. package/dist/esm/hooks/useSeries/types.d.ts +253 -0
  347. package/dist/esm/hooks/useSeries/types.js +1 -0
  348. package/dist/esm/hooks/useSeries/utils.d.ts +7 -0
  349. package/dist/esm/hooks/useSeries/utils.js +33 -0
  350. package/dist/esm/hooks/useShapes/HtmlLayer.d.ts +8 -0
  351. package/dist/esm/hooks/useShapes/HtmlLayer.js +22 -0
  352. package/dist/esm/hooks/useShapes/area/index.d.ts +12 -0
  353. package/dist/esm/hooks/useShapes/area/index.js +143 -0
  354. package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +12 -0
  355. package/dist/esm/hooks/useShapes/area/prepare-data.js +158 -0
  356. package/dist/esm/hooks/useShapes/area/types.d.ts +27 -0
  357. package/dist/esm/hooks/useShapes/area/types.js +1 -0
  358. package/dist/esm/hooks/useShapes/bar-x/index.d.ts +13 -0
  359. package/dist/esm/hooks/useShapes/bar-x/index.js +95 -0
  360. package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +13 -0
  361. package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +160 -0
  362. package/dist/esm/hooks/useShapes/bar-x/types.d.ts +12 -0
  363. package/dist/esm/hooks/useShapes/bar-x/types.js +1 -0
  364. package/dist/esm/hooks/useShapes/bar-y/index.d.ts +12 -0
  365. package/dist/esm/hooks/useShapes/bar-y/index.js +84 -0
  366. package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +12 -0
  367. package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +169 -0
  368. package/dist/esm/hooks/useShapes/bar-y/types.d.ts +13 -0
  369. package/dist/esm/hooks/useShapes/bar-y/types.js +1 -0
  370. package/dist/esm/hooks/useShapes/constants.d.ts +3 -0
  371. package/dist/esm/hooks/useShapes/constants.js +3 -0
  372. package/dist/esm/hooks/useShapes/index.d.ts +33 -0
  373. package/dist/esm/hooks/useShapes/index.js +154 -0
  374. package/dist/esm/hooks/useShapes/line/index.d.ts +12 -0
  375. package/dist/esm/hooks/useShapes/line/index.js +130 -0
  376. package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +13 -0
  377. package/dist/esm/hooks/useShapes/line/prepare-data.js +91 -0
  378. package/dist/esm/hooks/useShapes/line/types.d.ts +29 -0
  379. package/dist/esm/hooks/useShapes/line/types.js +1 -0
  380. package/dist/esm/hooks/useShapes/marker.d.ts +14 -0
  381. package/dist/esm/hooks/useShapes/marker.js +75 -0
  382. package/dist/esm/hooks/useShapes/pie/index.d.ts +13 -0
  383. package/dist/esm/hooks/useShapes/pie/index.js +171 -0
  384. package/dist/esm/hooks/useShapes/pie/prepare-data.d.ts +9 -0
  385. package/dist/esm/hooks/useShapes/pie/prepare-data.js +186 -0
  386. package/dist/esm/hooks/useShapes/pie/types.d.ts +41 -0
  387. package/dist/esm/hooks/useShapes/pie/types.js +1 -0
  388. package/dist/esm/hooks/useShapes/pie/utils.d.ts +4 -0
  389. package/dist/esm/hooks/useShapes/pie/utils.js +15 -0
  390. package/dist/esm/hooks/useShapes/scatter/index.d.ts +12 -0
  391. package/dist/esm/hooks/useShapes/scatter/index.js +69 -0
  392. package/dist/esm/hooks/useShapes/scatter/prepare-data.d.ts +11 -0
  393. package/dist/esm/hooks/useShapes/scatter/prepare-data.js +31 -0
  394. package/dist/esm/hooks/useShapes/scatter/types.d.ts +17 -0
  395. package/dist/esm/hooks/useShapes/scatter/types.js +1 -0
  396. package/dist/esm/hooks/useShapes/styles.css +35 -0
  397. package/dist/esm/hooks/useShapes/treemap/index.d.ts +12 -0
  398. package/dist/esm/hooks/useShapes/treemap/index.js +98 -0
  399. package/dist/esm/hooks/useShapes/treemap/prepare-data.d.ts +7 -0
  400. package/dist/esm/hooks/useShapes/treemap/prepare-data.js +114 -0
  401. package/dist/esm/hooks/useShapes/treemap/types.d.ts +16 -0
  402. package/dist/esm/hooks/useShapes/treemap/types.js +1 -0
  403. package/dist/esm/hooks/useShapes/utils.d.ts +29 -0
  404. package/dist/esm/hooks/useShapes/utils.js +53 -0
  405. package/dist/esm/hooks/useShapes/waterfall/index.d.ts +13 -0
  406. package/dist/esm/hooks/useShapes/waterfall/index.js +127 -0
  407. package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +12 -0
  408. package/dist/esm/hooks/useShapes/waterfall/prepare-data.js +133 -0
  409. package/dist/esm/hooks/useShapes/waterfall/types.d.ts +14 -0
  410. package/dist/esm/hooks/useShapes/waterfall/types.js +1 -0
  411. package/dist/esm/hooks/useSplit/index.d.ts +14 -0
  412. package/dist/esm/hooks/useSplit/index.js +57 -0
  413. package/dist/esm/hooks/useSplit/types.d.ts +17 -0
  414. package/dist/esm/hooks/useSplit/types.js +1 -0
  415. package/dist/esm/hooks/useTooltip/index.d.ts +13 -0
  416. package/dist/esm/hooks/useTooltip/index.js +17 -0
  417. package/dist/esm/hooks/useTooltip/types.d.ts +1 -0
  418. package/dist/esm/hooks/useTooltip/types.js +1 -0
  419. package/dist/esm/i18n/index.d.ts +8 -0
  420. package/dist/esm/i18n/index.js +10 -0
  421. package/dist/esm/index.d.ts +2 -0
  422. package/dist/esm/index.js +1 -0
  423. package/dist/esm/libs/chart-error/index.d.ts +16 -0
  424. package/dist/esm/libs/chart-error/index.js +19 -0
  425. package/dist/esm/libs/format-number/i18n/en.json +17 -0
  426. package/dist/esm/libs/format-number/i18n/i18n.d.ts +5 -0
  427. package/dist/esm/libs/format-number/i18n/i18n.js +8 -0
  428. package/dist/esm/libs/format-number/i18n/ru.json +17 -0
  429. package/dist/esm/libs/format-number/index.d.ts +5 -0
  430. package/dist/esm/libs/format-number/index.js +87 -0
  431. package/dist/esm/libs/format-number/types.d.ts +14 -0
  432. package/dist/esm/libs/format-number/types.js +1 -0
  433. package/dist/esm/libs/index.d.ts +2 -0
  434. package/dist/esm/libs/index.js +2 -0
  435. package/dist/esm/types/chart/area.d.ts +76 -0
  436. package/dist/esm/types/chart/area.js +1 -0
  437. package/dist/esm/types/chart/axis.d.ts +85 -0
  438. package/dist/esm/types/chart/axis.js +1 -0
  439. package/dist/esm/types/chart/bar-x.d.ts +67 -0
  440. package/dist/esm/types/chart/bar-x.js +1 -0
  441. package/dist/esm/types/chart/bar-y.d.ts +60 -0
  442. package/dist/esm/types/chart/bar-y.js +1 -0
  443. package/dist/esm/types/chart/base.d.ts +48 -0
  444. package/dist/esm/types/chart/base.js +1 -0
  445. package/dist/esm/types/chart/chart.d.ts +15 -0
  446. package/dist/esm/types/chart/chart.js +1 -0
  447. package/dist/esm/types/chart/halo.d.ts +9 -0
  448. package/dist/esm/types/chart/halo.js +1 -0
  449. package/dist/esm/types/chart/legend.d.ts +92 -0
  450. package/dist/esm/types/chart/legend.js +1 -0
  451. package/dist/esm/types/chart/line.d.ts +57 -0
  452. package/dist/esm/types/chart/line.js +1 -0
  453. package/dist/esm/types/chart/marker.d.ts +12 -0
  454. package/dist/esm/types/chart/marker.js +1 -0
  455. package/dist/esm/types/chart/pie.d.ts +88 -0
  456. package/dist/esm/types/chart/pie.js +1 -0
  457. package/dist/esm/types/chart/scatter.d.ts +46 -0
  458. package/dist/esm/types/chart/scatter.js +1 -0
  459. package/dist/esm/types/chart/series.d.ts +226 -0
  460. package/dist/esm/types/chart/series.js +1 -0
  461. package/dist/esm/types/chart/split.d.ts +13 -0
  462. package/dist/esm/types/chart/split.js +1 -0
  463. package/dist/esm/types/chart/title.d.ts +5 -0
  464. package/dist/esm/types/chart/title.js +1 -0
  465. package/dist/esm/types/chart/tooltip.d.ts +67 -0
  466. package/dist/esm/types/chart/tooltip.js +1 -0
  467. package/dist/esm/types/chart/treemap.d.ts +46 -0
  468. package/dist/esm/types/chart/treemap.js +1 -0
  469. package/dist/esm/types/chart/waterfall.d.ts +40 -0
  470. package/dist/esm/types/chart/waterfall.js +1 -0
  471. package/dist/esm/types/chart-ui.d.ts +24 -0
  472. package/dist/esm/types/chart-ui.js +1 -0
  473. package/dist/esm/types/formatter.d.ts +14 -0
  474. package/dist/esm/types/formatter.js +1 -0
  475. package/dist/esm/types/index.d.ts +42 -0
  476. package/dist/esm/types/index.js +19 -0
  477. package/dist/esm/types/misc.d.ts +4 -0
  478. package/dist/esm/types/misc.js +1 -0
  479. package/dist/esm/utils/chart/axis-generators/bottom.d.ts +24 -0
  480. package/dist/esm/utils/chart/axis-generators/bottom.js +126 -0
  481. package/dist/esm/utils/chart/axis-generators/index.d.ts +1 -0
  482. package/dist/esm/utils/chart/axis-generators/index.js +1 -0
  483. package/dist/esm/utils/chart/axis.d.ts +31 -0
  484. package/dist/esm/utils/chart/axis.js +71 -0
  485. package/dist/esm/utils/chart/color.d.ts +10 -0
  486. package/dist/esm/utils/chart/color.js +43 -0
  487. package/dist/esm/utils/chart/get-closest-data.d.ts +15 -0
  488. package/dist/esm/utils/chart/get-closest-data.js +172 -0
  489. package/dist/esm/utils/chart/index.d.ts +78 -0
  490. package/dist/esm/utils/chart/index.js +210 -0
  491. package/dist/esm/utils/chart/labels.d.ts +6 -0
  492. package/dist/esm/utils/chart/labels.js +44 -0
  493. package/dist/esm/utils/chart/legend.d.ts +8 -0
  494. package/dist/esm/utils/chart/legend.js +23 -0
  495. package/dist/esm/utils/chart/math.d.ts +25 -0
  496. package/dist/esm/utils/chart/math.js +51 -0
  497. package/dist/esm/utils/chart/series/index.d.ts +1 -0
  498. package/dist/esm/utils/chart/series/index.js +1 -0
  499. package/dist/esm/utils/chart/series/waterfall.d.ts +4 -0
  500. package/dist/esm/utils/chart/series/waterfall.js +25 -0
  501. package/dist/esm/utils/chart/symbol.d.ts +3 -0
  502. package/dist/esm/utils/chart/symbol.js +36 -0
  503. package/dist/esm/utils/chart/text.d.ts +29 -0
  504. package/dist/esm/utils/chart/text.js +139 -0
  505. package/dist/esm/utils/chart/time.d.ts +3 -0
  506. package/dist/esm/utils/chart/time.js +34 -0
  507. package/dist/esm/utils/chart-ui/index.d.ts +4 -0
  508. package/dist/esm/utils/chart-ui/index.js +4 -0
  509. package/dist/esm/utils/chart-ui/pie-center-text.d.ts +7 -0
  510. package/dist/esm/utils/chart-ui/pie-center-text.js +23 -0
  511. package/dist/esm/utils/cn.d.ts +3 -0
  512. package/dist/esm/utils/cn.js +4 -0
  513. package/dist/esm/utils/d3-dispatcher.d.ts +1 -0
  514. package/dist/esm/utils/d3-dispatcher.js +4 -0
  515. package/dist/esm/utils/index.d.ts +5 -0
  516. package/dist/esm/utils/index.js +5 -0
  517. package/dist/esm/utils/misc.d.ts +2 -0
  518. package/dist/esm/utils/misc.js +8 -0
  519. package/dist/esm/validation/index.d.ts +2 -0
  520. package/dist/esm/validation/index.js +220 -0
  521. package/package.json +140 -0
@@ -0,0 +1,67 @@
1
+ import type { MeaningfulAny } from '../misc';
2
+ import type { AreaSeries, AreaSeriesData } from './area';
3
+ import type { BarXSeries, BarXSeriesData } from './bar-x';
4
+ import type { BarYSeries, BarYSeriesData } from './bar-y';
5
+ import type { LineSeries, LineSeriesData } from './line';
6
+ import type { PieSeries, PieSeriesData } from './pie';
7
+ import type { ScatterSeries, ScatterSeriesData } from './scatter';
8
+ import type { TreemapSeries, TreemapSeriesData } from './treemap';
9
+ import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
10
+ export type TooltipDataChunkBarX<T = MeaningfulAny> = {
11
+ data: BarXSeriesData<T>;
12
+ series: BarXSeries<T>;
13
+ };
14
+ export type TooltipDataChunkBarY<T = MeaningfulAny> = {
15
+ data: BarYSeriesData<T>;
16
+ series: BarYSeries<T>;
17
+ };
18
+ export type TooltipDataChunkPie<T = MeaningfulAny> = {
19
+ data: PieSeriesData<T>;
20
+ series: {
21
+ type: PieSeries['type'];
22
+ id: string;
23
+ name: string;
24
+ };
25
+ };
26
+ export type TooltipDataChunkScatter<T = MeaningfulAny> = {
27
+ data: ScatterSeriesData<T>;
28
+ series: {
29
+ type: ScatterSeries['type'];
30
+ id: string;
31
+ name: string;
32
+ };
33
+ };
34
+ export type TooltipDataChunkLine<T = MeaningfulAny> = {
35
+ data: LineSeriesData<T>;
36
+ series: {
37
+ type: LineSeries['type'];
38
+ id: string;
39
+ name: string;
40
+ };
41
+ };
42
+ export type TooltipDataChunkArea<T = MeaningfulAny> = {
43
+ data: AreaSeriesData<T>;
44
+ series: {
45
+ type: AreaSeries['type'];
46
+ id: string;
47
+ name: string;
48
+ };
49
+ };
50
+ export type TooltipDataChunkTreemap<T = MeaningfulAny> = {
51
+ data: TreemapSeriesData<T>;
52
+ series: TreemapSeries<T>;
53
+ };
54
+ export type TooltipDataChunkWaterfall<T = MeaningfulAny> = {
55
+ data: WaterfallSeriesData<T>;
56
+ series: WaterfallSeries<T>;
57
+ };
58
+ export type TooltipDataChunk<T = MeaningfulAny> = (TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T> | TooltipDataChunkTreemap<T> | TooltipDataChunkWaterfall<T>) & {
59
+ closest?: boolean;
60
+ };
61
+ export type ChartTooltip<T = MeaningfulAny> = {
62
+ enabled?: boolean;
63
+ /** Specifies the renderer for the tooltip. If returned null default tooltip renderer will be used. */
64
+ renderer?: (args: {
65
+ hovered: TooltipDataChunk<T>[];
66
+ }) => React.ReactElement | null;
67
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import type { LayoutAlgorithm, SeriesType } from '../../constants';
2
+ import type { MeaningfulAny } from '../misc';
3
+ import type { BaseSeries, BaseSeriesData } from './base';
4
+ import type { ChartLegend, RectLegendSymbolOptions } from './legend';
5
+ export type TreemapSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
6
+ /** The name of the node (used in legend, tooltip etc). */
7
+ name: string | string[];
8
+ /** The value of the node. All nodes should have this property except nodes that have children. */
9
+ value?: number;
10
+ /** An id for the node. Used to group children. */
11
+ id?: string;
12
+ /**
13
+ * Parent id. Used to build a tree structure. The value should be the id of the node which is the parent.
14
+ * If no nodes has a matching id, or this option is undefined, then the parent will be set to the root.
15
+ */
16
+ parentId?: string;
17
+ };
18
+ export type TreemapSeries<T = MeaningfulAny> = BaseSeries & {
19
+ type: typeof SeriesType.Treemap;
20
+ data: TreemapSeriesData<T>[];
21
+ /** The name of the series (used in legend, tooltip etc). */
22
+ name: string;
23
+ /** The main color of the series (hex, rgba). */
24
+ color?: string;
25
+ /** Individual series legend options. Has higher priority than legend options in widget data. */
26
+ legend?: ChartLegend & {
27
+ symbol?: RectLegendSymbolOptions;
28
+ };
29
+ /** Set options on specific levels. Takes precedence over series options, but not point options. */
30
+ levels?: {
31
+ /** Decides which level takes effect from the options set in the levels object. */
32
+ index: number;
33
+ /** Can set the padding between all points which lies on the same level. */
34
+ padding?: number;
35
+ /** Can set a color on all points which lies on the same level. */
36
+ color?: string;
37
+ }[];
38
+ layoutAlgorithm?: `${LayoutAlgorithm}`;
39
+ /**
40
+ * Options for the series data labels, appearing next to each data point.
41
+ * */
42
+ dataLabels?: BaseSeries['dataLabels'] & {
43
+ /** Horizontal alignment of the data label inside the tile. */
44
+ align?: 'left' | 'center' | 'right';
45
+ };
46
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { SeriesType } from '../../constants';
2
+ import type { MeaningfulAny } from '../misc';
3
+ import type { BaseSeries, BaseSeriesData } from './base';
4
+ import type { ChartLegend, RectLegendSymbolOptions } from './legend';
5
+ export type WaterfallSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
6
+ /**
7
+ * The `x` value. Depending on the context , it may represents:
8
+ * - numeric value (for `linear` x axis)
9
+ * - timestamp value (for `datetime` x axis)
10
+ * - x axis category value (for `category` x axis). If the type is a string, then it is a category value itself. If the type is a number, then it is the index of an element in the array of categories described in `xAxis.categories`
11
+ */
12
+ x?: string | number;
13
+ /**
14
+ * The `y` value. Depending on the context , it may represents:
15
+ * - numeric value (for `linear` y axis)
16
+ */
17
+ y?: number;
18
+ /** Data label value of the point. If not specified, the y value is used. */
19
+ label?: string | number;
20
+ /** Individual opacity for the point. */
21
+ opacity?: number;
22
+ /** When this property is true, the point display the total sum across the entire series. */
23
+ total?: boolean;
24
+ };
25
+ export type WaterfallSeries<T = MeaningfulAny> = BaseSeries & {
26
+ type: typeof SeriesType.Waterfall;
27
+ data: WaterfallSeriesData<T>[];
28
+ /** The name of the series (used in legend, tooltip etc). */
29
+ name: string;
30
+ /** The main color of the series (hex, rgba). */
31
+ color?: string;
32
+ /** The color used for positive values. If it is not specified, the general color of the series is used. */
33
+ positiveColor?: string;
34
+ /** The color used for negative values. If it is not specified, the general color of the series is used. */
35
+ negativeColor?: string;
36
+ /** Individual series legend options. Has higher priority than legend options in widget data. */
37
+ legend?: ChartLegend & {
38
+ symbol?: RectLegendSymbolOptions;
39
+ };
40
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { BaseTextStyle } from './chart/base';
2
+ export type LabelData = {
3
+ text: string;
4
+ x: number;
5
+ y: number;
6
+ style: BaseTextStyle;
7
+ size: {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ textAnchor: 'start' | 'end' | 'middle';
12
+ series: {
13
+ id: string;
14
+ };
15
+ active?: boolean;
16
+ };
17
+ export type HtmlItem = {
18
+ x: number;
19
+ y: number;
20
+ content: string;
21
+ };
22
+ export type ShapeDataWithHtmlItems = {
23
+ htmlElements: HtmlItem[];
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ export type FormatOptions = {
2
+ precision?: number | 'auto';
3
+ unitRate?: number;
4
+ showRankDelimiter?: boolean;
5
+ lang?: string;
6
+ labelMode?: string;
7
+ };
8
+ export type FormatNumberOptions = FormatOptions & {
9
+ format?: 'number' | 'percent';
10
+ multiplier?: number;
11
+ prefix?: string;
12
+ postfix?: string;
13
+ unit?: 'auto' | 'k' | 'm' | 'b' | 't' | null;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { ChartXAxis, ChartYAxis } from './chart/axis';
2
+ import type { ChartOptions } from './chart/chart';
3
+ import type { ChartLegend } from './chart/legend';
4
+ import type { ChartSeries, ChartSeriesOptions } from './chart/series';
5
+ import type { ChartSplit } from './chart/split';
6
+ import type { ChartTitle } from './chart/title';
7
+ import type { ChartTooltip } from './chart/tooltip';
8
+ import type { MeaningfulAny } from './misc';
9
+ export * from './chart-ui';
10
+ export * from './misc';
11
+ export * from './chart/axis';
12
+ export * from './chart/base';
13
+ export * from './chart/chart';
14
+ export * from './chart/legend';
15
+ export * from './chart/pie';
16
+ export * from './chart/scatter';
17
+ export * from './chart/bar-x';
18
+ export * from './chart/bar-y';
19
+ export * from './chart/area';
20
+ export * from './chart/line';
21
+ export * from './chart/series';
22
+ export * from './chart/split';
23
+ export * from './chart/title';
24
+ export * from './chart/tooltip';
25
+ export * from './chart/halo';
26
+ export * from './chart/treemap';
27
+ export * from './chart/waterfall';
28
+ export type ChartData<T = MeaningfulAny> = {
29
+ chart?: ChartOptions;
30
+ legend?: ChartLegend;
31
+ series: {
32
+ data: ChartSeries<T>[];
33
+ options?: ChartSeriesOptions;
34
+ };
35
+ title?: ChartTitle;
36
+ tooltip?: ChartTooltip<T>;
37
+ xAxis?: ChartXAxis;
38
+ yAxis?: ChartYAxis[];
39
+ /** Setting for displaying charts on different plots.
40
+ * It can be used to visualize related information on multiple charts. */
41
+ split?: ChartSplit;
42
+ };
@@ -0,0 +1,19 @@
1
+ export * from './chart-ui';
2
+ export * from './misc';
3
+ export * from './chart/axis';
4
+ export * from './chart/base';
5
+ export * from './chart/chart';
6
+ export * from './chart/legend';
7
+ export * from './chart/pie';
8
+ export * from './chart/scatter';
9
+ export * from './chart/bar-x';
10
+ export * from './chart/bar-y';
11
+ export * from './chart/area';
12
+ export * from './chart/line';
13
+ export * from './chart/series';
14
+ export * from './chart/split';
15
+ export * from './chart/title';
16
+ export * from './chart/tooltip';
17
+ export * from './chart/halo';
18
+ export * from './chart/treemap';
19
+ export * from './chart/waterfall';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * A utilitarian type to describe `any` when it does not contradict the typescript usage paradigm.
3
+ */
4
+ export type MeaningfulAny = any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { AxisDomain, AxisScale, Selection } from 'd3';
2
+ import type { BaseTextStyle } from '../../../types';
3
+ type AxisBottomArgs = {
4
+ scale: AxisScale<AxisDomain>;
5
+ ticks: {
6
+ count?: number;
7
+ maxTickCount?: number;
8
+ labelFormat?: (value: any) => string;
9
+ labelsPaddings?: number;
10
+ labelsMargin?: number;
11
+ labelsStyle?: BaseTextStyle;
12
+ labelsMaxWidth?: number;
13
+ labelsLineHeight: number;
14
+ items?: [number, number][];
15
+ rotation?: number;
16
+ tickColor?: string;
17
+ };
18
+ domain: {
19
+ size: number;
20
+ color?: string;
21
+ };
22
+ };
23
+ export declare function axisBottom(args: AxisBottomArgs): (selection: Selection<SVGGElement, unknown, null, undefined>) => void;
24
+ export {};
@@ -0,0 +1,126 @@
1
+ import { path, select } from 'd3';
2
+ import { getXAxisItems, getXAxisOffset, getXTickPosition } from '../axis';
3
+ import { calculateCos, calculateSin } from '../math';
4
+ import { getLabelsSize, setEllipsisForOverflowText } from '../text';
5
+ function addDomain(selection, options) {
6
+ const { size, color } = options;
7
+ const domainPath = selection
8
+ .selectAll('.domain')
9
+ .data([null])
10
+ .enter()
11
+ .insert('path', '.tick')
12
+ .attr('class', 'domain')
13
+ .attr('d', `M0,0V0H${size}`);
14
+ if (color) {
15
+ domainPath.style('stroke', color);
16
+ }
17
+ }
18
+ export function axisBottom(args) {
19
+ const { scale, ticks: { labelFormat = (value) => String(value), labelsPaddings = 0, labelsMargin = 0, labelsMaxWidth = Infinity, labelsStyle, labelsLineHeight, items: tickItems, count: ticksCount, maxTickCount, rotation = 0, tickColor, }, domain, } = args;
20
+ const offset = getXAxisOffset();
21
+ const position = getXTickPosition({ scale, offset });
22
+ const values = getXAxisItems({ scale, count: ticksCount, maxCount: maxTickCount });
23
+ const labelHeight = getLabelsSize({
24
+ labels: values,
25
+ style: labelsStyle,
26
+ }).maxHeight;
27
+ return function (selection) {
28
+ var _a, _b, _c;
29
+ const rect = (_a = selection.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
30
+ const x = (rect === null || rect === void 0 ? void 0 : rect.x) || 0;
31
+ const right = x + domain.size;
32
+ const top = -((_c = (_b = tickItems === null || tickItems === void 0 ? void 0 : tickItems[0]) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : 0);
33
+ let transform = `translate(0, ${labelHeight + labelsMargin - top}px)`;
34
+ if (rotation) {
35
+ const labelsOffsetTop = labelHeight * calculateCos(rotation) + labelsMargin - top;
36
+ let labelsOffsetLeft = calculateSin(rotation) * labelHeight;
37
+ if (Math.abs(rotation) % 360 === 90) {
38
+ labelsOffsetLeft += ((rotation > 0 ? -1 : 1) * labelHeight) / 2;
39
+ }
40
+ transform = `translate(${-labelsOffsetLeft}px, ${labelsOffsetTop}px) rotate(${rotation}deg)`;
41
+ }
42
+ const tickPath = path();
43
+ tickItems === null || tickItems === void 0 ? void 0 : tickItems.forEach(([start, end]) => {
44
+ tickPath.moveTo(0, start);
45
+ tickPath.lineTo(0, end);
46
+ });
47
+ selection
48
+ .selectAll('.tick')
49
+ .data(values)
50
+ .order()
51
+ .join((el) => {
52
+ const tick = el.append('g').attr('class', 'tick');
53
+ tick.append('path')
54
+ .attr('d', tickPath.toString())
55
+ .attr('stroke', tickColor !== null && tickColor !== void 0 ? tickColor : 'currentColor');
56
+ tick.append('text')
57
+ .text(labelFormat)
58
+ .attr('fill', 'currentColor')
59
+ .attr('text-anchor', () => {
60
+ if (rotation) {
61
+ return rotation > 0 ? 'start' : 'end';
62
+ }
63
+ return 'middle';
64
+ })
65
+ .style('transform', transform)
66
+ .style('alignment-baseline', 'after-edge');
67
+ return tick;
68
+ })
69
+ .attr('transform', function (d) {
70
+ return `translate(${position(d) + offset}, ${top})`;
71
+ });
72
+ // Remove tick that has the same x coordinate like domain
73
+ selection
74
+ .select('.tick')
75
+ .filter((d) => {
76
+ return position(d) === 0;
77
+ })
78
+ .select('line')
79
+ .remove();
80
+ const labels = selection.selectAll('.tick text');
81
+ // FIXME: handle rotated overlapping labels (with a smarter approach)
82
+ if (rotation) {
83
+ const maxWidth = labelsMaxWidth * calculateCos(rotation) + labelsLineHeight * calculateSin(rotation);
84
+ labels.each(function () {
85
+ setEllipsisForOverflowText(select(this), maxWidth);
86
+ });
87
+ }
88
+ else {
89
+ // remove overlapping labels
90
+ let elementX = 0;
91
+ selection
92
+ .selectAll('.tick')
93
+ .filter(function () {
94
+ const node = this;
95
+ const r = node.getBoundingClientRect();
96
+ if (r.left < elementX) {
97
+ return true;
98
+ }
99
+ elementX = r.right + labelsPaddings;
100
+ return false;
101
+ })
102
+ .remove();
103
+ // add an ellipsis to the labels that go beyond the boundaries of the chart
104
+ labels.each(function (_d, i, nodes) {
105
+ if (i === nodes.length - 1) {
106
+ const currentElement = this;
107
+ const prevElement = nodes[i - 1];
108
+ const text = select(currentElement);
109
+ const currentElementPosition = currentElement.getBoundingClientRect();
110
+ const prevElementPosition = prevElement === null || prevElement === void 0 ? void 0 : prevElement.getBoundingClientRect();
111
+ const lackingSpace = Math.max(0, currentElementPosition.right - right);
112
+ if (lackingSpace) {
113
+ const remainSpace = right - ((prevElementPosition === null || prevElementPosition === void 0 ? void 0 : prevElementPosition.right) || 0) - labelsPaddings;
114
+ const translateX = currentElementPosition.width / 2 - lackingSpace;
115
+ text.attr('text-anchor', 'end').attr('transform', `translate(${translateX},0)`);
116
+ setEllipsisForOverflowText(text, remainSpace);
117
+ }
118
+ }
119
+ });
120
+ }
121
+ const { size: domainSize, color: domainColor } = domain;
122
+ selection
123
+ .call(addDomain, { size: domainSize, color: domainColor })
124
+ .style('font-size', (labelsStyle === null || labelsStyle === void 0 ? void 0 : labelsStyle.fontSize) || '');
125
+ };
126
+ }
@@ -0,0 +1 @@
1
+ export * from './bottom';
@@ -0,0 +1 @@
1
+ export * from './bottom';
@@ -0,0 +1,31 @@
1
+ import type { AxisDomain, AxisScale, ScaleBand } from 'd3';
2
+ import type { PreparedAxis, PreparedSplit } from '../../hooks';
3
+ import type { TextRow } from './text';
4
+ export declare function getTicksCount({ axis, range }: {
5
+ axis: PreparedAxis;
6
+ range: number;
7
+ }): number | undefined;
8
+ export declare function isBandScale(scale: AxisScale<AxisDomain>): scale is ScaleBand<AxisDomain>;
9
+ export declare function getScaleTicks(scale: AxisScale<AxisDomain>, ticksCount?: number): any;
10
+ export declare function getXAxisOffset(): 0 | 0.5;
11
+ export declare function getXTickPosition({ scale, offset }: {
12
+ scale: AxisScale<AxisDomain>;
13
+ offset: number;
14
+ }): (d: AxisDomain) => number;
15
+ export declare function getXAxisItems({ scale, count, maxCount, }: {
16
+ scale: AxisScale<AxisDomain>;
17
+ count?: number;
18
+ maxCount?: number;
19
+ }): any;
20
+ export declare function getMaxTickCount({ axis, width }: {
21
+ axis: PreparedAxis;
22
+ width: number;
23
+ }): number;
24
+ export declare function getAxisHeight(args: {
25
+ split: PreparedSplit;
26
+ boundsHeight: number;
27
+ }): number;
28
+ export declare function getAxisTitleRows(args: {
29
+ axis: PreparedAxis;
30
+ textMaxWidth: number;
31
+ }): TextRow[];
@@ -0,0 +1,71 @@
1
+ import { wrapText } from './text';
2
+ export function getTicksCount({ axis, range }) {
3
+ let ticksCount;
4
+ if (axis.ticks.pixelInterval) {
5
+ ticksCount = Math.ceil(range / axis.ticks.pixelInterval);
6
+ }
7
+ return ticksCount;
8
+ }
9
+ export function isBandScale(scale) {
10
+ return 'bandwidth' in scale && typeof scale.bandwidth === 'function';
11
+ }
12
+ export function getScaleTicks(scale, ticksCount) {
13
+ return 'ticks' in scale && typeof scale.ticks === 'function'
14
+ ? scale.ticks(ticksCount)
15
+ : scale.domain();
16
+ }
17
+ export function getXAxisOffset() {
18
+ return typeof window !== 'undefined' && window.devicePixelRatio > 1 ? 0 : 0.5;
19
+ }
20
+ function number(scale) {
21
+ return (d) => Number(scale(d));
22
+ }
23
+ function center(scale, offset) {
24
+ offset = Math.max(0, scale.bandwidth() - offset * 2) / 2;
25
+ if (scale.round()) {
26
+ offset = Math.round(offset);
27
+ }
28
+ return (d) => Number(scale(d)) + offset;
29
+ }
30
+ export function getXTickPosition({ scale, offset }) {
31
+ return isBandScale(scale) ? center(scale.copy(), offset) : number(scale.copy());
32
+ }
33
+ export function getXAxisItems({ scale, count, maxCount, }) {
34
+ let values = getScaleTicks(scale, count);
35
+ if (maxCount && values.length > maxCount) {
36
+ const step = Math.ceil(values.length / maxCount);
37
+ values = values.filter((_, i) => i % step === 0);
38
+ }
39
+ return values;
40
+ }
41
+ export function getMaxTickCount({ axis, width }) {
42
+ const minTickWidth = parseInt(axis.labels.style.fontSize) + axis.labels.padding;
43
+ return Math.floor(width / minTickWidth);
44
+ }
45
+ export function getAxisHeight(args) {
46
+ const { split, boundsHeight } = args;
47
+ if (split.plots.length > 1) {
48
+ return split.plots[0].height;
49
+ }
50
+ return boundsHeight;
51
+ }
52
+ export function getAxisTitleRows(args) {
53
+ const { axis, textMaxWidth } = args;
54
+ if (axis.title.maxRowCount < 1) {
55
+ return [];
56
+ }
57
+ const textRows = wrapText({
58
+ text: axis.title.text,
59
+ style: axis.title.style,
60
+ width: textMaxWidth,
61
+ });
62
+ return textRows.reduce((acc, row, index) => {
63
+ if (index < axis.title.maxRowCount) {
64
+ acc.push(row);
65
+ }
66
+ else {
67
+ acc[axis.title.maxRowCount - 1].text += row.text;
68
+ }
69
+ return acc;
70
+ }, []);
71
+ }
@@ -0,0 +1,10 @@
1
+ import type { ChartData } from '../../types';
2
+ export declare function getDomainForContinuousColorScale(args: {
3
+ series: ChartData['series']['data'];
4
+ }): number[];
5
+ export declare function getDefaultColorStops(size: number): number[];
6
+ export declare function getContinuesColorFn(args: {
7
+ values: number[];
8
+ colors: string[];
9
+ stops?: number[];
10
+ }): (value: number) => string;
@@ -0,0 +1,43 @@
1
+ import { range, scaleLinear } from 'd3';
2
+ export function getDomainForContinuousColorScale(args) {
3
+ const { series } = args;
4
+ const values = series.reduce((acc, s) => {
5
+ switch (s.type) {
6
+ case 'pie': {
7
+ acc.push(...s.data.map((d) => d.value));
8
+ break;
9
+ }
10
+ case 'bar-y': {
11
+ acc.push(...s.data.map((d) => Number(d.x)));
12
+ break;
13
+ }
14
+ case 'scatter':
15
+ case 'bar-x':
16
+ case 'waterfall':
17
+ case 'line':
18
+ case 'area': {
19
+ acc.push(...s.data.map((d) => Number(d.y)));
20
+ break;
21
+ }
22
+ default: {
23
+ throw Error(`The method for calculation a domain for a continuous color scale for the "${s.type}" series is not defined`);
24
+ }
25
+ }
26
+ return acc;
27
+ }, []);
28
+ return [Math.min(...values), Math.max(...values)];
29
+ }
30
+ export function getDefaultColorStops(size) {
31
+ return range(size).map((d) => d / size);
32
+ }
33
+ export function getContinuesColorFn(args) {
34
+ const { values, colors, stops: customStops } = args;
35
+ const min = Math.min(...values);
36
+ const max = Math.max(...values);
37
+ const stops = customStops !== null && customStops !== void 0 ? customStops : getDefaultColorStops(colors.length);
38
+ const color = scaleLinear(stops, colors);
39
+ return (value) => {
40
+ const colorValue = (value - min) / (max - min);
41
+ return color(colorValue);
42
+ };
43
+ }
@@ -0,0 +1,15 @@
1
+ import type { ShapeData } from '../../hooks';
2
+ import type { ChartSeries, ChartSeriesData, TooltipDataChunk } from '../../types';
3
+ type GetClosestPointsArgs = {
4
+ position: [number, number];
5
+ shapesData: ShapeData[];
6
+ };
7
+ export type ShapePoint = {
8
+ x: number;
9
+ y0: number;
10
+ y1: number;
11
+ data: ChartSeriesData;
12
+ series: ChartSeries;
13
+ };
14
+ export declare function getClosestPoints(args: GetClosestPointsArgs): TooltipDataChunk[];
15
+ export {};