@mui/x-charts 7.0.0-beta.2 → 7.0.0-beta.4

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 (265) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +27 -7
  3. package/CHANGELOG.md +298 -23
  4. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  5. package/ChartsGrid/ChartsGrid.js +128 -0
  6. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  7. package/ChartsGrid/chartsGridClasses.js +14 -0
  8. package/ChartsGrid/index.d.ts +2 -0
  9. package/ChartsGrid/index.js +27 -0
  10. package/ChartsGrid/package.json +6 -0
  11. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  12. package/ChartsSurface.js +6 -4
  13. package/ChartsTooltip/utils.js +1 -1
  14. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
  15. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
  16. package/ChartsXAxis/ChartsXAxis.js +3 -3
  17. package/ChartsYAxis/ChartsYAxis.js +3 -3
  18. package/Gauge/Gauge.d.ts +13 -0
  19. package/Gauge/Gauge.js +154 -0
  20. package/Gauge/GaugeContainer.d.ts +17 -0
  21. package/Gauge/GaugeContainer.js +214 -0
  22. package/Gauge/GaugeProvider.d.ts +117 -0
  23. package/Gauge/GaugeProvider.js +99 -0
  24. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  25. package/Gauge/GaugeReferenceArc.js +44 -0
  26. package/Gauge/GaugeValueArc.d.ts +2 -0
  27. package/Gauge/GaugeValueArc.js +51 -0
  28. package/Gauge/GaugeValueText.d.ts +15 -0
  29. package/Gauge/GaugeValueText.js +77 -0
  30. package/Gauge/gaugeClasses.d.ts +14 -0
  31. package/Gauge/gaugeClasses.js +15 -0
  32. package/Gauge/index.d.ts +7 -0
  33. package/Gauge/index.js +87 -0
  34. package/Gauge/package.json +6 -0
  35. package/Gauge/utils.d.ts +19 -0
  36. package/Gauge/utils.js +75 -0
  37. package/LineChart/LineChart.d.ts +24 -5
  38. package/LineChart/LineChart.js +31 -7
  39. package/PieChart/PieArc.d.ts +4 -4
  40. package/PieChart/PieArc.js +9 -9
  41. package/PieChart/PieArcLabelPlot.js +13 -13
  42. package/PieChart/PieChart.d.ts +22 -0
  43. package/PieChart/PieChart.js +22 -2
  44. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
  45. package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  46. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  47. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  48. package/ScatterChart/ScatterChart.d.ts +18 -0
  49. package/ScatterChart/ScatterChart.js +25 -3
  50. package/SparkLineChart/SparkLineChart.js +0 -2
  51. package/context/CartesianContextProvider.d.ts +0 -8
  52. package/context/CartesianContextProvider.js +4 -89
  53. package/context/DrawingProvider.d.ts +2 -11
  54. package/context/DrawingProvider.js +10 -35
  55. package/context/HighlightProvider.js +3 -0
  56. package/context/InteractionProvider.js +3 -0
  57. package/context/SeriesContextProvider.js +3 -0
  58. package/context/index.d.ts +0 -2
  59. package/context/index.js +1 -15
  60. package/esm/BarChart/BarChart.js +27 -7
  61. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  62. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  63. package/esm/ChartsGrid/index.js +2 -0
  64. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  65. package/esm/ChartsSurface.js +6 -4
  66. package/esm/ChartsTooltip/utils.js +2 -2
  67. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  68. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  69. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  70. package/esm/Gauge/Gauge.js +147 -0
  71. package/esm/Gauge/GaugeContainer.js +209 -0
  72. package/esm/Gauge/GaugeProvider.js +88 -0
  73. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  74. package/esm/Gauge/GaugeValueArc.js +42 -0
  75. package/esm/Gauge/GaugeValueText.js +69 -0
  76. package/esm/Gauge/gaugeClasses.js +7 -0
  77. package/esm/Gauge/index.js +7 -0
  78. package/esm/Gauge/utils.js +68 -0
  79. package/esm/LineChart/LineChart.js +31 -7
  80. package/esm/PieChart/PieArc.js +9 -9
  81. package/esm/PieChart/PieArcLabelPlot.js +13 -13
  82. package/esm/PieChart/PieChart.js +22 -2
  83. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  84. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  85. package/esm/ScatterChart/ScatterChart.js +25 -3
  86. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  87. package/esm/context/CartesianContextProvider.js +3 -88
  88. package/esm/context/DrawingProvider.js +10 -36
  89. package/esm/context/HighlightProvider.js +3 -0
  90. package/esm/context/InteractionProvider.js +3 -0
  91. package/esm/context/SeriesContextProvider.js +3 -0
  92. package/esm/context/index.js +1 -2
  93. package/esm/hooks/useAxisEvents.js +2 -2
  94. package/esm/hooks/useTicks.js +2 -3
  95. package/esm/index.js +2 -0
  96. package/hooks/useAxisEvents.js +1 -1
  97. package/hooks/useTicks.d.ts +2 -3
  98. package/hooks/useTicks.js +2 -3
  99. package/index.d.ts +2 -0
  100. package/index.js +23 -1
  101. package/modern/BarChart/BarChart.js +27 -7
  102. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  103. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  104. package/modern/ChartsGrid/index.js +2 -0
  105. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  106. package/modern/ChartsSurface.js +6 -4
  107. package/modern/ChartsTooltip/utils.js +2 -2
  108. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  109. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  110. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  111. package/modern/Gauge/Gauge.js +147 -0
  112. package/modern/Gauge/GaugeContainer.js +206 -0
  113. package/modern/Gauge/GaugeProvider.js +88 -0
  114. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  115. package/modern/Gauge/GaugeValueArc.js +42 -0
  116. package/modern/Gauge/GaugeValueText.js +69 -0
  117. package/modern/Gauge/gaugeClasses.js +7 -0
  118. package/modern/Gauge/index.js +7 -0
  119. package/modern/Gauge/utils.js +68 -0
  120. package/modern/LineChart/LineChart.js +31 -7
  121. package/modern/PieChart/PieArc.js +9 -9
  122. package/modern/PieChart/PieArcLabelPlot.js +13 -13
  123. package/modern/PieChart/PieChart.js +22 -2
  124. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  125. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  126. package/modern/ScatterChart/ScatterChart.js +25 -3
  127. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  128. package/modern/context/CartesianContextProvider.js +3 -88
  129. package/modern/context/DrawingProvider.js +10 -36
  130. package/modern/context/HighlightProvider.js +3 -0
  131. package/modern/context/InteractionProvider.js +3 -0
  132. package/modern/context/SeriesContextProvider.js +3 -0
  133. package/modern/context/index.js +1 -2
  134. package/modern/hooks/useAxisEvents.js +2 -2
  135. package/modern/hooks/useTicks.js +2 -3
  136. package/modern/index.js +3 -1
  137. package/package.json +4 -4
  138. package/legacy/BarChart/BarChart.js +0 -418
  139. package/legacy/BarChart/BarElement.js +0 -119
  140. package/legacy/BarChart/BarPlot.js +0 -232
  141. package/legacy/BarChart/extremums.js +0 -45
  142. package/legacy/BarChart/formatter.js +0 -78
  143. package/legacy/BarChart/index.js +0 -3
  144. package/legacy/BarChart/legend.js +0 -15
  145. package/legacy/ChartContainer/ChartContainer.js +0 -189
  146. package/legacy/ChartContainer/index.js +0 -1
  147. package/legacy/ChartsAxis/ChartsAxis.js +0 -215
  148. package/legacy/ChartsAxis/axisClasses.js +0 -5
  149. package/legacy/ChartsAxis/index.js +0 -2
  150. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
  151. package/legacy/ChartsAxisHighlight/index.js +0 -1
  152. package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
  153. package/legacy/ChartsClipPath/index.js +0 -1
  154. package/legacy/ChartsLegend/ChartsLegend.js +0 -100
  155. package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
  156. package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
  157. package/legacy/ChartsLegend/index.js +0 -4
  158. package/legacy/ChartsLegend/utils.js +0 -15
  159. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
  160. package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
  161. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
  162. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
  163. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
  164. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
  165. package/legacy/ChartsReferenceLine/common.js +0 -19
  166. package/legacy/ChartsReferenceLine/index.js +0 -2
  167. package/legacy/ChartsSurface.js +0 -76
  168. package/legacy/ChartsText/ChartsText.js +0 -95
  169. package/legacy/ChartsText/index.js +0 -1
  170. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
  171. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
  172. package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
  173. package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
  174. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
  175. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
  176. package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
  177. package/legacy/ChartsTooltip/index.js +0 -6
  178. package/legacy/ChartsTooltip/utils.js +0 -103
  179. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
  180. package/legacy/ChartsVoronoiHandler/index.js +0 -1
  181. package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
  182. package/legacy/ChartsXAxis/index.js +0 -1
  183. package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
  184. package/legacy/ChartsYAxis/index.js +0 -1
  185. package/legacy/LineChart/AnimatedArea.js +0 -102
  186. package/legacy/LineChart/AnimatedLine.js +0 -104
  187. package/legacy/LineChart/AreaElement.js +0 -112
  188. package/legacy/LineChart/AreaPlot.js +0 -149
  189. package/legacy/LineChart/LineChart.js +0 -426
  190. package/legacy/LineChart/LineElement.js +0 -112
  191. package/legacy/LineChart/LineHighlightElement.js +0 -79
  192. package/legacy/LineChart/LineHighlightPlot.js +0 -97
  193. package/legacy/LineChart/LinePlot.js +0 -144
  194. package/legacy/LineChart/MarkElement.js +0 -153
  195. package/legacy/LineChart/MarkPlot.js +0 -178
  196. package/legacy/LineChart/extremums.js +0 -54
  197. package/legacy/LineChart/formatter.js +0 -82
  198. package/legacy/LineChart/index.js +0 -11
  199. package/legacy/LineChart/legend.js +0 -15
  200. package/legacy/PieChart/PieArc.js +0 -103
  201. package/legacy/PieChart/PieArcLabel.js +0 -112
  202. package/legacy/PieChart/PieArcLabelPlot.js +0 -193
  203. package/legacy/PieChart/PieArcPlot.js +0 -180
  204. package/legacy/PieChart/PieChart.js +0 -382
  205. package/legacy/PieChart/PiePlot.js +0 -137
  206. package/legacy/PieChart/dataTransform/transition.js +0 -149
  207. package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
  208. package/legacy/PieChart/formatter.js +0 -55
  209. package/legacy/PieChart/index.js +0 -6
  210. package/legacy/PieChart/legend.js +0 -16
  211. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -255
  212. package/legacy/ResponsiveChartContainer/index.js +0 -1
  213. package/legacy/ScatterChart/Scatter.js +0 -110
  214. package/legacy/ScatterChart/ScatterChart.js +0 -370
  215. package/legacy/ScatterChart/ScatterPlot.js +0 -80
  216. package/legacy/ScatterChart/extremums.js +0 -39
  217. package/legacy/ScatterChart/formatter.js +0 -12
  218. package/legacy/ScatterChart/index.js +0 -3
  219. package/legacy/ScatterChart/legend.js +0 -15
  220. package/legacy/SparkLineChart/SparkLineChart.js +0 -266
  221. package/legacy/SparkLineChart/index.js +0 -1
  222. package/legacy/colorPalettes/colorPalettes.js +0 -15
  223. package/legacy/colorPalettes/index.js +0 -1
  224. package/legacy/constants.js +0 -8
  225. package/legacy/context/CartesianContextProvider.js +0 -327
  226. package/legacy/context/DrawingProvider.js +0 -74
  227. package/legacy/context/HighlightProvider.js +0 -56
  228. package/legacy/context/InteractionProvider.js +0 -81
  229. package/legacy/context/SeriesContextProvider.js +0 -74
  230. package/legacy/context/index.js +0 -2
  231. package/legacy/hooks/index.js +0 -2
  232. package/legacy/hooks/useAxisEvents.js +0 -120
  233. package/legacy/hooks/useChartDimensions.js +0 -18
  234. package/legacy/hooks/useDrawingArea.js +0 -21
  235. package/legacy/hooks/useInteractionItemProps.js +0 -71
  236. package/legacy/hooks/useMounted.js +0 -21
  237. package/legacy/hooks/useReducedMotion.js +0 -27
  238. package/legacy/hooks/useScale.js +0 -33
  239. package/legacy/hooks/useTicks.js +0 -66
  240. package/legacy/index.js +0 -31
  241. package/legacy/internals/components/AxisSharedComponents.js +0 -25
  242. package/legacy/internals/defaultizeColor.js +0 -17
  243. package/legacy/internals/defaultizeValueFormatter.js +0 -12
  244. package/legacy/internals/domUtils.js +0 -121
  245. package/legacy/internals/geometry.js +0 -37
  246. package/legacy/internals/getCurve.js +0 -39
  247. package/legacy/internals/getScale.js +0 -17
  248. package/legacy/internals/getWordsByLines.js +0 -15
  249. package/legacy/internals/isBandScale.js +0 -3
  250. package/legacy/internals/stackSeries.js +0 -92
  251. package/legacy/internals/useAnimatedPath.js +0 -32
  252. package/legacy/internals/utils.js +0 -52
  253. package/legacy/models/axis.js +0 -6
  254. package/legacy/models/helpers.js +0 -1
  255. package/legacy/models/index.js +0 -4
  256. package/legacy/models/layout.js +0 -1
  257. package/legacy/models/seriesType/bar.js +0 -1
  258. package/legacy/models/seriesType/common.js +0 -1
  259. package/legacy/models/seriesType/config.js +0 -1
  260. package/legacy/models/seriesType/index.js +0 -5
  261. package/legacy/models/seriesType/line.js +0 -1
  262. package/legacy/models/seriesType/pie.js +0 -1
  263. package/legacy/models/seriesType/scatter.js +0 -1
  264. package/legacy/models/stacking.js +0 -1
  265. package/legacy/themeAugmentation/index.js +0 -3
