@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,259 @@
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 { AreaPlot } from './AreaPlot';
6
+ import { LinePlot } from './LinePlot';
7
+ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
8
+ import { MarkPlot } from './MarkPlot';
9
+ import { ChartsAxis } from '../ChartsAxis/ChartsAxis';
10
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
11
+ import { ChartsTooltip } from '../ChartsTooltip';
12
+ import { ChartsLegend } from '../ChartsLegend';
13
+ import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
14
+ import { ChartsClipPath } from '../ChartsClipPath';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ function LineChart(props) {
18
+ const {
19
+ xAxis,
20
+ yAxis,
21
+ series,
22
+ width,
23
+ height,
24
+ margin,
25
+ colors,
26
+ sx,
27
+ tooltip,
28
+ axisHighlight = {
29
+ x: 'line'
30
+ },
31
+ legend,
32
+ topAxis,
33
+ leftAxis,
34
+ rightAxis,
35
+ bottomAxis,
36
+ children
37
+ } = props;
38
+ const id = useId();
39
+ const clipPathId = `${id}-clip-path`;
40
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
41
+ series: series.map(s => _extends({
42
+ type: 'line'
43
+ }, s)),
44
+ width: width,
45
+ height: height,
46
+ margin: margin,
47
+ xAxis: xAxis != null ? xAxis : [{
48
+ id: DEFAULT_X_AXIS_KEY,
49
+ scaleType: 'point',
50
+ data: [...new Array(Math.max(...series.map(s => s.data.length)))].map((_, index) => index)
51
+ }],
52
+ yAxis: yAxis,
53
+ colors: colors,
54
+ sx: sx,
55
+ disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
56
+ children: [/*#__PURE__*/_jsxs("g", {
57
+ clipPath: `url(#${clipPathId})`,
58
+ children: [/*#__PURE__*/_jsx(AreaPlot, {}), /*#__PURE__*/_jsx(LinePlot, {})]
59
+ }), /*#__PURE__*/_jsx(ChartsAxis, {
60
+ topAxis: topAxis,
61
+ leftAxis: leftAxis,
62
+ rightAxis: rightAxis,
63
+ bottomAxis: bottomAxis
64
+ }), /*#__PURE__*/_jsx(MarkPlot, {}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
65
+ id: clipPathId
66
+ }), children]
67
+ });
68
+ }
69
+ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
70
+ // ----------------------------- Warning --------------------------------
71
+ // | These PropTypes are generated from the TypeScript type definitions |
72
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
73
+ // ----------------------------------------------------------------------
74
+ axisHighlight: PropTypes.shape({
75
+ x: PropTypes.oneOf(['band', 'line', 'none']),
76
+ y: PropTypes.oneOf(['line', 'none'])
77
+ }),
78
+ /**
79
+ * Indicate which axis to display the the bottom of the charts.
80
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
81
+ * @default xAxisIds[0] The id of the first provided axis
82
+ */
83
+ bottomAxis: PropTypes.oneOfType([PropTypes.shape({
84
+ axisId: PropTypes.string.isRequired,
85
+ classes: PropTypes.object,
86
+ disableLine: PropTypes.bool,
87
+ disableTicks: PropTypes.bool,
88
+ fill: PropTypes.string,
89
+ label: PropTypes.string,
90
+ labelFontSize: PropTypes.number,
91
+ position: PropTypes.oneOf(['bottom', 'top']),
92
+ stroke: PropTypes.string,
93
+ tickFontSize: PropTypes.number,
94
+ tickSize: PropTypes.number
95
+ }), PropTypes.string]),
96
+ children: PropTypes.node,
97
+ className: PropTypes.string,
98
+ /**
99
+ * Color palette used to colorize multiple series.
100
+ */
101
+ colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
102
+ desc: PropTypes.string,
103
+ disableAxisListener: PropTypes.bool,
104
+ height: PropTypes.number,
105
+ /**
106
+ * Indicate which axis to display the the left of the charts.
107
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
108
+ * @default yAxisIds[0] The id of the first provided axis
109
+ */
110
+ leftAxis: PropTypes.oneOfType([PropTypes.shape({
111
+ axisId: PropTypes.string.isRequired,
112
+ classes: PropTypes.object,
113
+ disableLine: PropTypes.bool,
114
+ disableTicks: PropTypes.bool,
115
+ fill: PropTypes.string,
116
+ label: PropTypes.string,
117
+ labelFontSize: PropTypes.number,
118
+ position: PropTypes.oneOf(['left', 'right']),
119
+ stroke: PropTypes.string,
120
+ tickFontSize: PropTypes.number,
121
+ tickSize: PropTypes.number
122
+ }), PropTypes.string]),
123
+ legend: PropTypes.shape({
124
+ classes: PropTypes.object,
125
+ direction: PropTypes.oneOf(['column', 'row']),
126
+ itemWidth: PropTypes.number,
127
+ markSize: PropTypes.number,
128
+ offset: PropTypes.shape({
129
+ x: PropTypes.number,
130
+ y: PropTypes.number
131
+ }),
132
+ position: PropTypes.shape({
133
+ horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
134
+ vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
135
+ }),
136
+ spacing: PropTypes.number
137
+ }),
138
+ margin: PropTypes.shape({
139
+ bottom: PropTypes.number,
140
+ left: PropTypes.number,
141
+ right: PropTypes.number,
142
+ top: PropTypes.number
143
+ }),
144
+ /**
145
+ * Indicate which axis to display the the right of the charts.
146
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
147
+ * @default null
148
+ */
149
+ rightAxis: PropTypes.oneOfType([PropTypes.shape({
150
+ axisId: PropTypes.string.isRequired,
151
+ classes: PropTypes.object,
152
+ disableLine: PropTypes.bool,
153
+ disableTicks: PropTypes.bool,
154
+ fill: PropTypes.string,
155
+ label: PropTypes.string,
156
+ labelFontSize: PropTypes.number,
157
+ position: PropTypes.oneOf(['left', 'right']),
158
+ stroke: PropTypes.string,
159
+ tickFontSize: PropTypes.number,
160
+ tickSize: PropTypes.number
161
+ }), PropTypes.string]),
162
+ series: PropTypes.arrayOf(PropTypes.shape({
163
+ area: PropTypes.bool,
164
+ color: PropTypes.string,
165
+ curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
166
+ data: PropTypes.arrayOf(PropTypes.number).isRequired,
167
+ highlightScope: PropTypes.shape({
168
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
169
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
170
+ }),
171
+ id: PropTypes.string,
172
+ label: PropTypes.string,
173
+ stack: PropTypes.string,
174
+ stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
175
+ stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
176
+ type: PropTypes.oneOf(['line']),
177
+ valueFormatter: PropTypes.func,
178
+ xAxisKey: PropTypes.string,
179
+ yAxisKey: PropTypes.string
180
+ })).isRequired,
181
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
182
+ title: PropTypes.string,
183
+ tooltip: PropTypes.shape({
184
+ axisContent: PropTypes.elementType,
185
+ classes: PropTypes.object,
186
+ itemContent: PropTypes.elementType,
187
+ trigger: PropTypes.oneOf(['axis', 'item', 'none'])
188
+ }),
189
+ /**
190
+ * Indicate which axis to display the the top of the charts.
191
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
192
+ * @default null
193
+ */
194
+ topAxis: PropTypes.oneOfType([PropTypes.shape({
195
+ axisId: PropTypes.string.isRequired,
196
+ classes: PropTypes.object,
197
+ disableLine: PropTypes.bool,
198
+ disableTicks: PropTypes.bool,
199
+ fill: PropTypes.string,
200
+ label: PropTypes.string,
201
+ labelFontSize: PropTypes.number,
202
+ position: PropTypes.oneOf(['bottom', 'top']),
203
+ stroke: PropTypes.string,
204
+ tickFontSize: PropTypes.number,
205
+ tickSize: PropTypes.number
206
+ }), PropTypes.string]),
207
+ viewBox: PropTypes.shape({
208
+ height: PropTypes.number,
209
+ width: PropTypes.number,
210
+ x: PropTypes.number,
211
+ y: PropTypes.number
212
+ }),
213
+ width: PropTypes.number,
214
+ xAxis: PropTypes.arrayOf(PropTypes.shape({
215
+ axisId: PropTypes.string,
216
+ classes: PropTypes.object,
217
+ data: PropTypes.array,
218
+ disableLine: PropTypes.bool,
219
+ disableTicks: PropTypes.bool,
220
+ fill: PropTypes.string,
221
+ id: PropTypes.string,
222
+ label: PropTypes.string,
223
+ labelFontSize: PropTypes.number,
224
+ max: PropTypes.number,
225
+ maxTicks: PropTypes.number,
226
+ min: PropTypes.number,
227
+ minTicks: PropTypes.number,
228
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
229
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
230
+ stroke: PropTypes.string,
231
+ tickFontSize: PropTypes.number,
232
+ tickSize: PropTypes.number,
233
+ tickSpacing: PropTypes.number,
234
+ valueFormatter: PropTypes.func
235
+ })),
236
+ yAxis: PropTypes.arrayOf(PropTypes.shape({
237
+ axisId: PropTypes.string,
238
+ classes: PropTypes.object,
239
+ data: PropTypes.array,
240
+ disableLine: PropTypes.bool,
241
+ disableTicks: PropTypes.bool,
242
+ fill: PropTypes.string,
243
+ id: PropTypes.string,
244
+ label: PropTypes.string,
245
+ labelFontSize: PropTypes.number,
246
+ max: PropTypes.number,
247
+ maxTicks: PropTypes.number,
248
+ min: PropTypes.number,
249
+ minTicks: PropTypes.number,
250
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
251
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
252
+ stroke: PropTypes.string,
253
+ tickFontSize: PropTypes.number,
254
+ tickSize: PropTypes.number,
255
+ tickSpacing: PropTypes.number,
256
+ valueFormatter: PropTypes.func
257
+ }))
258
+ } : void 0;
259
+ export { LineChart };
@@ -0,0 +1,106 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["id", "classes", "color", "highlightScope"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { color as d3Color } from 'd3-color';
7
+ import composeClasses from '@mui/utils/composeClasses';
8
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
9
+ import { styled } from '@mui/material/styles';
10
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
11
+ import { InteractionContext } from '../context/InteractionProvider';
12
+ import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ export function getLineElementUtilityClass(slot) {
15
+ return generateUtilityClass('MuiLineElement', slot);
16
+ }
17
+ export const lineElementClasses = generateUtilityClasses('MuiLineElement', ['root', 'highlighted', 'faded']);
18
+ const useUtilityClasses = ownerState => {
19
+ const {
20
+ classes,
21
+ id,
22
+ isFaded,
23
+ isHighlighted
24
+ } = ownerState;
25
+ const slots = {
26
+ root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
27
+ };
28
+ return composeClasses(slots, getLineElementUtilityClass, classes);
29
+ };
30
+ const LineElementPath = styled('path', {
31
+ name: 'MuiLineElement',
32
+ slot: 'Root',
33
+ overridesResolver: (_, styles) => styles.root
34
+ })(({
35
+ ownerState
36
+ }) => ({
37
+ strokeWidth: 2,
38
+ strokeLinejoin: 'round',
39
+ fill: 'none',
40
+ stroke: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
41
+ transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
42
+ opacity: ownerState.isFaded ? 0.3 : 1
43
+ }));
44
+ LineElementPath.propTypes = {
45
+ // ----------------------------- Warning --------------------------------
46
+ // | These PropTypes are generated from the TypeScript type definitions |
47
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
48
+ // ----------------------------------------------------------------------
49
+ as: PropTypes.elementType,
50
+ ownerState: PropTypes.shape({
51
+ classes: PropTypes.object,
52
+ color: PropTypes.string.isRequired,
53
+ id: PropTypes.string.isRequired,
54
+ isFaded: PropTypes.bool.isRequired,
55
+ isHighlighted: PropTypes.bool.isRequired
56
+ }).isRequired,
57
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
58
+ };
59
+ function LineElement(props) {
60
+ const {
61
+ id,
62
+ classes: innerClasses,
63
+ color,
64
+ highlightScope
65
+ } = props,
66
+ other = _objectWithoutPropertiesLoose(props, _excluded);
67
+ const getInteractionItemProps = useInteractionItemProps(highlightScope);
68
+ const {
69
+ item
70
+ } = React.useContext(InteractionContext);
71
+ const isHighlighted = getIsHighlighted(item, {
72
+ type: 'line',
73
+ seriesId: id
74
+ }, highlightScope);
75
+ const isFaded = !isHighlighted && getIsFaded(item, {
76
+ type: 'line',
77
+ seriesId: id
78
+ }, highlightScope);
79
+ const ownerState = {
80
+ id,
81
+ classes: innerClasses,
82
+ color,
83
+ isFaded,
84
+ isHighlighted
85
+ };
86
+ const classes = useUtilityClasses(ownerState);
87
+ return /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
88
+ ownerState: ownerState,
89
+ className: classes.root
90
+ }, getInteractionItemProps({
91
+ type: 'line',
92
+ seriesId: id
93
+ })));
94
+ }
95
+ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
96
+ // ----------------------------- Warning --------------------------------
97
+ // | These PropTypes are generated from the TypeScript type definitions |
98
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
99
+ // ----------------------------------------------------------------------
100
+ classes: PropTypes.object,
101
+ highlightScope: PropTypes.shape({
102
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
103
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
104
+ })
105
+ } : void 0;
106
+ export { LineElement };
@@ -0,0 +1,58 @@
1
+ import * as React from 'react';
2
+ import { line as d3Line } from 'd3-shape';
3
+ import { SeriesContext } from '../context/SeriesContextProvider';
4
+ import { CartesianContext } from '../context/CartesianContextProvider';
5
+ import { LineElement } from './LineElement';
6
+ import { getValueToPositionMapper } from '../hooks/useScale';
7
+ import getCurveFactory from '../internals/getCurve';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export function LinePlot() {
10
+ const seriesData = React.useContext(SeriesContext).line;
11
+ const axisData = React.useContext(CartesianContext);
12
+ if (seriesData === undefined) {
13
+ return null;
14
+ }
15
+ const {
16
+ series,
17
+ stackingGroups
18
+ } = seriesData;
19
+ const {
20
+ xAxis,
21
+ yAxis,
22
+ xAxisIds,
23
+ yAxisIds
24
+ } = axisData;
25
+ const defaultXAxisId = xAxisIds[0];
26
+ const defaultYAxisId = yAxisIds[0];
27
+ return /*#__PURE__*/_jsx("g", {
28
+ children: stackingGroups.flatMap(({
29
+ ids: groupIds
30
+ }) => {
31
+ return groupIds.flatMap(seriesId => {
32
+ const {
33
+ xAxisKey = defaultXAxisId,
34
+ yAxisKey = defaultYAxisId,
35
+ stackedData
36
+ } = series[seriesId];
37
+ const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
38
+ const yScale = yAxis[yAxisKey].scale;
39
+ const xData = xAxis[xAxisKey].data;
40
+ if (xData === undefined) {
41
+ throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
42
+ }
43
+ const linePath = d3Line().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
44
+ const curve = getCurveFactory(series[seriesId].curve);
45
+ const d3Data = xData == null ? void 0 : xData.map((x, index) => ({
46
+ x,
47
+ y: stackedData[index]
48
+ }));
49
+ return /*#__PURE__*/_jsx(LineElement, {
50
+ id: seriesId,
51
+ d: linePath.curve(curve)(d3Data) || undefined,
52
+ color: series[seriesId].color,
53
+ highlightScope: series[seriesId].highlightScope
54
+ }, seriesId);
55
+ });
56
+ })
57
+ });
58
+ }
@@ -0,0 +1,130 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "highlightScope"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import composeClasses from '@mui/utils/composeClasses';
7
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
8
+ import { styled } from '@mui/material/styles';
9
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
+ import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
11
+ import { getSymbol } from '../internals/utils';
12
+ import { InteractionContext } from '../context/InteractionProvider';
13
+ import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ export function getMarkElementUtilityClass(slot) {
16
+ return generateUtilityClass('MuiMarkElement', slot);
17
+ }
18
+ export const markElementClasses = generateUtilityClasses('MuiMarkElement', ['root', 'highlighted', 'faded']);
19
+ const useUtilityClasses = ownerState => {
20
+ const {
21
+ classes,
22
+ id,
23
+ isFaded,
24
+ isHighlighted
25
+ } = ownerState;
26
+ const slots = {
27
+ root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
28
+ };
29
+ return composeClasses(slots, getMarkElementUtilityClass, classes);
30
+ };
31
+ const MarkElementPath = styled('path', {
32
+ name: 'MuiMarkElement',
33
+ slot: 'Root',
34
+ overridesResolver: (_, styles) => styles.root
35
+ })(({
36
+ ownerState,
37
+ theme
38
+ }) => ({
39
+ transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
40
+ transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
41
+ fill: (theme.vars || theme).palette.background.paper,
42
+ stroke: ownerState.color,
43
+ strokeWidth: 2,
44
+ '&.MuiMarkElement-highlighted': {
45
+ fill: ownerState.color
46
+ }
47
+ }));
48
+ MarkElementPath.propTypes = {
49
+ // ----------------------------- Warning --------------------------------
50
+ // | These PropTypes are generated from the TypeScript type definitions |
51
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
52
+ // ----------------------------------------------------------------------
53
+ as: PropTypes.elementType,
54
+ ownerState: PropTypes.shape({
55
+ classes: PropTypes.object,
56
+ color: PropTypes.string.isRequired,
57
+ id: PropTypes.string.isRequired,
58
+ isFaded: PropTypes.bool.isRequired,
59
+ isHighlighted: PropTypes.bool.isRequired,
60
+ x: PropTypes.number.isRequired,
61
+ y: PropTypes.number.isRequired
62
+ }).isRequired,
63
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
64
+ };
65
+ function MarkElement(props) {
66
+ var _axis$x;
67
+ const {
68
+ x,
69
+ y,
70
+ id,
71
+ classes: innerClasses,
72
+ color,
73
+ shape,
74
+ dataIndex,
75
+ highlightScope
76
+ } = props,
77
+ other = _objectWithoutPropertiesLoose(props, _excluded);
78
+ const getInteractionItemProps = useInteractionItemProps(highlightScope);
79
+ const {
80
+ item,
81
+ axis
82
+ } = React.useContext(InteractionContext);
83
+ const isHighlighted = ((_axis$x = axis.x) == null ? void 0 : _axis$x.index) === dataIndex || getIsHighlighted(item, {
84
+ type: 'line',
85
+ seriesId: id
86
+ }, highlightScope);
87
+ const isFaded = !isHighlighted && getIsFaded(item, {
88
+ type: 'line',
89
+ seriesId: id
90
+ }, highlightScope);
91
+ const ownerState = {
92
+ id,
93
+ classes: innerClasses,
94
+ isHighlighted,
95
+ isFaded,
96
+ color,
97
+ x,
98
+ y
99
+ };
100
+ const classes = useUtilityClasses(ownerState);
101
+ return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, {
102
+ ownerState: ownerState,
103
+ className: classes.root,
104
+ d: d3Symbol(d3SymbolsFill[getSymbol(shape)])()
105
+ }, getInteractionItemProps({
106
+ type: 'line',
107
+ seriesId: id,
108
+ dataIndex
109
+ })));
110
+ }
111
+ process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
112
+ // ----------------------------- Warning --------------------------------
113
+ // | These PropTypes are generated from the TypeScript type definitions |
114
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
115
+ // ----------------------------------------------------------------------
116
+ classes: PropTypes.object,
117
+ /**
118
+ * The index to the element in the series' data array.
119
+ */
120
+ dataIndex: PropTypes.number.isRequired,
121
+ highlightScope: PropTypes.shape({
122
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
123
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
124
+ }),
125
+ /**
126
+ * The shape of the marker.
127
+ */
128
+ shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired
129
+ } : void 0;
130
+ export { MarkElement };
@@ -0,0 +1,78 @@
1
+ import * as React from 'react';
2
+ import { SeriesContext } from '../context/SeriesContextProvider';
3
+ import { CartesianContext } from '../context/CartesianContextProvider';
4
+ import { MarkElement } from './MarkElement';
5
+ import { getValueToPositionMapper } from '../hooks/useScale';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function MarkPlot() {
8
+ const seriesData = React.useContext(SeriesContext).line;
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("g", {
26
+ children: stackingGroups.flatMap(({
27
+ ids: groupIds
28
+ }) => {
29
+ return groupIds.flatMap(seriesId => {
30
+ const {
31
+ xAxisKey = defaultXAxisId,
32
+ yAxisKey = defaultYAxisId,
33
+ stackedData
34
+ } = series[seriesId];
35
+ const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
36
+ const yScale = yAxis[yAxisKey].scale;
37
+ const xData = xAxis[xAxisKey].data;
38
+ const xRange = xAxis[xAxisKey].scale.range();
39
+ const yRange = yScale.range();
40
+ const isInRange = ({
41
+ x,
42
+ y
43
+ }) => {
44
+ if (x < Math.min(...xRange) || x > Math.max(...xRange)) {
45
+ return false;
46
+ }
47
+ if (y < Math.min(...yRange) || y > Math.max(...yRange)) {
48
+ return false;
49
+ }
50
+ return true;
51
+ };
52
+ if (xData === undefined) {
53
+ throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
54
+ }
55
+ return xData == null ? void 0 : xData.map((x, index) => {
56
+ const y = stackedData[index][1];
57
+ return {
58
+ x: xScale(x),
59
+ y: yScale(y),
60
+ index
61
+ };
62
+ }).filter(isInRange).map(({
63
+ x,
64
+ y,
65
+ index
66
+ }) => /*#__PURE__*/_jsx(MarkElement, {
67
+ id: seriesId,
68
+ dataIndex: index,
69
+ shape: "circle",
70
+ color: series[seriesId].color,
71
+ x: x,
72
+ y: y,
73
+ highlightScope: series[seriesId].highlightScope
74
+ }, `${seriesId}-${index}`));
75
+ });
76
+ })
77
+ });
78
+ }
@@ -0,0 +1,29 @@
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 isArea = series[seriesId].area !== undefined;
18
+ const getValues = isArea ? d => d : d => [d[1], d[1]]; // Id area should go from bottom to top, without area should only consider the top
19
+
20
+ const [seriesMin, seriesMax] = series[seriesId].stackedData.reduce((seriesAcc, stackedValue) => {
21
+ const [min, max] = getValues(stackedValue);
22
+ return [Math.min(min, seriesAcc[0]), Math.max(max, seriesAcc[1])];
23
+ }, getValues(series[seriesId].stackedData[0]));
24
+ if (acc[0] === null || acc[1] === null) {
25
+ return [seriesMin, seriesMax];
26
+ }
27
+ return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
28
+ }, [null, null]);
29
+ };