@mui/x-charts 6.0.0-alpha.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 (423) hide show
  1. package/BarChart/BarChart.d.ts +19 -0
  2. package/BarChart/BarChart.js +262 -0
  3. package/BarChart/BarElement.d.ts +21 -0
  4. package/BarChart/BarElement.js +92 -0
  5. package/BarChart/BarPlot.d.ts +2 -0
  6. package/BarChart/BarPlot.js +76 -0
  7. package/BarChart/extremums.d.ts +3 -0
  8. package/BarChart/extremums.js +27 -0
  9. package/BarChart/formatter.d.ts +3 -0
  10. package/BarChart/formatter.js +54 -0
  11. package/BarChart/index.d.ts +2 -0
  12. package/BarChart/index.js +19 -0
  13. package/BarChart/package.json +6 -0
  14. package/CHANGELOG.md +3211 -0
  15. package/ChartContainer/index.d.ts +9 -0
  16. package/ChartContainer/index.js +61 -0
  17. package/ChartContainer/package.json +6 -0
  18. package/ChartsAxis/ChartsAxis.d.ts +33 -0
  19. package/ChartsAxis/ChartsAxis.js +152 -0
  20. package/ChartsAxis/axisClasses.d.ts +29 -0
  21. package/ChartsAxis/axisClasses.js +13 -0
  22. package/ChartsAxis/index.d.ts +2 -0
  23. package/ChartsAxis/index.js +27 -0
  24. package/ChartsAxis/package.json +6 -0
  25. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +10 -0
  26. package/ChartsAxisHighlight/ChartsAxisHighlight.js +67 -0
  27. package/ChartsAxisHighlight/index.d.ts +1 -0
  28. package/ChartsAxisHighlight/index.js +16 -0
  29. package/ChartsAxisHighlight/package.json +6 -0
  30. package/ChartsClipPath/ChartsClipPath.d.ts +15 -0
  31. package/ChartsClipPath/ChartsClipPath.js +54 -0
  32. package/ChartsClipPath/index.d.ts +1 -0
  33. package/ChartsClipPath/index.js +16 -0
  34. package/ChartsClipPath/package.json +6 -0
  35. package/ChartsLegend/ChartsLegend.d.ts +44 -0
  36. package/ChartsLegend/ChartsLegend.js +202 -0
  37. package/ChartsLegend/chartsLegendClasses.d.ts +17 -0
  38. package/ChartsLegend/chartsLegendClasses.js +13 -0
  39. package/ChartsLegend/index.d.ts +2 -0
  40. package/ChartsLegend/index.js +27 -0
  41. package/ChartsLegend/package.json +6 -0
  42. package/ChartsLegend/utils.d.ts +14 -0
  43. package/ChartsLegend/utils.js +9 -0
  44. package/ChartsSurface.d.ts +21 -0
  45. package/ChartsSurface.js +58 -0
  46. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +40 -0
  47. package/ChartsTooltip/ChartsAxisTooltipContent.js +116 -0
  48. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +27 -0
  49. package/ChartsTooltip/ChartsItemTooltipContent.js +70 -0
  50. package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
  51. package/ChartsTooltip/ChartsTooltip.js +104 -0
  52. package/ChartsTooltip/ChartsTooltipTable.d.ts +26 -0
  53. package/ChartsTooltip/ChartsTooltipTable.js +81 -0
  54. package/ChartsTooltip/index.d.ts +1 -0
  55. package/ChartsTooltip/index.js +16 -0
  56. package/ChartsTooltip/package.json +6 -0
  57. package/ChartsTooltip/tooltipClasses.d.ts +13 -0
  58. package/ChartsTooltip/tooltipClasses.js +13 -0
  59. package/ChartsTooltip/utils.d.ts +24 -0
  60. package/ChartsTooltip/utils.js +91 -0
  61. package/ChartsXAxis/ChartsXAxis.d.ts +7 -0
  62. package/ChartsXAxis/ChartsXAxis.js +191 -0
  63. package/ChartsXAxis/index.d.ts +1 -0
  64. package/ChartsXAxis/index.js +16 -0
  65. package/ChartsXAxis/package.json +6 -0
  66. package/ChartsYAxis/ChartsYAxis.d.ts +7 -0
  67. package/ChartsYAxis/ChartsYAxis.js +192 -0
  68. package/ChartsYAxis/index.d.ts +1 -0
  69. package/ChartsYAxis/index.js +16 -0
  70. package/ChartsYAxis/package.json +6 -0
  71. package/LICENSE +21 -0
  72. package/LineChart/AreaElement.d.ts +28 -0
  73. package/LineChart/AreaElement.js +115 -0
  74. package/LineChart/AreaPlot.d.ts +2 -0
  75. package/LineChart/AreaPlot.js +67 -0
  76. package/LineChart/LineChart.d.ts +19 -0
  77. package/LineChart/LineChart.js +266 -0
  78. package/LineChart/LineElement.d.ts +28 -0
  79. package/LineChart/LineElement.js +117 -0
  80. package/LineChart/LinePlot.d.ts +2 -0
  81. package/LineChart/LinePlot.js +67 -0
  82. package/LineChart/MarkElement.d.ts +38 -0
  83. package/LineChart/MarkElement.js +140 -0
  84. package/LineChart/MarkPlot.d.ts +2 -0
  85. package/LineChart/MarkPlot.js +86 -0
  86. package/LineChart/extremums.d.ts +3 -0
  87. package/LineChart/extremums.js +36 -0
  88. package/LineChart/formatter.d.ts +3 -0
  89. package/LineChart/formatter.js +55 -0
  90. package/LineChart/index.d.ts +7 -0
  91. package/LineChart/index.js +75 -0
  92. package/LineChart/package.json +6 -0
  93. package/README.md +5 -0
  94. package/ResponsiveChartContainer/index.d.ts +5 -0
  95. package/ResponsiveChartContainer/index.js +54 -0
  96. package/ResponsiveChartContainer/package.json +6 -0
  97. package/ScatterChart/Scatter.d.ts +15 -0
  98. package/ScatterChart/Scatter.js +114 -0
  99. package/ScatterChart/ScatterChart.d.ts +19 -0
  100. package/ScatterChart/ScatterChart.js +252 -0
  101. package/ScatterChart/ScatterPlot.d.ts +2 -0
  102. package/ScatterChart/ScatterPlot.js +52 -0
  103. package/ScatterChart/extremums.d.ts +3 -0
  104. package/ScatterChart/extremums.js +49 -0
  105. package/ScatterChart/formatter.d.ts +3 -0
  106. package/ScatterChart/formatter.js +19 -0
  107. package/ScatterChart/index.d.ts +3 -0
  108. package/ScatterChart/index.js +26 -0
  109. package/ScatterChart/package.json +6 -0
  110. package/colorPalettes/colorPalettes.d.ts +11 -0
  111. package/colorPalettes/colorPalettes.js +24 -0
  112. package/colorPalettes/index.d.ts +1 -0
  113. package/colorPalettes/index.js +16 -0
  114. package/colorPalettes/package.json +6 -0
  115. package/constants.d.ts +8 -0
  116. package/constants.js +17 -0
  117. package/context/CartesianContextProvider.d.ts +30 -0
  118. package/context/CartesianContextProvider.js +227 -0
  119. package/context/DrawingProvider.d.ts +22 -0
  120. package/context/DrawingProvider.js +64 -0
  121. package/context/HighlightProvider.d.ts +28 -0
  122. package/context/HighlightProvider.js +57 -0
  123. package/context/InteractionProvider.d.ts +34 -0
  124. package/context/InteractionProvider.js +62 -0
  125. package/context/SeriesContextProvider.d.ts +17 -0
  126. package/context/SeriesContextProvider.js +69 -0
  127. package/context/index.d.ts +3 -0
  128. package/context/index.js +19 -0
  129. package/context/package.json +6 -0
  130. package/esm/BarChart/BarChart.js +255 -0
  131. package/esm/BarChart/BarElement.js +80 -0
  132. package/esm/BarChart/BarPlot.js +70 -0
  133. package/esm/BarChart/extremums.js +20 -0
  134. package/esm/BarChart/formatter.js +46 -0
  135. package/esm/BarChart/index.js +2 -0
  136. package/esm/ChartContainer/index.js +53 -0
  137. package/esm/ChartsAxis/ChartsAxis.js +145 -0
  138. package/esm/ChartsAxis/axisClasses.js +5 -0
  139. package/esm/ChartsAxis/index.js +2 -0
  140. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -0
  141. package/esm/ChartsAxisHighlight/index.js +1 -0
  142. package/esm/ChartsClipPath/ChartsClipPath.js +46 -0
  143. package/esm/ChartsClipPath/index.js +1 -0
  144. package/esm/ChartsLegend/ChartsLegend.js +189 -0
  145. package/esm/ChartsLegend/chartsLegendClasses.js +5 -0
  146. package/esm/ChartsLegend/index.js +2 -0
  147. package/esm/ChartsLegend/utils.js +3 -0
  148. package/esm/ChartsSurface.js +49 -0
  149. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +108 -0
  150. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +63 -0
  151. package/esm/ChartsTooltip/ChartsTooltip.js +96 -0
  152. package/esm/ChartsTooltip/ChartsTooltipTable.js +69 -0
  153. package/esm/ChartsTooltip/index.js +1 -0
  154. package/esm/ChartsTooltip/tooltipClasses.js +5 -0
  155. package/esm/ChartsTooltip/utils.js +81 -0
  156. package/esm/ChartsXAxis/ChartsXAxis.js +184 -0
  157. package/esm/ChartsXAxis/index.js +1 -0
  158. package/esm/ChartsYAxis/ChartsYAxis.js +185 -0
  159. package/esm/ChartsYAxis/index.js +1 -0
  160. package/esm/LineChart/AreaElement.js +104 -0
  161. package/esm/LineChart/AreaPlot.js +58 -0
  162. package/esm/LineChart/LineChart.js +259 -0
  163. package/esm/LineChart/LineElement.js +106 -0
  164. package/esm/LineChart/LinePlot.js +58 -0
  165. package/esm/LineChart/MarkElement.js +130 -0
  166. package/esm/LineChart/MarkPlot.js +78 -0
  167. package/esm/LineChart/extremums.js +29 -0
  168. package/esm/LineChart/formatter.js +48 -0
  169. package/esm/LineChart/index.js +7 -0
  170. package/esm/ResponsiveChartContainer/index.js +46 -0
  171. package/esm/ScatterChart/Scatter.js +106 -0
  172. package/esm/ScatterChart/ScatterChart.js +245 -0
  173. package/esm/ScatterChart/ScatterPlot.js +44 -0
  174. package/esm/ScatterChart/extremums.js +41 -0
  175. package/esm/ScatterChart/formatter.js +11 -0
  176. package/esm/ScatterChart/index.js +3 -0
  177. package/esm/colorPalettes/colorPalettes.js +9 -0
  178. package/esm/colorPalettes/index.js +1 -0
  179. package/esm/constants.js +8 -0
  180. package/esm/context/CartesianContextProvider.js +221 -0
  181. package/esm/context/DrawingProvider.js +52 -0
  182. package/esm/context/HighlightProvider.js +46 -0
  183. package/esm/context/InteractionProvider.js +51 -0
  184. package/esm/context/SeriesContextProvider.js +60 -0
  185. package/esm/context/index.js +2 -0
  186. package/esm/hooks/useAxisEvents.js +145 -0
  187. package/esm/hooks/useChartDimensions.js +14 -0
  188. package/esm/hooks/useInteractionItemProps.js +68 -0
  189. package/esm/hooks/useScale.js +33 -0
  190. package/esm/hooks/useTicks.js +46 -0
  191. package/esm/index.js +15 -0
  192. package/esm/internals/components/AxisSharedComponents.js +81 -0
  193. package/esm/internals/defaultizeColor.js +7 -0
  194. package/esm/internals/defaultizeValueFormatter.js +11 -0
  195. package/esm/internals/getCurve.js +39 -0
  196. package/esm/internals/stackSeries.js +93 -0
  197. package/esm/internals/utils.js +5 -0
  198. package/esm/models/axis.js +1 -0
  199. package/esm/models/helpers.js +1 -0
  200. package/esm/models/index.js +1 -0
  201. package/esm/models/layout.js +1 -0
  202. package/esm/models/seriesType/bar.js +1 -0
  203. package/esm/models/seriesType/common.js +1 -0
  204. package/esm/models/seriesType/config.js +1 -0
  205. package/esm/models/seriesType/index.js +12 -0
  206. package/esm/models/seriesType/line.js +1 -0
  207. package/esm/models/seriesType/pie.js +1 -0
  208. package/esm/models/seriesType/scatter.js +1 -0
  209. package/esm/themeAugmentation/index.js +3 -0
  210. package/hooks/useAxisEvents.d.ts +1 -0
  211. package/hooks/useAxisEvents.js +154 -0
  212. package/hooks/useChartDimensions.d.ts +8 -0
  213. package/hooks/useChartDimensions.js +24 -0
  214. package/hooks/useInteractionItemProps.d.ts +8 -0
  215. package/hooks/useInteractionItemProps.js +79 -0
  216. package/hooks/useScale.d.ts +13 -0
  217. package/hooks/useScale.js +41 -0
  218. package/hooks/useTicks.d.ts +23 -0
  219. package/hooks/useTicks.js +50 -0
  220. package/index.d.ts +15 -0
  221. package/index.js +177 -0
  222. package/internals/components/AxisSharedComponents.d.ts +6 -0
  223. package/internals/components/AxisSharedComponents.js +93 -0
  224. package/internals/defaultizeColor.d.ts +41 -0
  225. package/internals/defaultizeColor.js +14 -0
  226. package/internals/defaultizeValueFormatter.d.ts +8 -0
  227. package/internals/defaultizeValueFormatter.js +19 -0
  228. package/internals/getCurve.d.ts +2 -0
  229. package/internals/getCurve.js +45 -0
  230. package/internals/stackSeries.d.ts +29 -0
  231. package/internals/stackSeries.js +102 -0
  232. package/internals/utils.d.ts +2 -0
  233. package/internals/utils.js +11 -0
  234. package/legacy/BarChart/BarChart.js +260 -0
  235. package/legacy/BarChart/BarElement.js +78 -0
  236. package/legacy/BarChart/BarPlot.js +65 -0
  237. package/legacy/BarChart/extremums.js +25 -0
  238. package/legacy/BarChart/formatter.js +49 -0
  239. package/legacy/BarChart/index.js +2 -0
  240. package/legacy/ChartContainer/index.js +51 -0
  241. package/legacy/ChartsAxis/ChartsAxis.js +143 -0
  242. package/legacy/ChartsAxis/axisClasses.js +5 -0
  243. package/legacy/ChartsAxis/index.js +2 -0
  244. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +56 -0
  245. package/legacy/ChartsAxisHighlight/index.js +1 -0
  246. package/legacy/ChartsClipPath/ChartsClipPath.js +43 -0
  247. package/legacy/ChartsClipPath/index.js +1 -0
  248. package/legacy/ChartsLegend/ChartsLegend.js +186 -0
  249. package/legacy/ChartsLegend/chartsLegendClasses.js +5 -0
  250. package/legacy/ChartsLegend/index.js +2 -0
  251. package/legacy/ChartsLegend/utils.js +9 -0
  252. package/legacy/ChartsSurface.js +52 -0
  253. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +106 -0
  254. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +59 -0
  255. package/legacy/ChartsTooltip/ChartsTooltip.js +92 -0
  256. package/legacy/ChartsTooltip/ChartsTooltipTable.js +73 -0
  257. package/legacy/ChartsTooltip/index.js +1 -0
  258. package/legacy/ChartsTooltip/tooltipClasses.js +5 -0
  259. package/legacy/ChartsTooltip/utils.js +91 -0
  260. package/legacy/ChartsXAxis/ChartsXAxis.js +172 -0
  261. package/legacy/ChartsXAxis/index.js +1 -0
  262. package/legacy/ChartsYAxis/ChartsYAxis.js +173 -0
  263. package/legacy/ChartsYAxis/index.js +1 -0
  264. package/legacy/LineChart/AreaElement.js +102 -0
  265. package/legacy/LineChart/AreaPlot.js +62 -0
  266. package/legacy/LineChart/LineChart.js +265 -0
  267. package/legacy/LineChart/LineElement.js +104 -0
  268. package/legacy/LineChart/LinePlot.js +60 -0
  269. package/legacy/LineChart/MarkElement.js +128 -0
  270. package/legacy/LineChart/MarkPlot.js +75 -0
  271. package/legacy/LineChart/extremums.js +39 -0
  272. package/legacy/LineChart/formatter.js +51 -0
  273. package/legacy/LineChart/index.js +7 -0
  274. package/legacy/ResponsiveChartContainer/index.js +59 -0
  275. package/legacy/ScatterChart/Scatter.js +103 -0
  276. package/legacy/ScatterChart/ScatterChart.js +245 -0
  277. package/legacy/ScatterChart/ScatterPlot.js +39 -0
  278. package/legacy/ScatterChart/extremums.js +39 -0
  279. package/legacy/ScatterChart/formatter.js +12 -0
  280. package/legacy/ScatterChart/index.js +3 -0
  281. package/legacy/colorPalettes/colorPalettes.js +15 -0
  282. package/legacy/colorPalettes/index.js +1 -0
  283. package/legacy/constants.js +8 -0
  284. package/legacy/context/CartesianContextProvider.js +241 -0
  285. package/legacy/context/DrawingProvider.js +51 -0
  286. package/legacy/context/HighlightProvider.js +55 -0
  287. package/legacy/context/InteractionProvider.js +60 -0
  288. package/legacy/context/SeriesContextProvider.js +61 -0
  289. package/legacy/context/index.js +2 -0
  290. package/legacy/hooks/useAxisEvents.js +140 -0
  291. package/legacy/hooks/useChartDimensions.js +16 -0
  292. package/legacy/hooks/useInteractionItemProps.js +66 -0
  293. package/legacy/hooks/useScale.js +37 -0
  294. package/legacy/hooks/useTicks.js +46 -0
  295. package/legacy/index.js +22 -0
  296. package/legacy/internals/components/AxisSharedComponents.js +80 -0
  297. package/legacy/internals/defaultizeColor.js +8 -0
  298. package/legacy/internals/defaultizeValueFormatter.js +11 -0
  299. package/legacy/internals/getCurve.js +39 -0
  300. package/legacy/internals/stackSeries.js +90 -0
  301. package/legacy/internals/utils.js +5 -0
  302. package/legacy/models/axis.js +1 -0
  303. package/legacy/models/helpers.js +1 -0
  304. package/legacy/models/index.js +1 -0
  305. package/legacy/models/layout.js +1 -0
  306. package/legacy/models/seriesType/bar.js +1 -0
  307. package/legacy/models/seriesType/common.js +1 -0
  308. package/legacy/models/seriesType/config.js +1 -0
  309. package/legacy/models/seriesType/index.js +12 -0
  310. package/legacy/models/seriesType/line.js +1 -0
  311. package/legacy/models/seriesType/pie.js +1 -0
  312. package/legacy/models/seriesType/scatter.js +1 -0
  313. package/legacy/themeAugmentation/index.js +3 -0
  314. package/models/axis.d.ts +118 -0
  315. package/models/axis.js +5 -0
  316. package/models/helpers.d.ts +2 -0
  317. package/models/helpers.js +5 -0
  318. package/models/index.d.ts +1 -0
  319. package/models/index.js +16 -0
  320. package/models/layout.d.ts +10 -0
  321. package/models/layout.js +5 -0
  322. package/models/package.json +6 -0
  323. package/models/seriesType/bar.d.ts +18 -0
  324. package/models/seriesType/bar.js +5 -0
  325. package/models/seriesType/common.d.ts +26 -0
  326. package/models/seriesType/common.js +5 -0
  327. package/models/seriesType/config.d.ts +66 -0
  328. package/models/seriesType/config.js +5 -0
  329. package/models/seriesType/index.d.ts +13 -0
  330. package/models/seriesType/index.js +38 -0
  331. package/models/seriesType/line.d.ts +25 -0
  332. package/models/seriesType/line.js +5 -0
  333. package/models/seriesType/pie.d.ts +5 -0
  334. package/models/seriesType/pie.js +5 -0
  335. package/models/seriesType/scatter.d.ts +24 -0
  336. package/models/seriesType/scatter.js +5 -0
  337. package/modern/BarChart/BarChart.js +255 -0
  338. package/modern/BarChart/BarElement.js +80 -0
  339. package/modern/BarChart/BarPlot.js +68 -0
  340. package/modern/BarChart/extremums.js +19 -0
  341. package/modern/BarChart/formatter.js +46 -0
  342. package/modern/BarChart/index.js +2 -0
  343. package/modern/ChartContainer/index.js +53 -0
  344. package/modern/ChartsAxis/ChartsAxis.js +145 -0
  345. package/modern/ChartsAxis/axisClasses.js +5 -0
  346. package/modern/ChartsAxis/index.js +2 -0
  347. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -0
  348. package/modern/ChartsAxisHighlight/index.js +1 -0
  349. package/modern/ChartsClipPath/ChartsClipPath.js +46 -0
  350. package/modern/ChartsClipPath/index.js +1 -0
  351. package/modern/ChartsLegend/ChartsLegend.js +189 -0
  352. package/modern/ChartsLegend/chartsLegendClasses.js +5 -0
  353. package/modern/ChartsLegend/index.js +2 -0
  354. package/modern/ChartsLegend/utils.js +3 -0
  355. package/modern/ChartsSurface.js +49 -0
  356. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +107 -0
  357. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +62 -0
  358. package/modern/ChartsTooltip/ChartsTooltip.js +96 -0
  359. package/modern/ChartsTooltip/ChartsTooltipTable.js +69 -0
  360. package/modern/ChartsTooltip/index.js +1 -0
  361. package/modern/ChartsTooltip/tooltipClasses.js +5 -0
  362. package/modern/ChartsTooltip/utils.js +81 -0
  363. package/modern/ChartsXAxis/ChartsXAxis.js +184 -0
  364. package/modern/ChartsXAxis/index.js +1 -0
  365. package/modern/ChartsYAxis/ChartsYAxis.js +185 -0
  366. package/modern/ChartsYAxis/index.js +1 -0
  367. package/modern/LineChart/AreaElement.js +104 -0
  368. package/modern/LineChart/AreaPlot.js +58 -0
  369. package/modern/LineChart/LineChart.js +259 -0
  370. package/modern/LineChart/LineElement.js +106 -0
  371. package/modern/LineChart/LinePlot.js +58 -0
  372. package/modern/LineChart/MarkElement.js +129 -0
  373. package/modern/LineChart/MarkPlot.js +78 -0
  374. package/modern/LineChart/extremums.js +28 -0
  375. package/modern/LineChart/formatter.js +48 -0
  376. package/modern/LineChart/index.js +7 -0
  377. package/modern/ResponsiveChartContainer/index.js +45 -0
  378. package/modern/ScatterChart/Scatter.js +106 -0
  379. package/modern/ScatterChart/ScatterChart.js +245 -0
  380. package/modern/ScatterChart/ScatterPlot.js +44 -0
  381. package/modern/ScatterChart/extremums.js +41 -0
  382. package/modern/ScatterChart/formatter.js +11 -0
  383. package/modern/ScatterChart/index.js +3 -0
  384. package/modern/colorPalettes/colorPalettes.js +9 -0
  385. package/modern/colorPalettes/index.js +1 -0
  386. package/modern/constants.js +8 -0
  387. package/modern/context/CartesianContextProvider.js +217 -0
  388. package/modern/context/DrawingProvider.js +52 -0
  389. package/modern/context/HighlightProvider.js +46 -0
  390. package/modern/context/InteractionProvider.js +51 -0
  391. package/modern/context/SeriesContextProvider.js +58 -0
  392. package/modern/context/index.js +2 -0
  393. package/modern/hooks/useAxisEvents.js +145 -0
  394. package/modern/hooks/useChartDimensions.js +14 -0
  395. package/modern/hooks/useInteractionItemProps.js +68 -0
  396. package/modern/hooks/useScale.js +33 -0
  397. package/modern/hooks/useTicks.js +40 -0
  398. package/modern/index.js +22 -0
  399. package/modern/internals/components/AxisSharedComponents.js +81 -0
  400. package/modern/internals/defaultizeColor.js +7 -0
  401. package/modern/internals/defaultizeValueFormatter.js +11 -0
  402. package/modern/internals/getCurve.js +39 -0
  403. package/modern/internals/stackSeries.js +93 -0
  404. package/modern/internals/utils.js +5 -0
  405. package/modern/models/axis.js +1 -0
  406. package/modern/models/helpers.js +1 -0
  407. package/modern/models/index.js +1 -0
  408. package/modern/models/layout.js +1 -0
  409. package/modern/models/seriesType/bar.js +1 -0
  410. package/modern/models/seriesType/common.js +1 -0
  411. package/modern/models/seriesType/config.js +1 -0
  412. package/modern/models/seriesType/index.js +12 -0
  413. package/modern/models/seriesType/line.js +1 -0
  414. package/modern/models/seriesType/pie.js +1 -0
  415. package/modern/models/seriesType/scatter.js +1 -0
  416. package/modern/themeAugmentation/index.js +3 -0
  417. package/package.json +57 -0
  418. package/themeAugmentation/components.d.ts +72 -0
  419. package/themeAugmentation/index.d.ts +3 -0
  420. package/themeAugmentation/index.js +38 -0
  421. package/themeAugmentation/overrides.d.ts +29 -0
  422. package/themeAugmentation/package.json +6 -0
  423. package/themeAugmentation/props.d.ts +43 -0