@@ -1,118 +0,0 @@
1
- import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
- import clsx from 'clsx';
4
- import Typography from '@mui/material/Typography';
5
- import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
6
- import { isCartesianSeries, utcFormatter } from './utils';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- function DefaultChartsAxisTooltipContent(props) {
10
- var _axis$valueFormatter;
11
- var series = props.series,
12
- axis = props.axis,
13
- dataIndex = props.dataIndex,
14
- axisValue = props.axisValue,
15
- sx = props.sx,
16
- classes = props.classes;
17
- if (dataIndex == null) {
18
- return null;
19
- }
20
- var axisFormatter = (_axis$valueFormatter = axis.valueFormatter) != null ? _axis$valueFormatter : function (v) {
21
- return axis.scaleType === 'utc' ? utcFormatter(v) : v.toLocaleString();
22
- };
23
- return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
24
- sx: sx,
25
- className: classes.root,
26
- children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
27
- className: classes.table,
28
- children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
29
- children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
30
- children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
31
- colSpan: 3,
32
- children: /*#__PURE__*/_jsx(Typography, {
33
- children: axisFormatter(axisValue)
34
- })
35
- })
36
- })
37
- }), /*#__PURE__*/_jsx("tbody", {
38
- children: series.filter(isCartesianSeries).map(function (_ref) {
39
- var _data$dataIndex;
40
- var color = _ref.color,
41
- id = _ref.id,
42
- label = _ref.label,
43
- valueFormatter = _ref.valueFormatter,
44
- data = _ref.data;
45
- // @ts-ignore
46
- var formattedValue = valueFormatter((_data$dataIndex = data[dataIndex]) != null ? _data$dataIndex : null);
47
- if (formattedValue == null) {
48
- return null;
49
- }
50
- return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
51
- className: classes.row,
52
- children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
53
- className: clsx(classes.markCell, classes.cell),
54
- children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
55
- ownerState: {
56
- color: color
57
- },
58
- boxShadow: 1,
59
- className: classes.mark
60
- })
61
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
62
- className: clsx(classes.labelCell, classes.cell),
63
- children: label ? /*#__PURE__*/_jsx(Typography, {
64
- children: label
65
- }) : null
66
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
67
- className: clsx(classes.valueCell, classes.cell),
68
- children: /*#__PURE__*/_jsx(Typography, {
69
- children: formattedValue
70
- })
71
- })]
72
- }, id);
73
- })
74
- })]
75
- })
76
- });
77
- }
78
- process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propTypes = {
79
- // ----------------------------- Warning --------------------------------
80
- // | These PropTypes are generated from the TypeScript type definitions |
81
- // | To update them edit the TypeScript types and run "yarn proptypes" |
82
- // ----------------------------------------------------------------------
83
- /**
84
- * The properties of the triggered axis.
85
- */
86
- axis: PropTypes.object.isRequired,
87
- /**
88
- * Data identifying the triggered axis.
89
- */
90
- axisData: PropTypes.shape({
91
- x: PropTypes.shape({
92
- index: PropTypes.number,
93
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
94
- }),
95
- y: PropTypes.shape({
96
- index: PropTypes.number,
97
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
98
- })
99
- }).isRequired,
100
- /**
101
- * The value associated to the current mouse position.
102
- */
103
- axisValue: PropTypes.any.isRequired,
104
- /**
105
- * Override or extend the styles applied to the component.
106
- */
107
- classes: PropTypes.object.isRequired,
108
- /**
109
- * The index of the data item triggered.
110
- */
111
- dataIndex: PropTypes.number,
112
- /**
113
- * The series linked to the triggered axis.
114
- */
115
- series: PropTypes.arrayOf(PropTypes.object).isRequired,
116
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
117
- } : void 0;
118
- export { DefaultChartsAxisTooltipContent };
@@ -1,78 +0,0 @@
1
- import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
- import clsx from 'clsx';
4
- import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
- function DefaultChartsItemTooltipContent(props) {
8
- var _series$valueFormatte;
9
- var series = props.series,
10
- itemData = props.itemData,
11
- sx = props.sx,
12
- classes = props.classes;
13
- if (itemData.dataIndex === undefined) {
14
- return null;
15
- }
16
- var _ref = series.type === 'pie' ? {
17
- color: series.data[itemData.dataIndex].color,
18
- displayedLabel: series.data[itemData.dataIndex].label
19
- } : {
20
- color: series.color,
21
- displayedLabel: series.label
22
- },
23
- displayedLabel = _ref.displayedLabel,
24
- color = _ref.color;
25
- var value = series.data[itemData.dataIndex];
26
- var formattedValue = (_series$valueFormatte = series.valueFormatter) == null ? void 0 : _series$valueFormatte.call(series, value);
27
- return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
28
- sx: sx,
29
- className: classes.root,
30
- children: /*#__PURE__*/_jsx(ChartsTooltipTable, {
31
- className: classes.table,
32
- children: /*#__PURE__*/_jsx("tbody", {
33
- children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
34
- className: classes.row,
35
- children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
36
- className: clsx(classes.markCell, classes.cell),
37
- children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
38
- ownerState: {
39
- color: color
40
- },
41
- className: classes.mark
42
- })
43
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
44
- className: clsx(classes.labelCell, classes.cell),
45
- children: displayedLabel
46
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
47
- className: clsx(classes.valueCell, classes.cell),
48
- children: formattedValue
49
- })]
50
- })
51
- })
52
- })
53
- });
54
- }
55
- process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propTypes = {
56
- // ----------------------------- Warning --------------------------------
57
- // | These PropTypes are generated from the TypeScript type definitions |
58
- // | To update them edit the TypeScript types and run "yarn proptypes" |
59
- // ----------------------------------------------------------------------
60
- /**
61
- * Override or extend the styles applied to the component.
62
- */
63
- classes: PropTypes.object.isRequired,
64
- /**
65
- * The data used to identify the triggered item.
66
- */
67
- itemData: PropTypes.shape({
68
- dataIndex: PropTypes.number,
69
- seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
70
- type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
71
- }).isRequired,
72
- /**
73
- * The series linked to the triggered axis.
74
- */
75
- series: PropTypes.object.isRequired,
76
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
77
- } : void 0;
78
- export { DefaultChartsItemTooltipContent };
@@ -1,5 +0,0 @@
1
- import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
- export function getChartsTooltipUtilityClass(slot) {
3
- return generateUtilityClass('MuiChartsTooltip', slot);
4
- }
5
- export var chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
@@ -1,6 +0,0 @@
1
- export * from './ChartsTooltip';
2
- export * from './chartsTooltipClasses';
3
- export * from './ChartsAxisTooltipContent';
4
- export * from './ChartsItemTooltipContent';
5
- export * from './DefaultChartsAxisTooltipContent';
6
- export * from './DefaultChartsItemTooltipContent';
@@ -1,103 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import * as React from 'react';
3
- import { SVGContext } from '../context/DrawingProvider';
4
- export function generateVirtualElement(mousePosition) {
5
- if (mousePosition === null) {
6
- return {
7
- getBoundingClientRect: function getBoundingClientRect() {
8
- return {
9
- width: 0,
10
- height: 0,
11
- x: 0,
12
- y: 0,
13
- top: 0,
14
- right: 0,
15
- bottom: 0,
16
- left: 0,
17
- toJSON: function toJSON() {
18
- return '';
19
- }
20
- };
21
- }
22
- };
23
- }
24
- var x = mousePosition.x,
25
- y = mousePosition.y;
26
- return {
27
- getBoundingClientRect: function getBoundingClientRect() {
28
- return {
29
- width: 0,
30
- height: 0,
31
- x: x,
32
- y: y,
33
- top: y,
34
- right: x,
35
- bottom: y,
36
- left: x,
37
- toJSON: function toJSON() {
38
- return JSON.stringify({
39
- width: 0,
40
- height: 0,
41
- x: x,
42
- y: y,
43
- top: y,
44
- right: x,
45
- bottom: y,
46
- left: x
47
- });
48
- }
49
- };
50
- }
51
- };
52
- }
53
- export function useMouseTracker() {
54
- var svgRef = React.useContext(SVGContext);
55
-
56
- // Use a ref to avoid rerendering on every mousemove event.
57
- var _React$useState = React.useState(null),
58
- _React$useState2 = _slicedToArray(_React$useState, 2),
59
- mousePosition = _React$useState2[0],
60
- setMousePosition = _React$useState2[1];
61
- React.useEffect(function () {
62
- var element = svgRef.current;
63
- if (element === null) {
64
- return function () {};
65
- }
66
- var handleMouseOut = function handleMouseOut() {
67
- setMousePosition(null);
68
- };
69
- var handleMouseMove = function handleMouseMove(event) {
70
- setMousePosition({
71
- x: event.clientX,
72
- y: event.clientY
73
- });
74
- };
75
- element.addEventListener('mouseout', handleMouseOut);
76
- element.addEventListener('mousemove', handleMouseMove);
77
- return function () {
78
- element.removeEventListener('mouseout', handleMouseOut);
79
- element.removeEventListener('mousemove', handleMouseMove);
80
- };
81
- }, [svgRef]);
82
- return mousePosition;
83
- }
84
- export function getTooltipHasData(trigger, displayedData) {
85
- if (trigger === 'item') {
86
- return displayedData !== null;
87
- }
88
- var hasAxisXData = displayedData.x !== null;
89
- var hasAxisYData = displayedData.y !== null;
90
- return hasAxisXData || hasAxisYData;
91
- }
92
- export function isCartesianSeriesType(seriesType) {
93
- return ['bar', 'line', 'scatter'].includes(seriesType);
94
- }
95
- export function isCartesianSeries(series) {
96
- return isCartesianSeriesType(series.type);
97
- }
98
- export function utcFormatter(v) {
99
- if (v instanceof Date) {
100
- return v.toUTCString();
101
- }
102
- return v.toLocaleString();
103
- }
@@ -1,206 +0,0 @@
1
- import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Delaunay } from 'd3-delaunay';
4
- import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
- import { InteractionContext } from '../context/InteractionProvider';
6
- import { CartesianContext } from '../context/CartesianContextProvider';
7
- import { SVGContext, DrawingContext } from '../context/DrawingProvider';
8
- import { SeriesContext } from '../context/SeriesContextProvider';
9
- import { getValueToPositionMapper } from '../hooks/useScale';
10
- import { getSVGPoint } from '../internals/utils';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- function ChartsVoronoiHandler(props) {
13
- var _React$useContext$sca;
14
- var voronoiMaxRadius = props.voronoiMaxRadius,
15
- onItemClick = props.onItemClick;
16
- var svgRef = React.useContext(SVGContext);
17
- var _React$useContext = React.useContext(DrawingContext),
18
- width = _React$useContext.width,
19
- height = _React$useContext.height,
20
- top = _React$useContext.top,
21
- left = _React$useContext.left;
22
- var _React$useContext2 = React.useContext(CartesianContext),
23
- xAxis = _React$useContext2.xAxis,
24
- yAxis = _React$useContext2.yAxis,
25
- xAxisIds = _React$useContext2.xAxisIds,
26
- yAxisIds = _React$useContext2.yAxisIds;
27
- var _React$useContext3 = React.useContext(InteractionContext),
28
- dispatch = _React$useContext3.dispatch;
29
- var _ref = (_React$useContext$sca = React.useContext(SeriesContext).scatter) != null ? _React$useContext$sca : {},
30
- series = _ref.series,
31
- seriesOrder = _ref.seriesOrder;
32
- var voronoiRef = React.useRef({});
33
- var defaultXAxisId = xAxisIds[0];
34
- var defaultYAxisId = yAxisIds[0];
35
- useEnhancedEffect(function () {
36
- dispatch({
37
- type: 'updateVoronoiUsage',
38
- useVoronoiInteraction: true
39
- });
40
- return function () {
41
- dispatch({
42
- type: 'updateVoronoiUsage',
43
- useVoronoiInteraction: false
44
- });
45
- };
46
- }, [dispatch]);
47
- useEnhancedEffect(function () {
48
- // This effect generate and store the Delaunay object that's used to map coordinate to closest point.
49
-
50
- if (seriesOrder === undefined || series === undefined) {
51
- // If there is no scatter chart series
52
- return;
53
- }
54
- voronoiRef.current = {};
55
- var points = [];
56
- seriesOrder.forEach(function (seriesId) {
57
- var _series$seriesId = series[seriesId],
58
- data = _series$seriesId.data,
59
- xAxisKey = _series$seriesId.xAxisKey,
60
- yAxisKey = _series$seriesId.yAxisKey;
61
- var xScale = xAxis[xAxisKey != null ? xAxisKey : defaultXAxisId].scale;
62
- var yScale = yAxis[yAxisKey != null ? yAxisKey : defaultYAxisId].scale;
63
- var getXPosition = getValueToPositionMapper(xScale);
64
- var getYPosition = getValueToPositionMapper(yScale);
65
- var seriesPoints = data.flatMap(function (_ref2) {
66
- var x = _ref2.x,
67
- y = _ref2.y;
68
- return [getXPosition(x), getYPosition(y)];
69
- });
70
- voronoiRef.current[seriesId] = {
71
- startIndex: points.length,
72
- endIndex: points.length + seriesPoints.length
73
- };
74
- points = points.concat(seriesPoints);
75
- });
76
- voronoiRef.current.delauney = new Delaunay(points);
77
- }, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
78
- React.useEffect(function () {
79
- var element = svgRef.current;
80
- if (element === null) {
81
- return undefined;
82
- }
83
-
84
- // TODO: A perf optimisation of voronoi could be to use the last point as the intial point for the next search.
85
- function getClosestPoint(event) {
86
- var _voronoiRef$current$d;
87
- // Get mouse coordinate in global SVG space
88
- var svgPoint = getSVGPoint(svgRef.current, event);
89
- var outsideX = svgPoint.x < left || svgPoint.x > left + width;
90
- var outsideY = svgPoint.y < top || svgPoint.y > top + height;
91
- if (outsideX || outsideY) {
92
- return 'outside-chart';
93
- }
94
- if (!voronoiRef.current.delauney) {
95
- return 'no-point-found';
96
- }
97
- var closestPointIndex = (_voronoiRef$current$d = voronoiRef.current.delauney) == null ? void 0 : _voronoiRef$current$d.find(svgPoint.x, svgPoint.y);
98
- if (closestPointIndex === undefined) {
99
- return 'no-point-found';
100
- }
101
- var seriesId = Object.keys(voronoiRef.current).find(function (id) {
102
- if (id === 'delauney') {
103
- return false;
104
- }
105
- return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
106
- });
107
- if (seriesId === undefined) {
108
- return 'no-point-found';
109
- }
110
- var dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
111
- if (voronoiMaxRadius !== undefined) {
112
- var pointX = voronoiRef.current.delauney.points[2 * closestPointIndex];
113
- var pointY = voronoiRef.current.delauney.points[2 * closestPointIndex + 1];
114
- var dist2 = Math.pow(pointX - svgPoint.x, 2) + Math.pow(pointY - svgPoint.y, 2);
115
- if (dist2 > Math.pow(voronoiMaxRadius, 2)) {
116
- // The closest point is too far to be considered.
117
- return 'outside-voronoi-max-radius';
118
- }
119
- }
120
- return {
121
- seriesId: seriesId,
122
- dataIndex: dataIndex
123
- };
124
- }
125
- var handleMouseOut = function handleMouseOut() {
126
- dispatch({
127
- type: 'exitChart'
128
- });
129
- };
130
- var handleMouseMove = function handleMouseMove(event) {
131
- var closestPoint = getClosestPoint(event);
132
- if (closestPoint === 'outside-chart') {
133
- dispatch({
134
- type: 'exitChart'
135
- });
136
- return;
137
- }
138
- if (closestPoint === 'outside-voronoi-max-radius' || closestPoint === 'no-point-found') {
139
- dispatch({
140
- type: 'leaveItem',
141
- data: {
142
- type: 'scatter'
143
- }
144
- });
145
- return;
146
- }
147
- var seriesId = closestPoint.seriesId,
148
- dataIndex = closestPoint.dataIndex;
149
- dispatch({
150
- type: 'enterItem',
151
- data: {
152
- type: 'scatter',
153
- seriesId: seriesId,
154
- dataIndex: dataIndex
155
- }
156
- });
157
- };
158
- var handleMouseClick = function handleMouseClick(event) {
159
- if (!onItemClick) {
160
- return;
161
- }
162
- var closestPoint = getClosestPoint(event);
163
- if (typeof closestPoint === 'string') {
164
- // No point fond for any reason
165
- return;
166
- }
167
- var seriesId = closestPoint.seriesId,
168
- dataIndex = closestPoint.dataIndex;
169
- onItemClick(event, {
170
- type: 'scatter',
171
- seriesId: seriesId,
172
- dataIndex: dataIndex
173
- });
174
- };
175
- element.addEventListener('mouseout', handleMouseOut);
176
- element.addEventListener('mousemove', handleMouseMove);
177
- element.addEventListener('click', handleMouseClick);
178
- return function () {
179
- element.removeEventListener('mouseout', handleMouseOut);
180
- element.removeEventListener('mousemove', handleMouseMove);
181
- element.removeEventListener('click', handleMouseClick);
182
- };
183
- }, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick]);
184
-
185
- // eslint-disable-next-line react/jsx-no-useless-fragment
186
- return /*#__PURE__*/_jsx(React.Fragment, {});
187
- }
188
- process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
189
- // ----------------------------- Warning --------------------------------
190
- // | These PropTypes are generated from the TypeScript type definitions |
191
- // | To update them edit the TypeScript types and run "yarn proptypes" |
192
- // ----------------------------------------------------------------------
193
- /**
194
- * Callback fired when clicking on a scatter item.
195
- * @param {MouseEvent} event Mouse event catched at the svg level
196
- * @param {ScatterItemIdentifier} scatterItemIdentifier Identify whihc item got clicked
197
- */
198
- onItemClick: PropTypes.func,
199
- /**
200
- * Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
201
- * If `undefined`, the radius is assumed to be infinite.
202
- * @default undefined
203
- */
204
- voronoiMaxRadius: PropTypes.number
205
- } : void 0;
206
- export { ChartsVoronoiHandler };
@@ -1 +0,0 @@
1
- export * from './ChartsVoronoiHandler';