@mui/x-charts 7.6.0 → 7.6.2

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 (199) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +2 -2
  3. package/BarChart/BarPlot.js +2 -2
  4. package/BarChart/formatter.js +2 -2
  5. package/BarChart/getColor.d.ts +1 -1
  6. package/BarChart/getColor.js +4 -4
  7. package/BarChart/plugin.d.ts +2 -0
  8. package/BarChart/plugin.js +17 -0
  9. package/CHANGELOG.md +91 -0
  10. package/ChartContainer/ChartContainer.d.ts +14 -2
  11. package/ChartContainer/ChartContainer.js +13 -2
  12. package/ChartContainer/defaultPlugins.d.ts +2 -0
  13. package/ChartContainer/defaultPlugins.js +11 -0
  14. package/ChartContainer/usePluginsMerge.d.ts +10 -0
  15. package/ChartContainer/usePluginsMerge.js +39 -0
  16. package/ChartsLegend/ChartsLegend.js +2 -2
  17. package/ChartsLegend/utils.js +4 -1
  18. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  19. package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
  20. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  21. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
  22. package/ChartsTooltip/utils.d.ts +1 -7
  23. package/ChartsTooltip/utils.js +2 -10
  24. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  25. package/ChartsXAxis/ChartsXAxis.js +17 -19
  26. package/ChartsYAxis/ChartsYAxis.js +17 -19
  27. package/LineChart/AreaPlot.js +2 -2
  28. package/LineChart/LineChart.d.ts +1 -1
  29. package/LineChart/LineChart.js +2 -2
  30. package/LineChart/LineHighlightPlot.js +2 -2
  31. package/LineChart/LinePlot.js +2 -2
  32. package/LineChart/MarkPlot.js +2 -2
  33. package/LineChart/formatter.js +2 -2
  34. package/LineChart/getColor.d.ts +1 -1
  35. package/LineChart/getColor.js +2 -2
  36. package/LineChart/plugin.d.ts +2 -0
  37. package/LineChart/plugin.js +17 -0
  38. package/PieChart/PieChart.d.ts +1 -1
  39. package/PieChart/PieChart.js +2 -2
  40. package/PieChart/PiePlot.js +2 -2
  41. package/PieChart/plugin.d.ts +2 -0
  42. package/PieChart/plugin.js +14 -0
  43. package/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
  44. package/ScatterChart/ScatterChart.d.ts +1 -1
  45. package/ScatterChart/ScatterChart.js +2 -2
  46. package/ScatterChart/ScatterPlot.js +2 -2
  47. package/ScatterChart/formatter.js +2 -3
  48. package/ScatterChart/getColor.d.ts +1 -1
  49. package/ScatterChart/getColor.js +2 -2
  50. package/ScatterChart/plugin.d.ts +2 -0
  51. package/ScatterChart/plugin.js +17 -0
  52. package/SparkLineChart/SparkLineChart.d.ts +3 -3
  53. package/SparkLineChart/SparkLineChart.js +1 -1
  54. package/context/CartesianContextProvider.d.ts +13 -10
  55. package/context/CartesianContextProvider.js +2 -2
  56. package/context/DrawingProvider.d.ts +3 -1
  57. package/context/DrawingProvider.js +9 -2
  58. package/context/HighlightedProvider/HighlightedContext.d.ts +2 -1
  59. package/context/HighlightedProvider/HighlightedContext.js +8 -5
  60. package/context/HighlightedProvider/HighlightedProvider.js +15 -12
  61. package/context/HighlightedProvider/useHighlighted.js +6 -3
  62. package/context/HighlightedProvider/useItemHighlighted.js +2 -8
  63. package/context/SeriesContextProvider.d.ts +16 -5
  64. package/context/SeriesContextProvider.js +14 -17
  65. package/context/context.types.d.ts +4 -0
  66. package/context/context.types.js +5 -0
  67. package/esm/BarChart/BarChart.js +2 -2
  68. package/esm/BarChart/BarPlot.js +2 -2
  69. package/esm/BarChart/formatter.js +1 -1
  70. package/esm/BarChart/getColor.js +4 -4
  71. package/esm/BarChart/plugin.js +10 -0
  72. package/esm/ChartContainer/ChartContainer.js +13 -2
  73. package/esm/ChartContainer/defaultPlugins.js +5 -0
  74. package/esm/ChartContainer/usePluginsMerge.js +31 -0
  75. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  76. package/esm/ChartsLegend/utils.js +4 -1
  77. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  78. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  79. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  80. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
  81. package/esm/ChartsTooltip/utils.js +2 -8
  82. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  83. package/esm/ChartsXAxis/ChartsXAxis.js +17 -19
  84. package/esm/ChartsYAxis/ChartsYAxis.js +17 -19
  85. package/esm/LineChart/AreaPlot.js +2 -2
  86. package/esm/LineChart/LineChart.js +2 -2
  87. package/esm/LineChart/LineHighlightPlot.js +2 -2
  88. package/esm/LineChart/LinePlot.js +2 -2
  89. package/esm/LineChart/MarkPlot.js +2 -2
  90. package/esm/LineChart/formatter.js +1 -1
  91. package/esm/LineChart/getColor.js +2 -2
  92. package/esm/LineChart/plugin.js +10 -0
  93. package/esm/PieChart/PieChart.js +2 -2
  94. package/esm/PieChart/PiePlot.js +2 -2
  95. package/esm/PieChart/plugin.js +7 -0
  96. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
  97. package/esm/ScatterChart/ScatterChart.js +2 -2
  98. package/esm/ScatterChart/ScatterPlot.js +2 -2
  99. package/esm/ScatterChart/formatter.js +1 -1
  100. package/esm/ScatterChart/getColor.js +2 -2
  101. package/esm/ScatterChart/plugin.js +10 -0
  102. package/esm/SparkLineChart/SparkLineChart.js +1 -1
  103. package/esm/context/CartesianContextProvider.js +2 -2
  104. package/esm/context/DrawingProvider.js +9 -2
  105. package/esm/context/HighlightedProvider/HighlightedContext.js +8 -5
  106. package/esm/context/HighlightedProvider/HighlightedProvider.js +15 -12
  107. package/esm/context/HighlightedProvider/useHighlighted.js +6 -3
  108. package/esm/context/HighlightedProvider/useItemHighlighted.js +2 -6
  109. package/esm/context/SeriesContextProvider.js +14 -17
  110. package/esm/context/context.types.js +1 -0
  111. package/esm/hooks/useInteractionItemProps.js +2 -2
  112. package/esm/hooks/useSeries.js +6 -3
  113. package/esm/hooks/useSvgRef.js +6 -3
  114. package/esm/internals/configInit.js +20 -0
  115. package/esm/internals/defaultizeValueFormatter.js +2 -3
  116. package/esm/internals/index.js +1 -0
  117. package/esm/internals/isCartesian.js +7 -0
  118. package/esm/models/index.js +1 -0
  119. package/esm/models/plugin.js +1 -0
  120. package/esm/models/seriesType/index.js +6 -0
  121. package/hooks/useInteractionItemProps.js +1 -1
  122. package/hooks/useSeries.d.ts +6 -11
  123. package/hooks/useSeries.js +6 -3
  124. package/hooks/useSvgRef.js +6 -3
  125. package/hooks/useTicks.d.ts +4 -2
  126. package/index.js +1 -1
  127. package/internals/configInit.d.ts +9 -0
  128. package/internals/configInit.js +26 -0
  129. package/internals/defaultizeValueFormatter.d.ts +1 -2
  130. package/internals/defaultizeValueFormatter.js +2 -3
  131. package/internals/index.d.ts +1 -0
  132. package/internals/index.js +16 -0
  133. package/internals/isCartesian.d.ts +7 -0
  134. package/internals/isCartesian.js +14 -0
  135. package/internals/package.json +6 -0
  136. package/models/axis.d.ts +3 -3
  137. package/models/index.d.ts +1 -0
  138. package/models/index.js +11 -0
  139. package/models/plugin.d.ts +16 -0
  140. package/models/plugin.js +5 -0
  141. package/models/seriesType/config.d.ts +30 -5
  142. package/models/seriesType/index.d.ts +8 -11
  143. package/models/seriesType/index.js +6 -0
  144. package/modern/BarChart/BarChart.js +2 -2
  145. package/modern/BarChart/BarPlot.js +2 -2
  146. package/modern/BarChart/formatter.js +1 -1
  147. package/modern/BarChart/getColor.js +4 -4
  148. package/modern/BarChart/plugin.js +10 -0
  149. package/modern/ChartContainer/ChartContainer.js +13 -2
  150. package/modern/ChartContainer/defaultPlugins.js +5 -0
  151. package/modern/ChartContainer/usePluginsMerge.js +31 -0
  152. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  153. package/modern/ChartsLegend/utils.js +4 -1
  154. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  155. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  156. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  157. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
  158. package/modern/ChartsTooltip/utils.js +2 -8
  159. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  160. package/modern/ChartsXAxis/ChartsXAxis.js +17 -19
  161. package/modern/ChartsYAxis/ChartsYAxis.js +17 -19
  162. package/modern/LineChart/AreaPlot.js +2 -2
  163. package/modern/LineChart/LineChart.js +2 -2
  164. package/modern/LineChart/LineHighlightPlot.js +2 -2
  165. package/modern/LineChart/LinePlot.js +2 -2
  166. package/modern/LineChart/MarkPlot.js +2 -2
  167. package/modern/LineChart/formatter.js +1 -1
  168. package/modern/LineChart/getColor.js +2 -2
  169. package/modern/LineChart/plugin.js +10 -0
  170. package/modern/PieChart/PieChart.js +2 -2
  171. package/modern/PieChart/PiePlot.js +2 -2
  172. package/modern/PieChart/plugin.js +7 -0
  173. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
  174. package/modern/ScatterChart/ScatterChart.js +2 -2
  175. package/modern/ScatterChart/ScatterPlot.js +2 -2
  176. package/modern/ScatterChart/formatter.js +1 -1
  177. package/modern/ScatterChart/getColor.js +2 -2
  178. package/modern/ScatterChart/plugin.js +10 -0
  179. package/modern/SparkLineChart/SparkLineChart.js +1 -1
  180. package/modern/context/CartesianContextProvider.js +2 -2
  181. package/modern/context/DrawingProvider.js +9 -2
  182. package/modern/context/HighlightedProvider/HighlightedContext.js +8 -5
  183. package/modern/context/HighlightedProvider/HighlightedProvider.js +15 -12
  184. package/modern/context/HighlightedProvider/useHighlighted.js +6 -3
  185. package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -6
  186. package/modern/context/SeriesContextProvider.js +14 -17
  187. package/modern/context/context.types.js +1 -0
  188. package/modern/hooks/useInteractionItemProps.js +2 -2
  189. package/modern/hooks/useSeries.js +6 -3
  190. package/modern/hooks/useSvgRef.js +6 -3
  191. package/modern/index.js +1 -1
  192. package/modern/internals/configInit.js +20 -0
  193. package/modern/internals/defaultizeValueFormatter.js +2 -3
  194. package/modern/internals/index.js +1 -0
  195. package/modern/internals/isCartesian.js +7 -0
  196. package/modern/models/index.js +1 -0
  197. package/modern/models/plugin.js +1 -0
  198. package/modern/models/seriesType/index.js +6 -0
  199. package/package.json +1 -1