@@ -0,0 +1,255 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import useId from '@mui/utils/useId';
4
+ import PropTypes from 'prop-types';
5
+ import { BarPlot } from './BarPlot';
6
+ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
7
+ import { ChartsAxis } from '../ChartsAxis';
8
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
9
+ import { ChartsTooltip } from '../ChartsTooltip';
10
+ import { ChartsLegend } from '../ChartsLegend';
11
+ import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
12
+ import { ChartsClipPath } from '../ChartsClipPath';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ function BarChart(props) {
16
+ const {
17
+ xAxis,
18
+ yAxis,
19
+ series,
20
+ width,
21
+ height,
22
+ margin,
23
+ colors,
24
+ sx,
25
+ tooltip,
26
+ axisHighlight,
27
+ legend,
28
+ topAxis,
29
+ leftAxis,
30
+ rightAxis,
31
+ bottomAxis,
32
+ children
33
+ } = props;
34
+ const id = useId();
35
+ const clipPathId = `${id}-clip-path`;
36
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
37
+ series: series.map(s => _extends({
38
+ type: 'bar'
39
+ }, s)),
40
+ width: width,
41
+ height: height,
42
+ margin: margin,
43
+ xAxis: xAxis != null ? xAxis : [{
44
+ id: DEFAULT_X_AXIS_KEY,
45
+ scaleType: 'band',
46
+ data: [...new Array(Math.max(...series.map(s => s.data.length)))].map((_, index) => index)
47
+ }],
48
+ yAxis: yAxis,
49
+ colors: colors,
50
+ sx: sx,
51
+ disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
52
+ children: [/*#__PURE__*/_jsx("g", {
53
+ clipPath: `url(#${clipPathId})`,
54
+ children: /*#__PURE__*/_jsx(BarPlot, {})
55
+ }), /*#__PURE__*/_jsx(ChartsAxis, {
56
+ topAxis: topAxis,
57
+ leftAxis: leftAxis,
58
+ rightAxis: rightAxis,
59
+ bottomAxis: bottomAxis
60
+ }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
61
+ x: "band"
62
+ }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
63
+ id: clipPathId
64
+ }), children]
65
+ });
66
+ }
67
+ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
68
+ // ----------------------------- Warning --------------------------------
69
+ // | These PropTypes are generated from the TypeScript type definitions |
70
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
71
+ // ----------------------------------------------------------------------
72
+ axisHighlight: PropTypes.shape({
73
+ x: PropTypes.oneOf(['band', 'line', 'none']),
74
+ y: PropTypes.oneOf(['line', 'none'])
75
+ }),
76
+ /**
77
+ * Indicate which axis to display the the bottom of the charts.
78
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
79
+ * @default xAxisIds[0] The id of the first provided axis
80
+ */
81
+ bottomAxis: PropTypes.oneOfType([PropTypes.shape({
82
+ axisId: PropTypes.string.isRequired,
83
+ classes: PropTypes.object,
84
+ disableLine: PropTypes.bool,
85
+ disableTicks: PropTypes.bool,
86
+ fill: PropTypes.string,
87
+ label: PropTypes.string,
88
+ labelFontSize: PropTypes.number,
89
+ position: PropTypes.oneOf(['bottom', 'top']),
90
+ stroke: PropTypes.string,
91
+ tickFontSize: PropTypes.number,
92
+ tickSize: PropTypes.number
93
+ }), PropTypes.string]),
94
+ children: PropTypes.node,
95
+ className: PropTypes.string,
96
+ /**
97
+ * Color palette used to colorize multiple series.
98
+ */
99
+ colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
100
+ desc: PropTypes.string,
101
+ disableAxisListener: PropTypes.bool,
102
+ height: PropTypes.number,
103
+ /**
104
+ * Indicate which axis to display the the left of the charts.
105
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
106
+ * @default yAxisIds[0] The id of the first provided axis
107
+ */
108
+ leftAxis: PropTypes.oneOfType([PropTypes.shape({
109
+ axisId: PropTypes.string.isRequired,
110
+ classes: PropTypes.object,
111
+ disableLine: PropTypes.bool,
112
+ disableTicks: PropTypes.bool,
113
+ fill: PropTypes.string,
114
+ label: PropTypes.string,
115
+ labelFontSize: PropTypes.number,
116
+ position: PropTypes.oneOf(['left', 'right']),
117
+ stroke: PropTypes.string,
118
+ tickFontSize: PropTypes.number,
119
+ tickSize: PropTypes.number
120
+ }), PropTypes.string]),
121
+ legend: PropTypes.shape({
122
+ classes: PropTypes.object,
123
+ direction: PropTypes.oneOf(['column', 'row']),
124
+ itemWidth: PropTypes.number,
125
+ markSize: PropTypes.number,
126
+ offset: PropTypes.shape({
127
+ x: PropTypes.number,
128
+ y: PropTypes.number
129
+ }),
130
+ position: PropTypes.shape({
131
+ horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
132
+ vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
133
+ }),
134
+ spacing: PropTypes.number
135
+ }),
136
+ margin: PropTypes.shape({
137
+ bottom: PropTypes.number,
138
+ left: PropTypes.number,
139
+ right: PropTypes.number,
140
+ top: PropTypes.number
141
+ }),
142
+ /**
143
+ * Indicate which axis to display the the right of the charts.
144
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
145
+ * @default null
146
+ */
147
+ rightAxis: PropTypes.oneOfType([PropTypes.shape({
148
+ axisId: PropTypes.string.isRequired,
149
+ classes: PropTypes.object,
150
+ disableLine: PropTypes.bool,
151
+ disableTicks: PropTypes.bool,
152
+ fill: PropTypes.string,
153
+ label: PropTypes.string,
154
+ labelFontSize: PropTypes.number,
155
+ position: PropTypes.oneOf(['left', 'right']),
156
+ stroke: PropTypes.string,
157
+ tickFontSize: PropTypes.number,
158
+ tickSize: PropTypes.number
159
+ }), PropTypes.string]),
160
+ series: PropTypes.arrayOf(PropTypes.shape({
161
+ color: PropTypes.string,
162
+ data: PropTypes.arrayOf(PropTypes.number).isRequired,
163
+ highlightScope: PropTypes.shape({
164
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
165
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
166
+ }),
167
+ id: PropTypes.string,
168
+ label: PropTypes.string,
169
+ stack: PropTypes.string,
170
+ stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
171
+ stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
172
+ type: PropTypes.oneOf(['bar']),
173
+ valueFormatter: PropTypes.func,
174
+ xAxisKey: PropTypes.string,
175
+ yAxisKey: PropTypes.string
176
+ })).isRequired,
177
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
178
+ title: PropTypes.string,
179
+ tooltip: PropTypes.shape({
180
+ axisContent: PropTypes.elementType,
181
+ classes: PropTypes.object,
182
+ itemContent: PropTypes.elementType,
183
+ trigger: PropTypes.oneOf(['axis', 'item', 'none'])
184
+ }),
185
+ /**
186
+ * Indicate which axis to display the the top of the charts.
187
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
188
+ * @default null
189
+ */
190
+ topAxis: PropTypes.oneOfType([PropTypes.shape({
191
+ axisId: PropTypes.string.isRequired,
192
+ classes: PropTypes.object,
193
+ disableLine: PropTypes.bool,
194
+ disableTicks: PropTypes.bool,
195
+ fill: PropTypes.string,
196
+ label: PropTypes.string,
197
+ labelFontSize: PropTypes.number,
198
+ position: PropTypes.oneOf(['bottom', 'top']),
199
+ stroke: PropTypes.string,
200
+ tickFontSize: PropTypes.number,
201
+ tickSize: PropTypes.number
202
+ }), PropTypes.string]),
203
+ viewBox: PropTypes.shape({
204
+ height: PropTypes.number,
205
+ width: PropTypes.number,
206
+ x: PropTypes.number,
207
+ y: PropTypes.number
208
+ }),
209
+ width: PropTypes.number,
210
+ xAxis: PropTypes.arrayOf(PropTypes.shape({
211
+ axisId: PropTypes.string,
212
+ classes: PropTypes.object,
213
+ data: PropTypes.array,
214
+ disableLine: PropTypes.bool,
215
+ disableTicks: PropTypes.bool,
216
+ fill: PropTypes.string,
217
+ id: PropTypes.string,
218
+ label: PropTypes.string,
219
+ labelFontSize: PropTypes.number,
220
+ max: PropTypes.number,
221
+ maxTicks: PropTypes.number,
222
+ min: PropTypes.number,
223
+ minTicks: PropTypes.number,
224
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
225
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
226
+ stroke: PropTypes.string,
227
+ tickFontSize: PropTypes.number,
228
+ tickSize: PropTypes.number,
229
+ tickSpacing: PropTypes.number,
230
+ valueFormatter: PropTypes.func
231
+ })),
232
+ yAxis: PropTypes.arrayOf(PropTypes.shape({
233
+ axisId: PropTypes.string,
234
+ classes: PropTypes.object,
235
+ data: PropTypes.array,
236
+ disableLine: PropTypes.bool,
237
+ disableTicks: PropTypes.bool,
238
+ fill: PropTypes.string,
239
+ id: PropTypes.string,
240
+ label: PropTypes.string,
241
+ labelFontSize: PropTypes.number,
242
+ max: PropTypes.number,
243
+ maxTicks: PropTypes.number,
244
+ min: PropTypes.number,
245
+ minTicks: PropTypes.number,
246
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
247
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
248
+ stroke: PropTypes.string,
249
+ tickFontSize: PropTypes.number,
250
+ tickSize: PropTypes.number,
251
+ tickSpacing: PropTypes.number,
252
+ valueFormatter: PropTypes.func
253
+ }))
254
+ } : void 0;
255
+ export { BarChart };
@@ -0,0 +1,80 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope"];
4
+ import * as React from 'react';
5
+ import composeClasses from '@mui/utils/composeClasses';
6
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
7
+ import { styled } from '@mui/material/styles';
8
+ import { color as d3Color } from 'd3-color';
9
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
+ import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
11
+ import { InteractionContext } from '../context/InteractionProvider';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ export function getBarElementUtilityClass(slot) {
14
+ return generateUtilityClass('MuiBarElement', slot);
15
+ }
16
+ export const lineElementClasses = generateUtilityClasses('MuiBarElement', ['root']);
17
+ const useUtilityClasses = ownerState => {
18
+ const {
19
+ classes,
20
+ id
21
+ } = ownerState;
22
+ const slots = {
23
+ root: ['root', `series-${id}`]
24
+ };
25
+ return composeClasses(slots, getBarElementUtilityClass, classes);
26
+ };
27
+ const BarElementPath = styled('rect', {
28
+ name: 'MuiBarElement',
29
+ slot: 'Root',
30
+ overridesResolver: (_, styles) => styles.root
31
+ })(({
32
+ ownerState
33
+ }) => ({
34
+ stroke: 'none',
35
+ shapeRendering: 'crispEdges',
36
+ fill: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
37
+ transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
38
+ opacity: ownerState.isFaded && 0.3 || 1
39
+ }));
40
+ export function BarElement(props) {
41
+ const {
42
+ id,
43
+ dataIndex,
44
+ classes: innerClasses,
45
+ color,
46
+ highlightScope
47
+ } = props,
48
+ other = _objectWithoutPropertiesLoose(props, _excluded);
49
+ const getInteractionItemProps = useInteractionItemProps(highlightScope);
50
+ const {
51
+ item
52
+ } = React.useContext(InteractionContext);
53
+ const isHighlighted = getIsHighlighted(item, {
54
+ type: 'bar',
55
+ seriesId: id,
56
+ dataIndex
57
+ }, highlightScope);
58
+ const isFaded = !isHighlighted && getIsFaded(item, {
59
+ type: 'bar',
60
+ seriesId: id,
61
+ dataIndex
62
+ }, highlightScope);
63
+ const ownerState = {
64
+ id,
65
+ dataIndex,
66
+ classes: innerClasses,
67
+ color,
68
+ isFaded,
69
+ isHighlighted
70
+ };
71
+ const classes = useUtilityClasses(ownerState);
72
+ return /*#__PURE__*/_jsx(BarElementPath, _extends({}, other, {
73
+ ownerState: ownerState,
74
+ className: classes.root
75
+ }, getInteractionItemProps({
76
+ type: 'bar',
77
+ seriesId: id,
78
+ dataIndex
79
+ })));
80
+ }
@@ -0,0 +1,70 @@
1
+ import * as React from 'react';
2
+ import { SeriesContext } from '../context/SeriesContextProvider';
3
+ import { CartesianContext } from '../context/CartesianContextProvider';
4
+ import { isBandScale } from '../hooks/useScale';
5
+ import { BarElement } from './BarElement';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function BarPlot() {
8
+ const seriesData = React.useContext(SeriesContext).bar;
9
+ const axisData = React.useContext(CartesianContext);
10
+ if (seriesData === undefined) {
11
+ return null;
12
+ }
13
+ const {
14
+ series,
15
+ stackingGroups
16
+ } = seriesData;
17
+ const {
18
+ xAxis,
19
+ yAxis,
20
+ xAxisIds,
21
+ yAxisIds
22
+ } = axisData;
23
+ const defaultXAxisId = xAxisIds[0];
24
+ const defaultYAxisId = yAxisIds[0];
25
+ return /*#__PURE__*/_jsx(React.Fragment, {
26
+ children: stackingGroups.flatMap(({
27
+ ids: groupIds
28
+ }, groupIndex) => {
29
+ return groupIds.flatMap(seriesId => {
30
+ var _series$seriesId$xAxi, _series$seriesId$yAxi;
31
+ const xAxisKey = (_series$seriesId$xAxi = series[seriesId].xAxisKey) != null ? _series$seriesId$xAxi : defaultXAxisId;
32
+ const yAxisKey = (_series$seriesId$yAxi = series[seriesId].yAxisKey) != null ? _series$seriesId$yAxi : defaultYAxisId;
33
+ const xScale = xAxis[xAxisKey].scale;
34
+ const yScale = yAxis[yAxisKey].scale;
35
+ if (!isBandScale(xScale)) {
36
+ throw new Error(`Axis with id "${xAxisKey}" shoud be of type "band" to display the bar series ${stackingGroups}`);
37
+ }
38
+ if (xAxis[xAxisKey].data === undefined) {
39
+ throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
40
+ }
41
+
42
+ // Currently assuming all bars are vertical
43
+ const bandWidth = xScale.bandwidth();
44
+ const barWidth = 0.9 * bandWidth / stackingGroups.length;
45
+ const offset = 0.05 * bandWidth;
46
+
47
+ // @ts-ignore TODO: fix when adding a correct API for customisation
48
+ const {
49
+ stackedData,
50
+ color
51
+ } = series[seriesId];
52
+ return stackedData.map((values, dataIndex) => {
53
+ var _xAxis$xAxisKey$data;
54
+ const baseline = Math.min(...values);
55
+ const value = Math.max(...values);
56
+ return /*#__PURE__*/_jsx(BarElement, {
57
+ id: seriesId,
58
+ dataIndex: dataIndex,
59
+ x: xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + groupIndex * barWidth + offset,
60
+ y: yScale(value),
61
+ height: yScale(baseline) - yScale(value),
62
+ width: barWidth,
63
+ color: color,
64
+ highlightScope: series[seriesId].highlightScope
65
+ }, `${seriesId}-${dataIndex}`);
66
+ });
67
+ });
68
+ })
69
+ });
70
+ }
@@ -0,0 +1,20 @@
1
+ export const getExtremumX = params => {
2
+ var _axis$data, _axis$data2;
3
+ const {
4
+ axis
5
+ } = params;
6
+ const minX = Math.min(...((_axis$data = axis.data) != null ? _axis$data : []));
7
+ const maxX = Math.max(...((_axis$data2 = axis.data) != null ? _axis$data2 : []));
8
+ return [minX, maxX];
9
+ };
10
+ export const getExtremumY = params => {
11
+ const {
12
+ series,
13
+ axis,
14
+ isDefaultAxis
15
+ } = params;
16
+ return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
17
+ const [seriesMin, seriesMax] = series[seriesId].stackedData.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]);
18
+ return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
19
+ }, [null, null]);
20
+ };
@@ -0,0 +1,46 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { stack as d3Stack } from 'd3-shape';
3
+ import { getStackingGroups } from '../internals/stackSeries';
4
+ import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
5
+ const formatter = params => {
6
+ const {
7
+ seriesOrder,
8
+ series
9
+ } = params;
10
+ const stackingGroups = getStackingGroups(params);
11
+
12
+ // Create a data set with format adapted to d3
13
+ const d3Dataset = [];
14
+ seriesOrder.forEach(id => {
15
+ series[id].data.forEach((value, index) => {
16
+ if (d3Dataset.length <= index) {
17
+ d3Dataset.push({
18
+ [id]: value
19
+ });
20
+ } else {
21
+ d3Dataset[index][id] = value;
22
+ }
23
+ });
24
+ });
25
+ const completedSeries = {};
26
+ stackingGroups.forEach(stackingGroup => {
27
+ const {
28
+ ids,
29
+ stackingOffset,
30
+ stackingOrder
31
+ } = stackingGroup;
32
+ // Get stacked values, and derive the domain
33
+ const stackedSeries = d3Stack().keys(ids).order(stackingOrder).offset(stackingOffset)(d3Dataset);
34
+ ids.forEach((id, index) => {
35
+ completedSeries[id] = _extends({}, series[id], {
36
+ stackedData: stackedSeries[index].map(([a, b]) => [a, b])
37
+ });
38
+ });
39
+ });
40
+ return {
41
+ seriesOrder,
42
+ stackingGroups,
43
+ series: defaultizeValueFormatter(completedSeries, v => v.toLocaleString())
44
+ };
45
+ };
46
+ export default formatter;
@@ -0,0 +1,2 @@
1
+ export { BarPlot } from './BarPlot';
2
+ export { BarChart } from './BarChart';
@@ -0,0 +1,53 @@
1
+ import * as React from 'react';
2
+ import { DrawingProvider } from '../context/DrawingProvider';
3
+ import { SeriesContextProvider } from '../context/SeriesContextProvider';
4
+ import { InteractionProvider } from '../context/InteractionProvider';
5
+ import { ChartsSurface } from '../ChartsSurface';
6
+ import { CartesianContextProvider } from '../context/CartesianContextProvider';
7
+ import { HighlightProvider } from '../context/HighlightProvider';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export function ChartContainer(props) {
10
+ const {
11
+ width,
12
+ height,
13
+ series,
14
+ margin,
15
+ xAxis,
16
+ yAxis,
17
+ colors,
18
+ sx,
19
+ title,
20
+ desc,
21
+ disableAxisListener,
22
+ children
23
+ } = props;
24
+ const ref = React.useRef(null);
25
+ return /*#__PURE__*/_jsx(DrawingProvider, {
26
+ width: width,
27
+ height: height,
28
+ margin: margin,
29
+ svgRef: ref,
30
+ children: /*#__PURE__*/_jsx(SeriesContextProvider, {
31
+ series: series,
32
+ colors: colors,
33
+ children: /*#__PURE__*/_jsx(CartesianContextProvider, {
34
+ xAxis: xAxis,
35
+ yAxis: yAxis,
36
+ children: /*#__PURE__*/_jsx(InteractionProvider, {
37
+ children: /*#__PURE__*/_jsx(HighlightProvider, {
38
+ children: /*#__PURE__*/_jsx(ChartsSurface, {
39
+ width: width,
40
+ height: height,
41
+ ref: ref,
42
+ sx: sx,
43
+ title: title,
44
+ desc: desc,
45
+ disableAxisListener: disableAxisListener,
46
+ children: children
47
+ })
48
+ })
49
+ })
50
+ })
51
+ })
52
+ });
53
+ }
@@ -0,0 +1,145 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { CartesianContext } from '../context/CartesianContextProvider';
5
+ import { ChartsXAxis } from '../ChartsXAxis';
6
+ import { ChartsYAxis } from '../ChartsYAxis';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ const getAxisId = propsValue => {
10
+ if (propsValue == null) {
11
+ return null;
12
+ }
13
+ if (typeof propsValue === 'object') {
14
+ return propsValue.axisId;
15
+ }
16
+ return propsValue;
17
+ };
18
+ function ChartsAxis(props) {
19
+ const {
20
+ topAxis,
21
+ leftAxis,
22
+ rightAxis,
23
+ bottomAxis
24
+ } = props;
25
+ const {
26
+ xAxis,
27
+ xAxisIds,
28
+ yAxis,
29
+ yAxisIds
30
+ } = React.useContext(CartesianContext);
31
+
32
+ // TODO: use for plotting line without ticks or any thing
33
+ // const drawingArea = React.useContext(DrawingContext);
34
+
35
+ const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis);
36
+ const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis);
37
+ const topId = getAxisId(topAxis);
38
+ const rightId = getAxisId(rightAxis);
39
+ if (topId !== null && !xAxis[topId]) {
40
+ throw Error(`MUI: id used for top axis "${topId}" is not defined`);
41
+ }
42
+ if (leftId !== null && !yAxis[leftId]) {
43
+ throw Error(`MUI: id used for left axis "${leftId}" is not defined`);
44
+ }
45
+ if (rightId !== null && !yAxis[rightId]) {
46
+ throw Error(`MUI: id used for right axis "${rightId}" is not defined`);
47
+ }
48
+ if (bottomId !== null && !xAxis[bottomId]) {
49
+ throw Error(`MUI: id used for bottom axis "${bottomId}" is not defined`);
50
+ }
51
+ return /*#__PURE__*/_jsxs(React.Fragment, {
52
+ children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
53
+ position: "top",
54
+ axisId: topId
55
+ }, typeof topAxis === 'object' ? topAxis : {})), bottomId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
56
+ position: "bottom",
57
+ axisId: bottomId
58
+ }, typeof bottomAxis === 'object' ? bottomAxis : {})), leftId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({
59
+ position: "left",
60
+ axisId: leftId
61
+ }, typeof leftAxis === 'object' ? leftAxis : {})), rightId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({
62
+ position: "right",
63
+ axisId: rightId
64
+ }, typeof rightAxis === 'object' ? rightAxis : {}))]
65
+ });
66
+ }
67
+ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
68
+ // ----------------------------- Warning --------------------------------
69
+ // | These PropTypes are generated from the TypeScript type definitions |
70
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
71
+ // ----------------------------------------------------------------------
72
+ /**
73
+ * Indicate which axis to display the the bottom of the charts.
74
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
75
+ * @default xAxisIds[0] The id of the first provided axis
76
+ */
77
+ bottomAxis: PropTypes.oneOfType([PropTypes.shape({
78
+ axisId: PropTypes.string.isRequired,
79
+ classes: PropTypes.object,
80
+ disableLine: PropTypes.bool,
81
+ disableTicks: PropTypes.bool,
82
+ fill: PropTypes.string,
83
+ label: PropTypes.string,
84
+ labelFontSize: PropTypes.number,
85
+ position: PropTypes.oneOf(['bottom', 'top']),
86
+ stroke: PropTypes.string,
87
+ tickFontSize: PropTypes.number,
88
+ tickSize: PropTypes.number
89
+ }), PropTypes.string]),
90
+ /**
91
+ * Indicate which axis to display the the left of the charts.
92
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
93
+ * @default yAxisIds[0] The id of the first provided axis
94
+ */
95
+ leftAxis: PropTypes.oneOfType([PropTypes.shape({
96
+ axisId: PropTypes.string.isRequired,
97
+ classes: PropTypes.object,
98
+ disableLine: PropTypes.bool,
99
+ disableTicks: PropTypes.bool,
100
+ fill: PropTypes.string,
101
+ label: PropTypes.string,
102
+ labelFontSize: PropTypes.number,
103
+ position: PropTypes.oneOf(['left', 'right']),
104
+ stroke: PropTypes.string,
105
+ tickFontSize: PropTypes.number,
106
+ tickSize: PropTypes.number
107
+ }), PropTypes.string]),
108
+ /**
109
+ * Indicate which axis to display the the right of the charts.
110
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
111
+ * @default null
112
+ */
113
+ rightAxis: PropTypes.oneOfType([PropTypes.shape({
114
+ axisId: PropTypes.string.isRequired,
115
+ classes: PropTypes.object,
116
+ disableLine: PropTypes.bool,
117
+ disableTicks: PropTypes.bool,
118
+ fill: PropTypes.string,
119
+ label: PropTypes.string,
120
+ labelFontSize: PropTypes.number,
121
+ position: PropTypes.oneOf(['left', 'right']),
122
+ stroke: PropTypes.string,
123
+ tickFontSize: PropTypes.number,
124
+ tickSize: PropTypes.number
125
+ }), PropTypes.string]),
126
+ /**
127
+ * Indicate which axis to display the the top of the charts.
128
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
129
+ * @default null
130
+ */
131
+ topAxis: PropTypes.oneOfType([PropTypes.shape({
132
+ axisId: PropTypes.string.isRequired,
133
+ classes: PropTypes.object,
134
+ disableLine: PropTypes.bool,
135
+ disableTicks: PropTypes.bool,
136
+ fill: PropTypes.string,
137
+ label: PropTypes.string,
138
+ labelFontSize: PropTypes.number,
139
+ position: PropTypes.oneOf(['bottom', 'top']),
140
+ stroke: PropTypes.string,
141
+ tickFontSize: PropTypes.number,
142
+ tickSize: PropTypes.number
143
+ }), PropTypes.string])
144
+ } : void 0;
145
+ export { ChartsAxis };
@@ -0,0 +1,5 @@
1
+ import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
+ export function getAxisUtilityClass(slot) {
3
+ return generateUtilityClass('MuiChartsAxis', slot);
4
+ }
5
+ export const axisClasses = generateUtilityClasses('MuiChartsAxis', ['root', 'line', 'tickContainer', 'tick', 'tickLabel', 'label', 'directionX', 'directionY', 'top', 'bottom', 'left', 'right']);
@@ -0,0 +1,2 @@
1
+ export * from './ChartsAxis';
2
+ export * from './axisClasses';