@mui/x-charts 7.0.0-beta.3 → 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 (218) hide show
  1. package/BarChart/BarChart.js +0 -2
  2. package/CHANGELOG.md +226 -15
  3. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  4. package/ChartsTooltip/utils.js +1 -1
  5. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
  6. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
  7. package/ChartsXAxis/ChartsXAxis.js +1 -1
  8. package/ChartsYAxis/ChartsYAxis.js +1 -1
  9. package/Gauge/Gauge.js +0 -2
  10. package/Gauge/GaugeContainer.d.ts +0 -2
  11. package/Gauge/GaugeContainer.js +0 -2
  12. package/Gauge/GaugeProvider.js +3 -0
  13. package/Gauge/GaugeValueText.js +1 -1
  14. package/LineChart/LineChart.js +0 -2
  15. package/PieChart/PieChart.js +0 -2
  16. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
  17. package/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  18. package/ScatterChart/ScatterChart.js +0 -3
  19. package/SparkLineChart/SparkLineChart.js +0 -2
  20. package/context/CartesianContextProvider.d.ts +0 -8
  21. package/context/CartesianContextProvider.js +4 -89
  22. package/context/DrawingProvider.d.ts +2 -11
  23. package/context/DrawingProvider.js +10 -35
  24. package/context/HighlightProvider.js +3 -0
  25. package/context/InteractionProvider.js +3 -0
  26. package/context/SeriesContextProvider.js +3 -0
  27. package/context/index.d.ts +0 -2
  28. package/context/index.js +1 -15
  29. package/esm/BarChart/BarChart.js +0 -2
  30. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  31. package/esm/ChartsTooltip/utils.js +2 -2
  32. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  33. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  34. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  35. package/esm/Gauge/Gauge.js +0 -2
  36. package/esm/Gauge/GaugeContainer.js +0 -2
  37. package/esm/Gauge/GaugeProvider.js +3 -0
  38. package/esm/Gauge/GaugeValueText.js +1 -1
  39. package/esm/LineChart/LineChart.js +0 -2
  40. package/esm/PieChart/PieChart.js +0 -2
  41. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  42. package/esm/ScatterChart/ScatterChart.js +0 -3
  43. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  44. package/esm/context/CartesianContextProvider.js +3 -88
  45. package/esm/context/DrawingProvider.js +10 -36
  46. package/esm/context/HighlightProvider.js +3 -0
  47. package/esm/context/InteractionProvider.js +3 -0
  48. package/esm/context/SeriesContextProvider.js +3 -0
  49. package/esm/context/index.js +1 -2
  50. package/esm/hooks/useAxisEvents.js +2 -2
  51. package/hooks/useAxisEvents.js +1 -1
  52. package/hooks/useTicks.d.ts +1 -1
  53. package/index.js +1 -1
  54. package/modern/BarChart/BarChart.js +0 -2
  55. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  56. package/modern/ChartsTooltip/utils.js +2 -2
  57. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  58. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  59. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  60. package/modern/Gauge/Gauge.js +0 -2
  61. package/modern/Gauge/GaugeContainer.js +0 -2
  62. package/modern/Gauge/GaugeProvider.js +3 -0
  63. package/modern/Gauge/GaugeValueText.js +1 -1
  64. package/modern/LineChart/LineChart.js +0 -2
  65. package/modern/PieChart/PieChart.js +0 -2
  66. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  67. package/modern/ScatterChart/ScatterChart.js +0 -3
  68. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  69. package/modern/context/CartesianContextProvider.js +3 -88
  70. package/modern/context/DrawingProvider.js +10 -36
  71. package/modern/context/HighlightProvider.js +3 -0
  72. package/modern/context/InteractionProvider.js +3 -0
  73. package/modern/context/SeriesContextProvider.js +3 -0
  74. package/modern/context/index.js +1 -2
  75. package/modern/hooks/useAxisEvents.js +2 -2
  76. package/modern/index.js +1 -1
  77. package/package.json +1 -1
  78. package/legacy/BarChart/BarChart.js +0 -440
  79. package/legacy/BarChart/BarElement.js +0 -119
  80. package/legacy/BarChart/BarPlot.js +0 -232
  81. package/legacy/BarChart/extremums.js +0 -45
  82. package/legacy/BarChart/formatter.js +0 -78
  83. package/legacy/BarChart/index.js +0 -3
  84. package/legacy/BarChart/legend.js +0 -15
  85. package/legacy/ChartContainer/ChartContainer.js +0 -189
  86. package/legacy/ChartContainer/index.js +0 -1
  87. package/legacy/ChartsAxis/ChartsAxis.js +0 -215
  88. package/legacy/ChartsAxis/axisClasses.js +0 -5
  89. package/legacy/ChartsAxis/index.js +0 -2
  90. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
  91. package/legacy/ChartsAxisHighlight/index.js +0 -1
  92. package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
  93. package/legacy/ChartsClipPath/index.js +0 -1
  94. package/legacy/ChartsGrid/ChartsGrid.js +0 -119
  95. package/legacy/ChartsGrid/chartsGridClasses.js +0 -6
  96. package/legacy/ChartsGrid/index.js +0 -2
  97. package/legacy/ChartsLegend/ChartsLegend.js +0 -100
  98. package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
  99. package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
  100. package/legacy/ChartsLegend/index.js +0 -4
  101. package/legacy/ChartsLegend/utils.js +0 -15
  102. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
  103. package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
  104. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
  105. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
  106. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
  107. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
  108. package/legacy/ChartsReferenceLine/common.js +0 -19
  109. package/legacy/ChartsReferenceLine/index.js +0 -2
  110. package/legacy/ChartsSurface.js +0 -78
  111. package/legacy/ChartsText/ChartsText.js +0 -95
  112. package/legacy/ChartsText/index.js +0 -1
  113. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
  114. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
  115. package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
  116. package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
  117. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
  118. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
  119. package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
  120. package/legacy/ChartsTooltip/index.js +0 -6
  121. package/legacy/ChartsTooltip/utils.js +0 -103
  122. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
  123. package/legacy/ChartsVoronoiHandler/index.js +0 -1
  124. package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
  125. package/legacy/ChartsXAxis/index.js +0 -1
  126. package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
  127. package/legacy/ChartsYAxis/index.js +0 -1
  128. package/legacy/Gauge/Gauge.js +0 -146
  129. package/legacy/Gauge/GaugeContainer.js +0 -215
  130. package/legacy/Gauge/GaugeProvider.js +0 -87
  131. package/legacy/Gauge/GaugeReferenceArc.js +0 -37
  132. package/legacy/Gauge/GaugeValueArc.js +0 -44
  133. package/legacy/Gauge/GaugeValueText.js +0 -66
  134. package/legacy/Gauge/gaugeClasses.js +0 -7
  135. package/legacy/Gauge/index.js +0 -7
  136. package/legacy/Gauge/utils.js +0 -84
  137. package/legacy/LineChart/AnimatedArea.js +0 -102
  138. package/legacy/LineChart/AnimatedLine.js +0 -104
  139. package/legacy/LineChart/AreaElement.js +0 -112
  140. package/legacy/LineChart/AreaPlot.js +0 -149
  141. package/legacy/LineChart/LineChart.js +0 -452
  142. package/legacy/LineChart/LineElement.js +0 -112
  143. package/legacy/LineChart/LineHighlightElement.js +0 -79
  144. package/legacy/LineChart/LineHighlightPlot.js +0 -97
  145. package/legacy/LineChart/LinePlot.js +0 -144
  146. package/legacy/LineChart/MarkElement.js +0 -153
  147. package/legacy/LineChart/MarkPlot.js +0 -178
  148. package/legacy/LineChart/extremums.js +0 -54
  149. package/legacy/LineChart/formatter.js +0 -82
  150. package/legacy/LineChart/index.js +0 -11
  151. package/legacy/LineChart/legend.js +0 -15
  152. package/legacy/PieChart/PieArc.js +0 -103
  153. package/legacy/PieChart/PieArcLabel.js +0 -112
  154. package/legacy/PieChart/PieArcLabelPlot.js +0 -193
  155. package/legacy/PieChart/PieArcPlot.js +0 -180
  156. package/legacy/PieChart/PieChart.js +0 -404
  157. package/legacy/PieChart/PiePlot.js +0 -137
  158. package/legacy/PieChart/dataTransform/transition.js +0 -149
  159. package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
  160. package/legacy/PieChart/formatter.js +0 -55
  161. package/legacy/PieChart/index.js +0 -6
  162. package/legacy/PieChart/legend.js +0 -16
  163. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -185
  164. package/legacy/ResponsiveChartContainer/index.js +0 -1
  165. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +0 -73
  166. package/legacy/ScatterChart/Scatter.js +0 -110
  167. package/legacy/ScatterChart/ScatterChart.js +0 -395
  168. package/legacy/ScatterChart/ScatterPlot.js +0 -80
  169. package/legacy/ScatterChart/extremums.js +0 -39
  170. package/legacy/ScatterChart/formatter.js +0 -12
  171. package/legacy/ScatterChart/index.js +0 -3
  172. package/legacy/ScatterChart/legend.js +0 -15
  173. package/legacy/SparkLineChart/SparkLineChart.js +0 -266
  174. package/legacy/SparkLineChart/index.js +0 -1
  175. package/legacy/colorPalettes/colorPalettes.js +0 -15
  176. package/legacy/colorPalettes/index.js +0 -1
  177. package/legacy/constants.js +0 -8
  178. package/legacy/context/CartesianContextProvider.js +0 -327
  179. package/legacy/context/DrawingProvider.js +0 -74
  180. package/legacy/context/HighlightProvider.js +0 -56
  181. package/legacy/context/InteractionProvider.js +0 -81
  182. package/legacy/context/SeriesContextProvider.js +0 -74
  183. package/legacy/context/index.js +0 -2
  184. package/legacy/hooks/index.js +0 -2
  185. package/legacy/hooks/useAxisEvents.js +0 -120
  186. package/legacy/hooks/useChartDimensions.js +0 -18
  187. package/legacy/hooks/useDrawingArea.js +0 -21
  188. package/legacy/hooks/useInteractionItemProps.js +0 -71
  189. package/legacy/hooks/useMounted.js +0 -21
  190. package/legacy/hooks/useReducedMotion.js +0 -27
  191. package/legacy/hooks/useScale.js +0 -33
  192. package/legacy/hooks/useTicks.js +0 -65
  193. package/legacy/index.js +0 -33
  194. package/legacy/internals/components/AxisSharedComponents.js +0 -25
  195. package/legacy/internals/defaultizeColor.js +0 -17
  196. package/legacy/internals/defaultizeValueFormatter.js +0 -12
  197. package/legacy/internals/domUtils.js +0 -121
  198. package/legacy/internals/geometry.js +0 -37
  199. package/legacy/internals/getCurve.js +0 -39
  200. package/legacy/internals/getScale.js +0 -17
  201. package/legacy/internals/getWordsByLines.js +0 -15
  202. package/legacy/internals/isBandScale.js +0 -3
  203. package/legacy/internals/stackSeries.js +0 -92
  204. package/legacy/internals/useAnimatedPath.js +0 -32
  205. package/legacy/internals/utils.js +0 -52
  206. package/legacy/models/axis.js +0 -6
  207. package/legacy/models/helpers.js +0 -1
  208. package/legacy/models/index.js +0 -4
  209. package/legacy/models/layout.js +0 -1
  210. package/legacy/models/seriesType/bar.js +0 -1
  211. package/legacy/models/seriesType/common.js +0 -1
  212. package/legacy/models/seriesType/config.js +0 -1
  213. package/legacy/models/seriesType/index.js +0 -5
  214. package/legacy/models/seriesType/line.js +0 -1
  215. package/legacy/models/seriesType/pie.js +0 -1
  216. package/legacy/models/seriesType/scatter.js +0 -1
  217. package/legacy/models/stacking.js +0 -1
  218. 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';