@@ -14,11 +14,11 @@ var _extremums2 = require("../ScatterChart/extremums");
14
14
  var _extremums3 = require("../LineChart/extremums");
15
15
  var _axis = require("../models/axis");
16
16
  var _getScale = require("../internals/getScale");
17
- var _SeriesContextProvider = require("./SeriesContextProvider");
18
17
  var _constants = require("../constants");
19
18
  var _useTicks = require("../hooks/useTicks");
20
19
  var _useDrawingArea = require("../hooks/useDrawingArea");
21
20
  var _colorScale = require("../internals/colorScale");
21
+ var _useSeries = require("../hooks/useSeries");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -52,7 +52,7 @@ function CartesianContextProvider(props) {
52
52
  dataset,
53
53
  children
54
54
  } = props;
55
- const formattedSeries = React.useContext(_SeriesContextProvider.SeriesContext);
55
+ const formattedSeries = (0, _useSeries.useSeries)();
56
56
  const drawingArea = (0, _useDrawingArea.useDrawingArea)();
57
57
  const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
58
58
  const dataKey = axisConfig.dataKey;
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { LayoutConfig } from '../models/layout';
3
+ import { Initializable } from './context.types';
3
4
  export interface DrawingProviderProps extends LayoutConfig {
4
5
  children: React.ReactNode;
5
6
  svgRef: React.RefObject<SVGSVGElement>;
@@ -39,5 +40,6 @@ export declare const DrawingContext: React.Context<DrawingArea & {
39
40
  */
40
41
  chartId: string;
41
42
  }>;
42
- export declare const SvgContext: React.Context<React.RefObject<SVGSVGElement>>;
43
+ export type SvgContextState = React.RefObject<SVGSVGElement>;
44
+ export declare const SvgContext: React.Context<Initializable<SvgContextState>>;
43
45
  export declare function DrawingProvider(props: DrawingProviderProps): React.JSX.Element;
@@ -31,7 +31,10 @@ if (process.env.NODE_ENV !== 'production') {
31
31
  DrawingContext.displayName = 'DrawingContext';
32
32
  }
33
33
  const SvgContext = exports.SvgContext = /*#__PURE__*/React.createContext({
34
- current: null
34
+ isInitialized: false,
35
+ data: {
36
+ current: null
37
+ }
35
38
  });
36
39
  if (process.env.NODE_ENV !== 'production') {
37
40
  SvgContext.displayName = 'SvgContext';
@@ -49,8 +52,12 @@ function DrawingProvider(props) {
49
52
  const value = React.useMemo(() => (0, _extends2.default)({
50
53
  chartId: chartId ?? ''
51
54
  }, drawingArea), [chartId, drawingArea]);
55
+ const refValue = React.useMemo(() => ({
56
+ isInitialized: true,
57
+ data: svgRef
58
+ }), [svgRef]);
52
59
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(SvgContext.Provider, {
53
- value: svgRef,
60
+ value: refValue,
54
61
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DrawingContext.Provider, {
55
62
  value: value,
56
63
  children: children
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { SeriesId } from '../../models/seriesType/common';
3
+ import { Initializable } from '../context.types';
3
4
  /**
4
5
  * The data of the highlighted item.
5
6
  * To highlight an item, you need to provide the series id and the item id.
@@ -62,4 +63,4 @@ export type HighlightedState = {
62
63
  isHighlighted: (input: HighlightItemData) => boolean;
63
64
  isFaded: (input: HighlightItemData) => boolean;
64
65
  };
65
- export declare const HighlightedContext: React.Context<HighlightedState>;
66
+ export declare const HighlightedContext: React.Context<Initializable<HighlightedState>>;
@@ -25,11 +25,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
25
25
  */
26
26
 
27
27
  const HighlightedContext = exports.HighlightedContext = /*#__PURE__*/React.createContext({
28
- highlightedItem: null,
29
- setHighlighted: () => {},
30
- clearHighlighted: () => {},
31
- isHighlighted: () => false,
32
- isFaded: () => false
28
+ isInitialized: false,
29
+ data: {
30
+ highlightedItem: null,
31
+ setHighlighted: () => {},
32
+ clearHighlighted: () => {},
33
+ isHighlighted: () => false,
34
+ isFaded: () => false
35
+ }
33
36
  });
34
37
  if (process.env.NODE_ENV !== 'production') {
35
38
  HighlightedContext.displayName = 'HighlightedContext';
@@ -56,18 +56,21 @@ function HighlightedProvider({
56
56
  const highlightScope = highlightedItem && highlightedItem.seriesId ? seriesById.get(highlightedItem.seriesId) ?? undefined : undefined;
57
57
  const providerValue = React.useMemo(() => {
58
58
  return {
59
- highlightScope,
60
- highlightedItem,
61
- setHighlighted: itemData => {
62
- setHighlightedItem(itemData);
63
- onHighlightChange?.(itemData);
64
- },
65
- clearHighlighted: () => {
66
- setHighlightedItem(null);
67
- onHighlightChange?.(null);
68
- },
69
- isHighlighted: (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem),
70
- isFaded: (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)
59
+ isInitialized: true,
60
+ data: {
61
+ highlightScope,
62
+ highlightedItem,
63
+ setHighlighted: itemData => {
64
+ setHighlightedItem(itemData);
65
+ onHighlightChange?.(itemData);
66
+ },
67
+ clearHighlighted: () => {
68
+ setHighlightedItem(null);
69
+ onHighlightChange?.(null);
70
+ },
71
+ isHighlighted: (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem),
72
+ isFaded: (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)
73
+ }
71
74
  };
72
75
  }, [highlightedItem, highlightScope, setHighlightedItem, onHighlightChange]);
73
76
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_HighlightedContext.HighlightedContext.Provider, {
@@ -16,9 +16,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
16
16
  * @returns {HighlightedState} the state of the chart
17
17
  */
18
18
  function useHighlighted() {
19
- const highlighted = React.useContext(_HighlightedContext.HighlightedContext);
20
- if (highlighted === undefined) {
19
+ const {
20
+ isInitialized,
21
+ data
22
+ } = React.useContext(_HighlightedContext.HighlightedContext);
23
+ if (!isInitialized) {
21
24
  throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
22
25
  }
23
- return highlighted;
26
+ return data;
24
27
  }
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useItemHighlighted = useItemHighlighted;
7
- var React = _interopRequireWildcard(require("react"));
8
- var _HighlightedContext = require("./HighlightedContext");
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
7
+ var _useHighlighted = require("./useHighlighted");
11
8
  /**
12
9
  * A hook to check the highlighted state of the item.
13
10
  * This function already calculates that an item is not faded if it is highlighted.
@@ -18,10 +15,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
18
15
  * @returns {ItemHighlightedState} the state of the item
19
16
  */
20
17
  function useItemHighlighted(item) {
21
- const highlighted = React.useContext(_HighlightedContext.HighlightedContext);
22
- if (highlighted === undefined) {
23
- throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
24
- }
18
+ const highlighted = (0, _useHighlighted.useHighlighted)();
25
19
  if (!item) {
26
20
  return {
27
21
  isHighlighted: false,
@@ -1,25 +1,36 @@
1
1
  import * as React from 'react';
2
2
  import { AllSeriesType } from '../models/seriesType';
3
- import { ChartSeriesType, DatasetType, FormatterResult } from '../models/seriesType/config';
3
+ import { ChartSeriesType, DatasetType, FormatterParams, FormatterResult } from '../models/seriesType/config';
4
4
  import { ChartsColorPalette } from '../colorPalettes';
5
- export type SeriesContextProviderProps = {
5
+ import { Initializable } from './context.types';
6
+ export type SeriesFormatterType<T extends ChartSeriesType> = (series: AllSeriesType<T>[], colors: string[], dataset?: DatasetType) => {
7
+ [type in T]?: FormatterResult<type>;
8
+ };
9
+ export type SeriesContextProviderProps<T extends ChartSeriesType = ChartSeriesType> = {
6
10
  dataset?: DatasetType;
7
11
  /**
8
12
  * The array of series to display.
9
13
  * Each type of series has its own specificity.
10
14
  * Please refer to the appropriate docs page to learn more about it.
11
15
  */
12
- series: AllSeriesType[];
16
+ series: AllSeriesType<T>[];
13
17
  /**
14
18
  * Color palette used to colorize multiple series.
15
19
  * @default blueberryTwilightPalette
16
20
  */
17
21
  colors?: ChartsColorPalette;
22
+ /**
23
+ * Preprocessors for each series types.
24
+ */
25
+ seriesFormatters: SeriesFormatterConfig<T>;
18
26
  children: React.ReactNode;
19
27
  };
20
28
  export type FormattedSeries = {
21
29
  [type in ChartSeriesType]?: FormatterResult<type>;
22
30
  };
23
- export declare const SeriesContext: React.Context<FormattedSeries>;
24
- declare function SeriesContextProvider(props: SeriesContextProviderProps): React.JSX.Element;
31
+ export declare const SeriesContext: React.Context<Initializable<FormattedSeries>>;
32
+ export type SeriesFormatterConfig<T extends ChartSeriesType = ChartSeriesType> = {
33
+ [K in T]?: (series: FormatterParams<K>, dataset?: DatasetType) => any;
34
+ };
35
+ declare function SeriesContextProvider<T extends ChartSeriesType>(props: SeriesContextProviderProps<T>): React.JSX.Element;
25
36
  export { SeriesContextProvider };
@@ -9,26 +9,18 @@ exports.SeriesContextProvider = SeriesContextProvider;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _styles = require("@mui/material/styles");
12
- var _formatter = _interopRequireDefault(require("../BarChart/formatter"));
13
- var _formatter2 = _interopRequireDefault(require("../ScatterChart/formatter"));
14
- var _formatter3 = _interopRequireDefault(require("../LineChart/formatter"));
15
- var _formatter4 = _interopRequireDefault(require("../PieChart/formatter"));
16
12
  var _defaultizeColor = require("../internals/defaultizeColor");
17
13
  var _colorPalettes = require("../colorPalettes");
18
14
  var _jsxRuntime = require("react/jsx-runtime");
19
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
- const SeriesContext = exports.SeriesContext = /*#__PURE__*/React.createContext({});
17
+ const SeriesContext = exports.SeriesContext = /*#__PURE__*/React.createContext({
18
+ isInitialized: false,
19
+ data: {}
20
+ });
22
21
  if (process.env.NODE_ENV !== 'production') {
23
22
  SeriesContext.displayName = 'SeriesContext';
24
23
  }
25
- const seriesTypeFormatter = {
26
- bar: _formatter.default,
27
- scatter: _formatter2.default,
28
- line: _formatter3.default,
29
- pie: _formatter4.default
30
- };
31
-
32
24
  /**
33
25
  * This methods is the interface between what the developer is providing and what components receives
34
26
  * To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
@@ -37,7 +29,7 @@ const seriesTypeFormatter = {
37
29
  * @param colors The color palette used to defaultize series colors
38
30
  * @returns An object structuring all the series by type.
39
31
  */
40
- const formatSeries = (series, colors, dataset) => {
32
+ const preprocessSeries = (series, colors, seriesFormatters, dataset) => {
41
33
  // Group series by type
42
34
  const seriesGroups = {};
43
35
  series.forEach((seriesData, seriesIndex) => {
@@ -61,9 +53,10 @@ const formatSeries = (series, colors, dataset) => {
61
53
  });
62
54
  const formattedSeries = {};
63
55
  // Apply formatter on a type group
64
- Object.keys(seriesTypeFormatter).forEach(type => {
65
- if (seriesGroups[type] !== undefined) {
66
- formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
56
+ Object.keys(seriesFormatters).forEach(type => {
57
+ const group = seriesGroups[type];
58
+ if (group !== undefined) {
59
+ formattedSeries[type] = seriesFormatters[type]?.(group, dataset) ?? seriesGroups[type];
67
60
  }
68
61
  });
69
62
  return formattedSeries;
@@ -73,10 +66,14 @@ function SeriesContextProvider(props) {
73
66
  series,
74
67
  dataset,
75
68
  colors = _colorPalettes.blueberryTwilightPalette,
69
+ seriesFormatters,
76
70
  children
77
71
  } = props;
78
72
  const theme = (0, _styles.useTheme)();
79
- const formattedSeries = React.useMemo(() => formatSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, dataset), [series, colors, theme.palette.mode, dataset]);
73
+ const formattedSeries = React.useMemo(() => ({
74
+ isInitialized: true,
75
+ data: preprocessSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, seriesFormatters, dataset)
76
+ }), [series, colors, theme.palette.mode, seriesFormatters, dataset]);
80
77
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(SeriesContext.Provider, {
81
78
  value: formattedSeries,
82
79
  children: children
@@ -0,0 +1,4 @@
1
+ export type Initializable<T> = {
2
+ isInitialized: boolean;
3
+ data: T;
4
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -351,7 +351,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
351
351
  labelStyle: PropTypes.object,
352
352
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
353
353
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
354
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
354
+ position: PropTypes.oneOf(['bottom', 'top']),
355
355
  reverse: PropTypes.bool,
356
356
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
357
357
  slotProps: PropTypes.object,
@@ -404,7 +404,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
404
404
  labelStyle: PropTypes.object,
405
405
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
406
406
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
407
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
407
+ position: PropTypes.oneOf(['left', 'right']),
408
408
  reverse: PropTypes.bool,
409
409
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
410
410
  slotProps: PropTypes.object,
@@ -4,7 +4,6 @@ const _excluded = ["skipAnimation", "onItemClick", "borderRadius", "barLabel"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useTransition } from '@react-spring/web';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
7
  import { CartesianContext } from '../context/CartesianContextProvider';
9
8
  import { BarElement } from './BarElement';
10
9
  import getColor from './getColor';
@@ -12,6 +11,7 @@ import { useChartId } from '../hooks';
12
11
  import { BarClipPath } from './BarClipPath';
13
12
  import { BarLabelPlot } from './BarLabel/BarLabelPlot';
14
13
  import { checkScaleErrors } from './checkScaleErrors';
14
+ import { useBarSeries } from '../hooks/useSeries';
15
15
 
16
16
  /**
17
17
  * Solution of the equations
@@ -42,7 +42,7 @@ function getBandSize({
42
42
  };
43
43
  }
44
44
  const useAggregatedData = () => {
45
- const seriesData = React.useContext(SeriesContext).bar ?? {
45
+ const seriesData = useBarSeries() ?? {
46
46
  series: {},
47
47
  stackingGroups: [],
48
48
  seriesOrder: []
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from 'd3-shape';
3
3
  import { getStackingGroups } from '../internals/stackSeries';
4
- import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
4
+ import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
5
5
  let warnOnce = false;
6
6
  const formatter = (params, dataset) => {
7
7
  const {
@@ -1,8 +1,8 @@
1
1
  export default function getColor(series, xAxis, yAxis) {
2
2
  const verticalLayout = series.layout === 'vertical';
3
- const bandColorScale = verticalLayout ? xAxis.colorScale : yAxis.colorScale;
4
- const valueColorScale = verticalLayout ? yAxis.colorScale : xAxis.colorScale;
5
- const bandValues = verticalLayout ? xAxis.data : yAxis.data;
3
+ const bandColorScale = verticalLayout ? xAxis?.colorScale : yAxis?.colorScale;
4
+ const valueColorScale = verticalLayout ? yAxis?.colorScale : xAxis?.colorScale;
5
+ const bandValues = verticalLayout ? xAxis?.data : yAxis?.data;
6
6
  if (valueColorScale) {
7
7
  return dataIndex => {
8
8
  const value = series.data[dataIndex];
@@ -13,7 +13,7 @@ export default function getColor(series, xAxis, yAxis) {
13
13
  return color;
14
14
  };
15
15
  }
16
- if (bandColorScale) {
16
+ if (bandColorScale && bandValues) {
17
17
  return dataIndex => {
18
18
  const value = bandValues[dataIndex];
19
19
  const color = value === null ? series.color : bandColorScale(value);
@@ -0,0 +1,10 @@
1
+ import { getExtremumX, getExtremumY } from './extremums';
2
+ import formatter from './formatter';
3
+ import getColor from './getColor';
4
+ export const plugin = {
5
+ seriesType: 'bar',
6
+ seriesFormatter: formatter,
7
+ colorProcessor: getColor,
8
+ xExtremumGetter: getExtremumX,
9
+ yExtremumGetter: getExtremumY
10
+ };
@@ -9,6 +9,7 @@ import { ChartsSurface } from '../ChartsSurface';
9
9
  import { CartesianContextProvider } from '../context/CartesianContextProvider';
10
10
  import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
11
11
  import { HighlightedProvider } from '../context';
12
+ import { usePluginsMerge } from './usePluginsMerge';
12
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
14
15
  const {
@@ -26,10 +27,14 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
26
27
  disableAxisListener,
27
28
  highlightedItem,
28
29
  onHighlightChange,
30
+ plugins,
29
31
  children
30
32
  } = props;
31
33
  const svgRef = React.useRef(null);
32
34
  const handleRef = useForkRef(ref, svgRef);
35
+ const {
36
+ seriesFormatters
37
+ } = usePluginsMerge(plugins);
33
38
  useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
34
39
 
35
40
  return /*#__PURE__*/_jsx(DrawingProvider, {
@@ -41,6 +46,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
41
46
  series: series,
42
47
  colors: colors,
43
48
  dataset: dataset,
49
+ seriesFormatters: seriesFormatters,
44
50
  children: /*#__PURE__*/_jsx(CartesianContextProvider, {
45
51
  xAxis: xAxis,
46
52
  yAxis: yAxis,
@@ -117,6 +123,11 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
117
123
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
118
124
  */
119
125
  onHighlightChange: PropTypes.func,
126
+ /**
127
+ * An array of plugins defining how to preprocess data.
128
+ * If not provided, the container supports line, bar, scatter and pie charts.
129
+ */
130
+ plugins: PropTypes.arrayOf(PropTypes.object),
120
131
  /**
121
132
  * The array of series to display.
122
133
  * Each type of series has its own specificity.
@@ -170,7 +181,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
170
181
  labelStyle: PropTypes.object,
171
182
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
172
183
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
173
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
184
+ position: PropTypes.oneOf(['bottom', 'top']),
174
185
  reverse: PropTypes.bool,
175
186
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
176
187
  slotProps: PropTypes.object,
@@ -223,7 +234,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
223
234
  labelStyle: PropTypes.object,
224
235
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
225
236
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
226
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
237
+ position: PropTypes.oneOf(['left', 'right']),
227
238
  reverse: PropTypes.bool,
228
239
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
229
240
  slotProps: PropTypes.object,
@@ -0,0 +1,5 @@
1
+ import { plugin as barPlugin } from '../BarChart/plugin';
2
+ import { plugin as scatterPlugin } from '../ScatterChart/plugin';
3
+ import { plugin as linePlugin } from '../LineChart/plugin';
4
+ import { plugin as piePlugin } from '../PieChart/plugin';
5
+ export const defaultPlugins = [barPlugin, scatterPlugin, linePlugin, piePlugin];
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { defaultPlugins } from './defaultPlugins';
3
+ export function usePluginsMerge(plugins) {
4
+ const defaultizedPlugins = plugins ?? defaultPlugins;
5
+ return React.useMemo(() => {
6
+ const seriesFormatters = {};
7
+ const colorProcessors = {};
8
+ const xExtremumGetters = {};
9
+ const yExtremumGetters = {};
10
+ for (let i = 0; i < defaultizedPlugins.length; i += 1) {
11
+ const plugin = defaultizedPlugins[i];
12
+
13
+ // To remove those any we will need to solve this union discrimination issue:
14
+ // https://www.typescriptlang.org/play/?#code/FDAuE8AcFMAIDkCuBbARtATgYQPYDsAzASwHNYBeWAb2FlgGsi8ATALlgHI8V0MOBuWrBwwMAQ1A4M7ABQAPdtzSYAlBQB8sJb0EBfEBBiwAyqAxMSuQqQrUhjFuw4BnMxYFCRmCVNkLYruZ4JGrkmoEWeiAAxviuWqhWxCTsSMrY+Mm2VAxMbLAARNqYBQA0wqI+0rByGrAATLAAVDWw+rF48YFJpOymQZaZNpQ5DvkFEcFlFd6S1bVhsAAG9S0AJFRyukttMXGgsB3JzrYA2niJQyTl3VcAugZQcADylXPOALJikJAW2ULFDAAflSPEwPRIpw4XnEcw4d1KQkmJBBJjcwQhUJhVXhiN0gmAHXi2LmXx+FnYr1mUk+31+wWy+JABCksBkABtoAcjjYcARDldnGoaCA6AB6MWwADqUnoJxw9FgRH5AHc4L9ooroGJogALQ5iZxwPJEABuRGYiDE7PASJVRFAerZPJIADoxsKhHRooa4FwwXxWF66DNYVIyfTIS73Xk7rZoySpIIQyHUBhtfRkyGfUbOMiOEGU3RExgIxZTtGxnHKAm3kng8xoAQxIh2aBC0W0xms-pvftqLkWOUS2141chBLYABJDimuB4HBKxtiWBiVA4RAHXU4FWwSSwTkHAAqxlgiBYmFcYhYAusbrGq5vtepGFX6YPTHo0GYnjrpbp5ZVrYJZ6EAA
15
+ seriesFormatters[plugin.seriesType] = plugin.seriesFormatter;
16
+ colorProcessors[plugin.seriesType] = plugin.colorProcessor;
17
+ if (plugin.xExtremumGetter) {
18
+ xExtremumGetters[plugin.seriesType] = plugin.xExtremumGetter;
19
+ }
20
+ if (plugin.yExtremumGetter) {
21
+ yExtremumGetters[plugin.seriesType] = plugin.yExtremumGetter;
22
+ }
23
+ }
24
+ return {
25
+ seriesFormatters,
26
+ colorProcessors,
27
+ xExtremumGetters,
28
+ yExtremumGetters
29
+ };
30
+ }, [defaultizedPlugins]);
31
+ }
@@ -5,10 +5,10 @@ import { useSlotProps } from '@mui/base/utils';
5
5
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
6
6
  import { useThemeProps, useTheme } from '@mui/material/styles';
7
7
  import { getSeriesToDisplay } from './utils';
8
- import { SeriesContext } from '../context/SeriesContextProvider';
9
8
  import { getLegendUtilityClass } from './chartsLegendClasses';
10
9
  import { DefaultChartsLegend } from './DefaultChartsLegend';
11
10
  import { useDrawingArea } from '../hooks';
11
+ import { useSeries } from '../hooks/useSeries';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const useUtilityClasses = ownerState => {
14
14
  const {
@@ -47,7 +47,7 @@ function ChartsLegend(inProps) {
47
47
  theme
48
48
  }));
49
49
  const drawingArea = useDrawingArea();
50
- const series = React.useContext(SeriesContext);
50
+ const series = useSeries();
51
51
  const seriesToDisplay = getSeriesToDisplay(series);
52
52
  const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
53
53
  const chartLegendRenderProps = useSlotProps({
@@ -9,5 +9,8 @@ const legendGetter = {
9
9
  pie: getPieLegend
10
10
  };
11
11
  export function getSeriesToDisplay(series) {
12
- return Object.keys(series).flatMap(seriesType => legendGetter[seriesType](series[seriesType]));
12
+ return Object.keys(series).flatMap(seriesType => {
13
+ const getter = legendGetter[seriesType];
14
+ return getter === undefined ? [] : getter(series[seriesType]);
15
+ });
13
16
  }
@@ -1,16 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { SvgContext } from '../context/DrawingProvider';
4
3
  import { InteractionContext } from '../context/InteractionProvider';
5
4
  import { CartesianContext } from '../context/CartesianContextProvider';
6
- import { SeriesContext } from '../context/SeriesContextProvider';
5
+ import { useSeries } from '../hooks/useSeries';
6
+ import { useSvgRef } from '../hooks';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  function ChartsOnAxisClickHandler(props) {
9
9
  const {
10
10
  onAxisClick
11
11
  } = props;
12
- const svgRef = React.useContext(SvgContext);
13
- const series = React.useContext(SeriesContext);
12
+ const svgRef = useSvgRef();
13
+ const series = useSeries();
14
14
  const {
15
15
  axis
16
16
  } = React.useContext(InteractionContext);
@@ -2,12 +2,12 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
- import { SeriesContext } from '../context/SeriesContextProvider';
6
5
  import { CartesianContext } from '../context/CartesianContextProvider';
7
6
  import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
8
- import { isCartesianSeriesType } from './utils';
7
+ import { isCartesianSeriesType } from '../internals/isCartesian';
9
8
  import colorGetter from '../internals/colorGetter';
10
9
  import { ZAxisContext } from '../context/ZAxisContextProvider';
10
+ import { useSeries } from '../hooks/useSeries';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  function ChartsAxisTooltipContent(props) {
13
13
  const {
@@ -30,7 +30,7 @@ function ChartsAxisTooltipContent(props) {
30
30
  zAxisIds,
31
31
  zAxis
32
32
  } = React.useContext(ZAxisContext);
33
- const series = React.useContext(SeriesContext);
33
+ const series = useSeries();
34
34
  const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
35
35
  const relevantSeries = React.useMemo(() => {
36
36
  const rep = [];
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
- import { SeriesContext } from '../context/SeriesContextProvider';
6
5
  import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
7
6
  import { CartesianContext } from '../context/CartesianContextProvider';
8
7
  import colorGetter from '../internals/colorGetter';
9
8
  import { ZAxisContext } from '../context/ZAxisContextProvider';
9
+ import { useSeries } from '../hooks/useSeries';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  function ChartsItemTooltipContent(props) {
12
12
  const {
@@ -16,7 +16,7 @@ function ChartsItemTooltipContent(props) {
16
16
  classes,
17
17
  contentProps
18
18
  } = props;
19
- const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
19
+ const series = useSeries()[itemData.type].series[itemData.seriesId];
20
20
  const {
21
21
  xAxis,
22
22
  yAxis,
@@ -3,8 +3,9 @@ import PropTypes from 'prop-types';
3
3
  import clsx from 'clsx';
4
4
  import Typography from '@mui/material/Typography';
5
5
  import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
6
- import { isCartesianSeries, utcFormatter } from './utils';
6
+ import { utcFormatter } from './utils';
7
7
  import { getLabel } from '../internals/getLabel';
8
+ import { isCartesianSeries } from '../internals/isCartesian';
8
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  function DefaultChartsAxisTooltipContent(props) {
10
11
  const {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { SvgContext } from '../context/DrawingProvider';
2
+ import { useSvgRef } from '../hooks';
3
3
  export function generateVirtualElement(mousePosition) {
4
4
  if (mousePosition === null) {
5
5
  return {
@@ -44,7 +44,7 @@ export function generateVirtualElement(mousePosition) {
44
44
  };
45
45
  }
46
46
  export function useMouseTracker() {
47
- const svgRef = React.useContext(SvgContext);
47
+ const svgRef = useSvgRef();
48
48
 
49
49
  // Use a ref to avoid rerendering on every mousemove event.
50
50
  const [mousePosition, setMousePosition] = React.useState(null);
@@ -84,12 +84,6 @@ export function getTooltipHasData(trigger, displayedData) {
84
84
  const hasAxisYData = displayedData.y !== null;
85
85
  return hasAxisXData || hasAxisYData;
86
86
  }
87
- export function isCartesianSeriesType(seriesType) {
88
- return ['bar', 'line', 'scatter'].includes(seriesType);
89
- }
90
- export function isCartesianSeries(series) {
91
- return isCartesianSeriesType(series.type);
92
- }
93
87
  export function utcFormatter(v) {
94
88
  if (v instanceof Date) {
95
89
  return v.toUTCString();