@mui/x-charts 9.2.0 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/BarChart/BarChart.js +10 -10
  2. package/BarChart/BarChart.mjs +10 -10
  3. package/BarChart/BarElement.d.mts +3 -2
  4. package/BarChart/BarElement.d.ts +3 -2
  5. package/BarChart/BarLabel/BarLabelItem.d.mts +3 -2
  6. package/BarChart/BarLabel/BarLabelItem.d.ts +3 -2
  7. package/BarChart/seriesConfig/bar/extremums.js +7 -2
  8. package/BarChart/seriesConfig/bar/extremums.mjs +7 -2
  9. package/BarChart/seriesConfig/bar/getColor.js +7 -53
  10. package/BarChart/seriesConfig/bar/getColor.mjs +7 -53
  11. package/BarChart/seriesConfig/bar/seriesProcessor.js +3 -1
  12. package/BarChart/seriesConfig/bar/seriesProcessor.mjs +3 -1
  13. package/BarChart/seriesConfig/bar/tooltip.js +4 -27
  14. package/BarChart/seriesConfig/bar/tooltip.mjs +4 -27
  15. package/CHANGELOG.md +314 -0
  16. package/ChartsContainer/ChartsContainer.js +30 -9
  17. package/ChartsContainer/ChartsContainer.mjs +30 -9
  18. package/ChartsLabel/ChartsLabelMark.js +1 -23
  19. package/ChartsLabel/ChartsLabelMark.mjs +0 -22
  20. package/ChartsLabel/labelMarkClasses.d.mts +0 -1
  21. package/ChartsLabel/labelMarkClasses.d.ts +0 -1
  22. package/ChartsLabel/labelMarkClasses.js +1 -2
  23. package/ChartsLabel/labelMarkClasses.mjs +2 -2
  24. package/ChartsLayerContainer/ChartsLayerContainer.js +36 -30
  25. package/ChartsLayerContainer/ChartsLayerContainer.mjs +36 -30
  26. package/ChartsLegend/chartsLegend.types.d.mts +3 -2
  27. package/ChartsLegend/chartsLegend.types.d.ts +3 -2
  28. package/ChartsLegend/piecewiseColorLegendClasses.js +8 -2
  29. package/ChartsLegend/piecewiseColorLegendClasses.mjs +8 -2
  30. package/ChartsOverlay/ChartsOverlay.d.mts +5 -4
  31. package/ChartsOverlay/ChartsOverlay.d.ts +5 -4
  32. package/ChartsReferenceLine/ChartsXReferenceLine.js +6 -1
  33. package/ChartsReferenceLine/ChartsXReferenceLine.mjs +6 -1
  34. package/ChartsReferenceLine/ChartsYReferenceLine.js +5 -0
  35. package/ChartsReferenceLine/ChartsYReferenceLine.mjs +5 -0
  36. package/ChartsTooltip/ChartTooltip.types.d.mts +3 -2
  37. package/ChartsTooltip/ChartTooltip.types.d.ts +3 -2
  38. package/ChartsTooltip/useAxesTooltip.js +2 -2
  39. package/ChartsTooltip/useAxesTooltip.mjs +2 -2
  40. package/ChartsTooltip/useItemTooltip.js +2 -2
  41. package/ChartsTooltip/useItemTooltip.mjs +2 -2
  42. package/ChartsXAxis/ChartsXAxis.js +3 -1
  43. package/ChartsXAxis/ChartsXAxis.mjs +3 -1
  44. package/ChartsXAxis/useAxisTicksProps.d.mts +84 -3
  45. package/ChartsXAxis/useAxisTicksProps.d.ts +84 -3
  46. package/ChartsYAxis/ChartsYAxis.js +3 -1
  47. package/ChartsYAxis/ChartsYAxis.mjs +3 -1
  48. package/ChartsYAxis/useAxisTicksProps.d.mts +84 -3
  49. package/ChartsYAxis/useAxisTicksProps.d.ts +84 -3
  50. package/LineChart/AreaElement.d.mts +3 -2
  51. package/LineChart/AreaElement.d.ts +3 -2
  52. package/LineChart/LineChart.js +6 -6
  53. package/LineChart/LineChart.mjs +6 -6
  54. package/LineChart/LineElement.d.mts +3 -2
  55. package/LineChart/LineElement.d.ts +3 -2
  56. package/LineChart/LineHighlightPlot.d.mts +3 -2
  57. package/LineChart/LineHighlightPlot.d.ts +3 -2
  58. package/LineChart/LineHighlightPlot.js +65 -45
  59. package/LineChart/LineHighlightPlot.mjs +65 -45
  60. package/LineChart/MarkPlot.d.mts +3 -2
  61. package/LineChart/MarkPlot.d.ts +3 -2
  62. package/LineChart/seriesConfig/curveEvaluation.js +40 -15
  63. package/LineChart/seriesConfig/curveEvaluation.mjs +39 -15
  64. package/LineChart/seriesConfig/extremums.js +5 -1
  65. package/LineChart/seriesConfig/extremums.mjs +5 -1
  66. package/LineChart/seriesConfig/getColor.js +7 -54
  67. package/LineChart/seriesConfig/getColor.mjs +7 -54
  68. package/LineChart/seriesConfig/seriesProcessor.d.mts +2 -4
  69. package/LineChart/seriesConfig/seriesProcessor.d.ts +2 -4
  70. package/LineChart/seriesConfig/seriesProcessor.js +2 -139
  71. package/LineChart/seriesConfig/seriesProcessor.mjs +2 -138
  72. package/LineChart/seriesConfig/tooltip.js +4 -25
  73. package/LineChart/seriesConfig/tooltip.mjs +4 -25
  74. package/LineChart/useMarkPlotData.js +3 -1
  75. package/LineChart/useMarkPlotData.mjs +3 -1
  76. package/PieChart/PieArcLabelPlot.d.mts +3 -2
  77. package/PieChart/PieArcLabelPlot.d.ts +3 -2
  78. package/PieChart/PieArcPlot.d.mts +3 -2
  79. package/PieChart/PieArcPlot.d.ts +3 -2
  80. package/PieChart/PieChart.js +6 -6
  81. package/PieChart/PieChart.mjs +6 -6
  82. package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +2 -2
  83. package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +2 -2
  84. package/RadarChart/RadarAxis/useRadarAxis.js +1 -1
  85. package/RadarChart/RadarAxis/useRadarAxis.mjs +1 -1
  86. package/RadarChart/RadarChart.js +8 -8
  87. package/RadarChart/RadarChart.mjs +8 -8
  88. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
  89. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
  90. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +1 -0
  91. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +1 -0
  92. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -0
  93. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.mjs +1 -0
  94. package/ScatterChart/BatchScatter.d.mts +2 -8
  95. package/ScatterChart/BatchScatter.d.ts +2 -8
  96. package/ScatterChart/BatchScatter.js +17 -12
  97. package/ScatterChart/BatchScatter.mjs +17 -12
  98. package/ScatterChart/FocusedScatterMark.js +2 -2
  99. package/ScatterChart/FocusedScatterMark.mjs +2 -2
  100. package/ScatterChart/HighlightedScatterMark.js +3 -3
  101. package/ScatterChart/HighlightedScatterMark.mjs +3 -3
  102. package/ScatterChart/Scatter.d.mts +5 -0
  103. package/ScatterChart/Scatter.d.ts +5 -0
  104. package/ScatterChart/Scatter.js +7 -2
  105. package/ScatterChart/Scatter.mjs +7 -2
  106. package/ScatterChart/ScatterChart.d.mts +2 -1
  107. package/ScatterChart/ScatterChart.d.ts +2 -1
  108. package/ScatterChart/ScatterChart.js +32 -11
  109. package/ScatterChart/ScatterChart.mjs +32 -11
  110. package/ScatterChart/ScatterMarker.types.d.mts +3 -2
  111. package/ScatterChart/ScatterMarker.types.d.ts +3 -2
  112. package/ScatterChart/ScatterPlot.d.mts +3 -2
  113. package/ScatterChart/ScatterPlot.d.ts +3 -2
  114. package/ScatterChart/ScatterPlot.js +6 -1
  115. package/ScatterChart/ScatterPlot.mjs +6 -1
  116. package/ScatterChart/seriesConfig/extremums.js +6 -0
  117. package/ScatterChart/seriesConfig/extremums.mjs +6 -0
  118. package/ScatterChart/seriesConfig/getColor.js +1 -1
  119. package/ScatterChart/seriesConfig/getColor.mjs +1 -1
  120. package/ScatterChart/seriesConfig/getMarkerSize.d.mts +18 -0
  121. package/ScatterChart/seriesConfig/getMarkerSize.d.ts +18 -0
  122. package/ScatterChart/seriesConfig/getMarkerSize.js +43 -0
  123. package/ScatterChart/seriesConfig/getMarkerSize.mjs +37 -0
  124. package/ScatterChart/seriesConfig/seriesProcessor.js +23 -8
  125. package/ScatterChart/seriesConfig/seriesProcessor.mjs +23 -8
  126. package/ScatterChart/seriesConfig/tooltip.js +2 -24
  127. package/ScatterChart/seriesConfig/tooltip.mjs +2 -24
  128. package/ScatterChart/useScatterItemPosition.d.mts +4 -0
  129. package/ScatterChart/useScatterItemPosition.d.ts +4 -0
  130. package/ScatterChart/useScatterItemPosition.js +9 -0
  131. package/ScatterChart/useScatterItemPosition.mjs +8 -0
  132. package/SparkLineChart/SparkLineChart.js +27 -27
  133. package/SparkLineChart/SparkLineChart.mjs +27 -27
  134. package/Toolbar/Toolbar.types.d.mts +3 -2
  135. package/Toolbar/Toolbar.types.d.ts +3 -2
  136. package/index.js +1 -1
  137. package/index.mjs +1 -1
  138. package/internals/animation/animation.d.mts +1 -2
  139. package/internals/animation/animation.d.ts +1 -2
  140. package/internals/commonNextFocusItem.d.mts +10 -2
  141. package/internals/commonNextFocusItem.d.ts +10 -2
  142. package/internals/commonNextFocusItem.js +12 -4
  143. package/internals/commonNextFocusItem.mjs +12 -4
  144. package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +1 -1
  145. package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +1 -1
  146. package/internals/createCommonKeyboardFocusHandler.d.mts +1 -1
  147. package/internals/createCommonKeyboardFocusHandler.d.ts +1 -1
  148. package/internals/createCommonKeyboardFocusHandler.js +3 -3
  149. package/internals/createCommonKeyboardFocusHandler.mjs +3 -3
  150. package/internals/getLineLikeTooltip.d.mts +9 -0
  151. package/internals/getLineLikeTooltip.d.ts +9 -0
  152. package/internals/getLineLikeTooltip.js +38 -0
  153. package/internals/getLineLikeTooltip.mjs +31 -0
  154. package/internals/incompleteDatasetKeysError.d.mts +1 -0
  155. package/internals/incompleteDatasetKeysError.d.ts +1 -0
  156. package/internals/incompleteDatasetKeysError.js +11 -0
  157. package/internals/incompleteDatasetKeysError.mjs +4 -0
  158. package/internals/index.d.mts +5 -0
  159. package/internals/index.d.ts +5 -0
  160. package/internals/index.js +48 -0
  161. package/internals/index.mjs +5 -0
  162. package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.mts +4 -2
  163. package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.ts +4 -2
  164. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  165. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.mjs +4 -3
  166. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  167. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +3 -3
  168. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.mts +10 -1
  169. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +10 -1
  170. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +18 -1
  171. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.mjs +16 -0
  172. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -3
  173. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -3
  174. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +24 -5
  175. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.mjs +24 -5
  176. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.mts +1 -1
  177. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +1 -1
  178. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +46 -2
  179. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.mjs +47 -2
  180. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +46 -11
  181. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +46 -11
  182. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +2 -1
  183. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +2 -1
  184. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +6 -2
  185. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.mjs +6 -2
  186. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.mts +4 -0
  187. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +4 -0
  188. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +3 -1
  189. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.mjs +1 -0
  190. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +5 -3
  191. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +7 -5
  192. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +17 -3
  193. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.mjs +17 -3
  194. package/internals/processLineLikeSeries.d.mts +6 -0
  195. package/internals/processLineLikeSeries.d.ts +6 -0
  196. package/internals/processLineLikeSeries.js +145 -0
  197. package/internals/processLineLikeSeries.mjs +138 -0
  198. package/internals/resolveColorProcessor.d.mts +11 -0
  199. package/internals/resolveColorProcessor.d.ts +11 -0
  200. package/internals/resolveColorProcessor.js +62 -0
  201. package/internals/resolveColorProcessor.mjs +56 -0
  202. package/internals/sizeScale.d.mts +6 -0
  203. package/internals/sizeScale.d.ts +6 -0
  204. package/internals/sizeScale.js +46 -0
  205. package/internals/sizeScale.mjs +38 -0
  206. package/models/axis.d.mts +18 -12
  207. package/models/axis.d.ts +18 -12
  208. package/models/chartsSlotsComponentsProps.d.mts +25 -0
  209. package/models/chartsSlotsComponentsProps.d.ts +25 -0
  210. package/models/chartsSlotsComponentsProps.js +5 -0
  211. package/models/chartsSlotsComponentsProps.mjs +1 -0
  212. package/models/index.d.mts +1 -0
  213. package/models/index.d.ts +1 -0
  214. package/models/index.js +11 -0
  215. package/models/index.mjs +1 -0
  216. package/models/seriesType/line.d.mts +5 -2
  217. package/models/seriesType/line.d.ts +5 -2
  218. package/models/seriesType/scatter.d.mts +34 -2
  219. package/models/seriesType/scatter.d.ts +34 -2
  220. package/models/sizeMapping.d.mts +64 -0
  221. package/models/sizeMapping.d.ts +64 -0
  222. package/models/sizeMapping.js +5 -0
  223. package/models/sizeMapping.mjs +1 -0
  224. package/models/slots/chartsBaseSlots.d.mts +6 -5
  225. package/models/slots/chartsBaseSlots.d.ts +6 -5
  226. package/models/z-axis.d.mts +10 -1
  227. package/models/z-axis.d.ts +10 -1
  228. package/package.json +6 -6
@@ -8,10 +8,11 @@ import { defaultizeAxis } from "./defaultizeAxis.mjs";
8
8
  import { selectorChartsInteractionIsInitialized } from "../useChartInteraction/index.mjs";
9
9
  import { selectorChartPolarCenter, selectorChartRadiusAxis, selectorChartRotationAxis } from "./useChartPolarAxis.selectors.mjs";
10
10
  import { getChartPoint } from "../../../getChartPoint.mjs";
11
- import { generatePolar2svg, generateSvg2polar, generateSvg2rotation } from "./coordinateTransformation.mjs";
12
- import { getRotationAxisIndex } from "./getAxisIndex.mjs";
11
+ import { generatePolar2svg, generateSvg2polar, generateSvg2radius, generateSvg2rotation } from "./coordinateTransformation.mjs";
12
+ import { getRadiusAxisIndex, getRotationAxisIndex } from "./getAxisIndex.mjs";
13
13
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.mjs";
14
14
  import { checkHasInteractionPlugin } from "../useChartInteraction/checkHasInteractionPlugin.mjs";
15
+ import { isPolarSeriesType } from "../../../isPolar.mjs";
15
16
  export const useChartPolarAxis = ({
16
17
  params,
17
18
  store,
@@ -171,9 +172,10 @@ export const useChartPolarAxis = ({
171
172
  const svgPoint = getChartPoint(element, event.detail.srcEvent);
172
173
  const rotation = generateSvg2rotation(center)(svgPoint.x, svgPoint.y);
173
174
  const rotationIndex = getRotationAxisIndex(rotationAxisWithScale[usedRotationAxisId], rotation);
175
+ const radius = generateSvg2radius(center)(svgPoint.x, svgPoint.y);
176
+ const radiusIndex = getRadiusAxisIndex(radiusAxisWithScale[usedRadiusAxisId], radius);
174
177
  isRotationAxis = rotationIndex !== -1;
175
- dataIndex = isRotationAxis ? rotationIndex : null; // radius index is not yet implemented.
176
-
178
+ dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
177
179
  const USED_AXIS_ID = isRotationAxis ? usedRotationAxisId : usedRadiusAxisId;
178
180
  if (dataIndex == null || dataIndex === -1) {
179
181
  return;
@@ -182,7 +184,7 @@ export const useChartPolarAxis = ({
182
184
  // The .data exist because otherwise the dataIndex would be null or -1.
183
185
  const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
184
186
  const seriesValues = {};
185
- Object.keys(processedSeries).filter(seriesType => seriesType === 'radar').forEach(seriesType => {
187
+ Object.keys(processedSeries).filter(isPolarSeriesType).forEach(seriesType => {
186
188
  processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
187
189
  const seriesItem = processedSeries[seriesType].series[seriesId];
188
190
  seriesValues[seriesId] = seriesItem.data[dataIndex];
@@ -11,6 +11,7 @@ var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/form
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _colorScale = require("../../../colorScale");
14
+ var _sizeScale = require("../../../sizeScale");
14
15
  function addDefaultId(axisConfig, defaultId) {
15
16
  if (axisConfig.id !== undefined) {
16
17
  return axisConfig;
@@ -32,6 +33,19 @@ function processColorMap(axisConfig) {
32
33
  }, axisConfig.colorMap) : axisConfig.colorMap)
33
34
  });
34
35
  }
36
+ function processSizeMap(axisConfig) {
37
+ if (!axisConfig.sizeMap) {
38
+ return axisConfig;
39
+ }
40
+ return (0, _extends2.default)({}, axisConfig, {
41
+ sizeScale: axisConfig.sizeMap.type === 'ordinal' ? (0, _sizeScale.getOrdinalSizeScale)((0, _extends2.default)({
42
+ values: axisConfig.data
43
+ }, axisConfig.sizeMap)) : (0, _sizeScale.getSizeScale)(axisConfig.sizeMap.type === 'continuous' ? (0, _extends2.default)({
44
+ min: axisConfig.min,
45
+ max: axisConfig.max
46
+ }, axisConfig.sizeMap) : axisConfig.sizeMap)
47
+ });
48
+ }
35
49
  function getZAxisState(zAxis, dataset) {
36
50
  if (!zAxis || zAxis.length === 0) {
37
51
  return {
@@ -45,16 +59,16 @@ function getZAxisState(zAxis, dataset) {
45
59
  const dataKey = axisConfig.dataKey;
46
60
  const defaultizedId = axisConfig.id ?? `defaultized-z-axis-${index}`;
47
61
  if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
48
- zAxisLookup[defaultizedId] = processColorMap(addDefaultId(axisConfig, defaultizedId));
62
+ zAxisLookup[defaultizedId] = processSizeMap(processColorMap(addDefaultId(axisConfig, defaultizedId)));
49
63
  axisIds.push(defaultizedId);
50
64
  return;
51
65
  }
52
66
  if (dataset === undefined) {
53
67
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The z-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the z-axis.' : (0, _formatErrorMessage2.default)(41));
54
68
  }
55
- zAxisLookup[defaultizedId] = processColorMap(addDefaultId((0, _extends2.default)({}, axisConfig, {
69
+ zAxisLookup[defaultizedId] = processSizeMap(processColorMap(addDefaultId((0, _extends2.default)({}, axisConfig, {
56
70
  data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
57
- }), defaultizedId));
71
+ }), defaultizedId)));
58
72
  axisIds.push(defaultizedId);
59
73
  });
60
74
  return {
@@ -4,6 +4,7 @@ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  import * as React from 'react';
6
6
  import { getColorScale, getOrdinalColorScale } from "../../../colorScale.mjs";
7
+ import { getSizeScale, getOrdinalSizeScale } from "../../../sizeScale.mjs";
7
8
  function addDefaultId(axisConfig, defaultId) {
8
9
  if (axisConfig.id !== undefined) {
9
10
  return axisConfig;
@@ -25,6 +26,19 @@ function processColorMap(axisConfig) {
25
26
  }, axisConfig.colorMap) : axisConfig.colorMap)
26
27
  });
27
28
  }
29
+ function processSizeMap(axisConfig) {
30
+ if (!axisConfig.sizeMap) {
31
+ return axisConfig;
32
+ }
33
+ return _extends({}, axisConfig, {
34
+ sizeScale: axisConfig.sizeMap.type === 'ordinal' ? getOrdinalSizeScale(_extends({
35
+ values: axisConfig.data
36
+ }, axisConfig.sizeMap)) : getSizeScale(axisConfig.sizeMap.type === 'continuous' ? _extends({
37
+ min: axisConfig.min,
38
+ max: axisConfig.max
39
+ }, axisConfig.sizeMap) : axisConfig.sizeMap)
40
+ });
41
+ }
28
42
  function getZAxisState(zAxis, dataset) {
29
43
  if (!zAxis || zAxis.length === 0) {
30
44
  return {
@@ -38,16 +52,16 @@ function getZAxisState(zAxis, dataset) {
38
52
  const dataKey = axisConfig.dataKey;
39
53
  const defaultizedId = axisConfig.id ?? `defaultized-z-axis-${index}`;
40
54
  if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
41
- zAxisLookup[defaultizedId] = processColorMap(addDefaultId(axisConfig, defaultizedId));
55
+ zAxisLookup[defaultizedId] = processSizeMap(processColorMap(addDefaultId(axisConfig, defaultizedId)));
42
56
  axisIds.push(defaultizedId);
43
57
  return;
44
58
  }
45
59
  if (dataset === undefined) {
46
60
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The z-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the z-axis.' : _formatErrorMessage(41));
47
61
  }
48
- zAxisLookup[defaultizedId] = processColorMap(addDefaultId(_extends({}, axisConfig, {
62
+ zAxisLookup[defaultizedId] = processSizeMap(processColorMap(addDefaultId(_extends({}, axisConfig, {
49
63
  data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
50
- }), defaultizedId));
64
+ }), defaultizedId)));
51
65
  axisIds.push(defaultizedId);
52
66
  });
53
67
  return {
@@ -0,0 +1,6 @@
1
+ import { type ChartSeriesType, type DatasetType } from "../models/seriesType/config.mjs";
2
+ import type { SeriesProcessorParams, SeriesProcessorResult } from "./plugins/corePlugins/useChartSeriesConfig/index.mjs";
3
+ import type { IsItemVisibleFunction } from "./plugins/featurePlugins/useChartVisibilityManager/index.mjs";
4
+ type LineLikeChartType = Extract<ChartSeriesType, 'line' | 'radialLine'>;
5
+ export declare function processLineLikeSeries<SeriesType extends LineLikeChartType>(params: SeriesProcessorParams<SeriesType>, dataset: Readonly<DatasetType> | undefined, isItemVisible: IsItemVisibleFunction | undefined, seriesType: SeriesType): SeriesProcessorResult<SeriesType>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ChartSeriesType, type DatasetType } from "../models/seriesType/config.js";
2
+ import type { SeriesProcessorParams, SeriesProcessorResult } from "./plugins/corePlugins/useChartSeriesConfig/index.js";
3
+ import type { IsItemVisibleFunction } from "./plugins/featurePlugins/useChartVisibilityManager/index.js";
4
+ type LineLikeChartType = Extract<ChartSeriesType, 'line' | 'radialLine'>;
5
+ export declare function processLineLikeSeries<SeriesType extends LineLikeChartType>(params: SeriesProcessorParams<SeriesType>, dataset: Readonly<DatasetType> | undefined, isItemVisible: IsItemVisibleFunction | undefined, seriesType: SeriesType): SeriesProcessorResult<SeriesType>;
6
+ export {};
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.processLineLikeSeries = processLineLikeSeries;
8
+ var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
11
+ var _warning = require("@mui/x-internals/warning");
12
+ var _stacking = require("./stacking");
13
+ const defaultShapes = ['circle', 'square', 'diamond', 'cross', 'star', 'triangle', 'wye'];
14
+ const lineValueFormatter = v => v == null ? '' : v.toLocaleString();
15
+ function processLineLikeSeries(params, dataset, isItemVisible, seriesType) {
16
+ const {
17
+ seriesOrder,
18
+ series
19
+ } = params;
20
+ const stackingGroups = (0, _stacking.getStackingGroups)((0, _extends2.default)({}, params, {
21
+ defaultStrategy: {
22
+ stackOffset: 'none'
23
+ }
24
+ }));
25
+ const idToIndex = new Map();
26
+ const d3Dataset = dataset ?? [];
27
+ seriesOrder.forEach((id, seriesIndex) => {
28
+ idToIndex.set(id, seriesIndex);
29
+ const data = series[id].data;
30
+ if (data !== undefined) {
31
+ data.forEach((value, dataIndex) => {
32
+ if (d3Dataset.length <= dataIndex) {
33
+ d3Dataset.push({
34
+ [id]: value
35
+ });
36
+ } else {
37
+ d3Dataset[dataIndex][id] = value;
38
+ }
39
+ });
40
+ } else if (series[id].valueGetter && dataset) {
41
+ dataset.forEach((entry, dataIndex) => {
42
+ const value = series[id].valueGetter(entry);
43
+ if (d3Dataset.length <= dataIndex) {
44
+ d3Dataset.push({
45
+ [id]: value
46
+ });
47
+ } else {
48
+ d3Dataset[dataIndex][id] = value;
49
+ }
50
+ });
51
+ } else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
52
+ const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
53
+ // TODO: fix mui/no-guarded-throw
54
+ // eslint-disable-next-line mui/no-guarded-throw
55
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${titleCase} series with id="${id}" has no data. ` + 'The chart cannot render this series without data. ' + 'Provide a data property to the series or use the dataset prop.' : (0, _formatErrorMessage2.default)(276, titleCase, id));
56
+ }
57
+ if (process.env.NODE_ENV !== 'production') {
58
+ if (!data && dataset) {
59
+ const dataKey = series[id].dataKey;
60
+ if (!dataKey && !series[id].valueGetter) {
61
+ const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
62
+ // TODO: fix mui/no-guarded-throw
63
+ // eslint-disable-next-line mui/no-guarded-throw
64
+ throw new Error(`MUI X Charts: ${titleCase} series with id="${id}" has no data, no dataKey, and no valueGetter. ` + 'When using the dataset prop, each series must have a dataKey or valueGetter to identify which dataset values to use. ' + 'Add a dataKey or valueGetter property to the series configuration.');
65
+ }
66
+ if (dataKey) {
67
+ const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
68
+ const lowerCase = seriesType === 'line' ? 'lines' : 'radial lines';
69
+ dataset.forEach((entry, index) => {
70
+ const value = entry[dataKey];
71
+ if (value != null && typeof value !== 'number') {
72
+ (0, _warning.warnOnce)(`MUI X Charts: your dataset key "${dataKey}" is used for plotting ${lowerCase}, but the dataset contains the non-null non-numerical element "${value}" at index ${index}.
73
+ ${titleCase} plots only support numeric and null values.`);
74
+ }
75
+ });
76
+ }
77
+ }
78
+ }
79
+ });
80
+ const completedSeries = {};
81
+ stackingGroups.forEach(stackingGroup => {
82
+ const {
83
+ ids,
84
+ stackingOffset,
85
+ stackingOrder
86
+ } = stackingGroup;
87
+ const keys = ids.map(id => {
88
+ const dataKey = series[id].dataKey;
89
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
90
+ });
91
+ const stackedData = (0, _d3Shape.stack)().keys(keys).value((d, key) => d[key] ?? 0).order(stackingOrder).offset(stackingOffset)(d3Dataset);
92
+ const idOrder = stackedData.map(s => s.index);
93
+ const fixedOrder = () => idOrder;
94
+ const visibleStackedData = (0, _d3Shape.stack)().keys(keys).value((d, key) => {
95
+ const keyIndex = keys.indexOf(key);
96
+ const seriesId = ids[keyIndex];
97
+ if (!isItemVisible?.({
98
+ type: seriesType,
99
+ seriesId
100
+ })) {
101
+ return 0;
102
+ }
103
+ return d[key] ?? 0;
104
+ }).order(fixedOrder).offset(stackingOffset)(d3Dataset);
105
+ ids.forEach((id, index) => {
106
+ const {
107
+ dataKey,
108
+ valueGetter
109
+ } = series[id];
110
+ let data;
111
+ if (valueGetter) {
112
+ data = dataset.map(d => valueGetter(d));
113
+ } else if (dataKey) {
114
+ data = dataset.map(d => {
115
+ const value = d[dataKey];
116
+ return typeof value === 'number' ? value : null;
117
+ });
118
+ } else {
119
+ data = series[id].data;
120
+ }
121
+ const hidden = !isItemVisible?.({
122
+ type: seriesType,
123
+ seriesId: id
124
+ });
125
+ // SAFETY: 'line' and 'radialLine' series inputs are structurally identical for the
126
+ // fields needed to build the defaultized series result. The differing axis-ID fields
127
+ // are passed through via spread without being read.
128
+ completedSeries[id] = (0, _extends2.default)({
129
+ labelMarkType: 'line+mark'
130
+ }, series[id], {
131
+ shape: series[id].shape ?? defaultShapes[(idToIndex.get(id) ?? 0) % defaultShapes.length],
132
+ data,
133
+ valueFormatter: series[id].valueFormatter ?? lineValueFormatter,
134
+ hidden,
135
+ stackedData: stackedData[index],
136
+ visibleStackedData: visibleStackedData[index]
137
+ });
138
+ });
139
+ });
140
+ return {
141
+ seriesOrder,
142
+ stackingGroups,
143
+ series: completedSeries
144
+ };
145
+ }
@@ -0,0 +1,138 @@
1
+ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
4
+ import { warnOnce } from '@mui/x-internals/warning';
5
+ import { getStackingGroups } from "./stacking/index.mjs";
6
+ const defaultShapes = ['circle', 'square', 'diamond', 'cross', 'star', 'triangle', 'wye'];
7
+ const lineValueFormatter = v => v == null ? '' : v.toLocaleString();
8
+ export function processLineLikeSeries(params, dataset, isItemVisible, seriesType) {
9
+ const {
10
+ seriesOrder,
11
+ series
12
+ } = params;
13
+ const stackingGroups = getStackingGroups(_extends({}, params, {
14
+ defaultStrategy: {
15
+ stackOffset: 'none'
16
+ }
17
+ }));
18
+ const idToIndex = new Map();
19
+ const d3Dataset = dataset ?? [];
20
+ seriesOrder.forEach((id, seriesIndex) => {
21
+ idToIndex.set(id, seriesIndex);
22
+ const data = series[id].data;
23
+ if (data !== undefined) {
24
+ data.forEach((value, dataIndex) => {
25
+ if (d3Dataset.length <= dataIndex) {
26
+ d3Dataset.push({
27
+ [id]: value
28
+ });
29
+ } else {
30
+ d3Dataset[dataIndex][id] = value;
31
+ }
32
+ });
33
+ } else if (series[id].valueGetter && dataset) {
34
+ dataset.forEach((entry, dataIndex) => {
35
+ const value = series[id].valueGetter(entry);
36
+ if (d3Dataset.length <= dataIndex) {
37
+ d3Dataset.push({
38
+ [id]: value
39
+ });
40
+ } else {
41
+ d3Dataset[dataIndex][id] = value;
42
+ }
43
+ });
44
+ } else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
45
+ const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
46
+ // TODO: fix mui/no-guarded-throw
47
+ // eslint-disable-next-line mui/no-guarded-throw
48
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${titleCase} series with id="${id}" has no data. ` + 'The chart cannot render this series without data. ' + 'Provide a data property to the series or use the dataset prop.' : _formatErrorMessage(276, titleCase, id));
49
+ }
50
+ if (process.env.NODE_ENV !== 'production') {
51
+ if (!data && dataset) {
52
+ const dataKey = series[id].dataKey;
53
+ if (!dataKey && !series[id].valueGetter) {
54
+ const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
55
+ // TODO: fix mui/no-guarded-throw
56
+ // eslint-disable-next-line mui/no-guarded-throw
57
+ throw new Error(`MUI X Charts: ${titleCase} series with id="${id}" has no data, no dataKey, and no valueGetter. ` + 'When using the dataset prop, each series must have a dataKey or valueGetter to identify which dataset values to use. ' + 'Add a dataKey or valueGetter property to the series configuration.');
58
+ }
59
+ if (dataKey) {
60
+ const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
61
+ const lowerCase = seriesType === 'line' ? 'lines' : 'radial lines';
62
+ dataset.forEach((entry, index) => {
63
+ const value = entry[dataKey];
64
+ if (value != null && typeof value !== 'number') {
65
+ warnOnce(`MUI X Charts: your dataset key "${dataKey}" is used for plotting ${lowerCase}, but the dataset contains the non-null non-numerical element "${value}" at index ${index}.
66
+ ${titleCase} plots only support numeric and null values.`);
67
+ }
68
+ });
69
+ }
70
+ }
71
+ }
72
+ });
73
+ const completedSeries = {};
74
+ stackingGroups.forEach(stackingGroup => {
75
+ const {
76
+ ids,
77
+ stackingOffset,
78
+ stackingOrder
79
+ } = stackingGroup;
80
+ const keys = ids.map(id => {
81
+ const dataKey = series[id].dataKey;
82
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
83
+ });
84
+ const stackedData = d3Stack().keys(keys).value((d, key) => d[key] ?? 0).order(stackingOrder).offset(stackingOffset)(d3Dataset);
85
+ const idOrder = stackedData.map(s => s.index);
86
+ const fixedOrder = () => idOrder;
87
+ const visibleStackedData = d3Stack().keys(keys).value((d, key) => {
88
+ const keyIndex = keys.indexOf(key);
89
+ const seriesId = ids[keyIndex];
90
+ if (!isItemVisible?.({
91
+ type: seriesType,
92
+ seriesId
93
+ })) {
94
+ return 0;
95
+ }
96
+ return d[key] ?? 0;
97
+ }).order(fixedOrder).offset(stackingOffset)(d3Dataset);
98
+ ids.forEach((id, index) => {
99
+ const {
100
+ dataKey,
101
+ valueGetter
102
+ } = series[id];
103
+ let data;
104
+ if (valueGetter) {
105
+ data = dataset.map(d => valueGetter(d));
106
+ } else if (dataKey) {
107
+ data = dataset.map(d => {
108
+ const value = d[dataKey];
109
+ return typeof value === 'number' ? value : null;
110
+ });
111
+ } else {
112
+ data = series[id].data;
113
+ }
114
+ const hidden = !isItemVisible?.({
115
+ type: seriesType,
116
+ seriesId: id
117
+ });
118
+ // SAFETY: 'line' and 'radialLine' series inputs are structurally identical for the
119
+ // fields needed to build the defaultized series result. The differing axis-ID fields
120
+ // are passed through via spread without being read.
121
+ completedSeries[id] = _extends({
122
+ labelMarkType: 'line+mark'
123
+ }, series[id], {
124
+ shape: series[id].shape ?? defaultShapes[(idToIndex.get(id) ?? 0) % defaultShapes.length],
125
+ data,
126
+ valueFormatter: series[id].valueFormatter ?? lineValueFormatter,
127
+ hidden,
128
+ stackedData: stackedData[index],
129
+ visibleStackedData: visibleStackedData[index]
130
+ });
131
+ });
132
+ });
133
+ return {
134
+ seriesOrder,
135
+ stackingGroups,
136
+ series: completedSeries
137
+ };
138
+ }
@@ -0,0 +1,11 @@
1
+ import type { DefaultizedSeriesType } from "../models/seriesType/index.mjs";
2
+ import type { ChartSeriesType } from "../models/seriesType/config.mjs";
3
+ type LineOrBarSeriesType = Extract<ChartSeriesType, 'line' | 'bar' | 'radialLine' | 'radialBar'>;
4
+ export interface ResolveColorProcessorParams<SeriesType extends LineOrBarSeriesType, V> {
5
+ series: Pick<DefaultizedSeriesType<SeriesType>, 'color' | 'data' | 'colorGetter'>;
6
+ valueColorScale?: (value: number) => string | null;
7
+ categoryColorScale?: (value: V) => string | null;
8
+ categoryValues?: readonly V[];
9
+ }
10
+ export declare function resolveColorProcessor<SeriesType extends LineOrBarSeriesType, V>(params: ResolveColorProcessorParams<SeriesType, V>): (dataIndex?: number) => string;
11
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { DefaultizedSeriesType } from "../models/seriesType/index.js";
2
+ import type { ChartSeriesType } from "../models/seriesType/config.js";
3
+ type LineOrBarSeriesType = Extract<ChartSeriesType, 'line' | 'bar' | 'radialLine' | 'radialBar'>;
4
+ export interface ResolveColorProcessorParams<SeriesType extends LineOrBarSeriesType, V> {
5
+ series: Pick<DefaultizedSeriesType<SeriesType>, 'color' | 'data' | 'colorGetter'>;
6
+ valueColorScale?: (value: number) => string | null;
7
+ categoryColorScale?: (value: V) => string | null;
8
+ categoryValues?: readonly V[];
9
+ }
10
+ export declare function resolveColorProcessor<SeriesType extends LineOrBarSeriesType, V>(params: ResolveColorProcessorParams<SeriesType, V>): (dataIndex?: number) => string;
11
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveColorProcessor = resolveColorProcessor;
7
+ var _getSeriesColorFn = require("./getSeriesColorFn");
8
+ function resolveColorProcessor(params) {
9
+ const {
10
+ series,
11
+ valueColorScale,
12
+ categoryColorScale,
13
+ categoryValues
14
+ } = params;
15
+ const getSeriesColor = (0, _getSeriesColorFn.getSeriesColorFn)(series);
16
+ if (valueColorScale) {
17
+ return dataIndex => {
18
+ if (dataIndex === undefined) {
19
+ return series.color;
20
+ }
21
+ const value = series.data[dataIndex];
22
+ const color = value === null ? getSeriesColor({
23
+ value,
24
+ dataIndex
25
+ }) : valueColorScale(value);
26
+ if (color === null) {
27
+ return getSeriesColor({
28
+ value,
29
+ dataIndex
30
+ });
31
+ }
32
+ return color;
33
+ };
34
+ }
35
+ if (categoryColorScale && categoryValues) {
36
+ return dataIndex => {
37
+ if (dataIndex === undefined) {
38
+ return series.color;
39
+ }
40
+ const value = categoryValues[dataIndex];
41
+ const fallbackValue = {
42
+ value: series.data[dataIndex],
43
+ dataIndex
44
+ };
45
+ const color = value === null ? getSeriesColor(fallbackValue) : categoryColorScale(value);
46
+ if (color === null) {
47
+ return getSeriesColor(fallbackValue);
48
+ }
49
+ return color;
50
+ };
51
+ }
52
+ return dataIndex => {
53
+ if (dataIndex === undefined) {
54
+ return series.color;
55
+ }
56
+ const value = series.data[dataIndex];
57
+ return getSeriesColor({
58
+ value,
59
+ dataIndex
60
+ });
61
+ };
62
+ }
@@ -0,0 +1,56 @@
1
+ import { getSeriesColorFn } from "./getSeriesColorFn.mjs";
2
+ export function resolveColorProcessor(params) {
3
+ const {
4
+ series,
5
+ valueColorScale,
6
+ categoryColorScale,
7
+ categoryValues
8
+ } = params;
9
+ const getSeriesColor = getSeriesColorFn(series);
10
+ if (valueColorScale) {
11
+ return dataIndex => {
12
+ if (dataIndex === undefined) {
13
+ return series.color;
14
+ }
15
+ const value = series.data[dataIndex];
16
+ const color = value === null ? getSeriesColor({
17
+ value,
18
+ dataIndex
19
+ }) : valueColorScale(value);
20
+ if (color === null) {
21
+ return getSeriesColor({
22
+ value,
23
+ dataIndex
24
+ });
25
+ }
26
+ return color;
27
+ };
28
+ }
29
+ if (categoryColorScale && categoryValues) {
30
+ return dataIndex => {
31
+ if (dataIndex === undefined) {
32
+ return series.color;
33
+ }
34
+ const value = categoryValues[dataIndex];
35
+ const fallbackValue = {
36
+ value: series.data[dataIndex],
37
+ dataIndex
38
+ };
39
+ const color = value === null ? getSeriesColor(fallbackValue) : categoryColorScale(value);
40
+ if (color === null) {
41
+ return getSeriesColor(fallbackValue);
42
+ }
43
+ return color;
44
+ };
45
+ }
46
+ return dataIndex => {
47
+ if (dataIndex === undefined) {
48
+ return series.color;
49
+ }
50
+ const value = series.data[dataIndex];
51
+ return getSeriesColor({
52
+ value,
53
+ dataIndex
54
+ });
55
+ };
56
+ }
@@ -0,0 +1,6 @@
1
+ import { type ScaleOrdinal, type ScaleThreshold, type ScaleSequential } from '@mui/x-charts-vendor/d3-scale';
2
+ import { type ContinuousSizeConfig, type PiecewiseSizeConfig, type OrdinalSizeConfig } from "../models/sizeMapping.mjs";
3
+ export declare function getSequentialSizeScale<Value extends number | Date>(config: ContinuousSizeConfig<Value> | PiecewiseSizeConfig<Value>): ScaleThreshold<Value, number, never> | ScaleSequential<number, never>;
4
+ export declare function getOrdinalSizeScale(config: OrdinalSizeConfig): ScaleOrdinal<number | Date | string, number, number | null>;
5
+ export declare function getSizeScale(config: OrdinalSizeConfig): ScaleOrdinal<number | Date | string, number, number | null>;
6
+ export declare function getSizeScale(config: ContinuousSizeConfig | PiecewiseSizeConfig): ScaleThreshold<number | Date, number | null> | ScaleSequential<number, number | null>;
@@ -0,0 +1,6 @@
1
+ import { type ScaleOrdinal, type ScaleThreshold, type ScaleSequential } from '@mui/x-charts-vendor/d3-scale';
2
+ import { type ContinuousSizeConfig, type PiecewiseSizeConfig, type OrdinalSizeConfig } from "../models/sizeMapping.js";
3
+ export declare function getSequentialSizeScale<Value extends number | Date>(config: ContinuousSizeConfig<Value> | PiecewiseSizeConfig<Value>): ScaleThreshold<Value, number, never> | ScaleSequential<number, never>;
4
+ export declare function getOrdinalSizeScale(config: OrdinalSizeConfig): ScaleOrdinal<number | Date | string, number, number | null>;
5
+ export declare function getSizeScale(config: OrdinalSizeConfig): ScaleOrdinal<number | Date | string, number, number | null>;
6
+ export declare function getSizeScale(config: ContinuousSizeConfig | PiecewiseSizeConfig): ScaleThreshold<number | Date, number | null> | ScaleSequential<number, number | null>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getOrdinalSizeScale = getOrdinalSizeScale;
7
+ exports.getSequentialSizeScale = getSequentialSizeScale;
8
+ exports.getSizeScale = getSizeScale;
9
+ var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
10
+ const isFunctionInterpolator = config => {
11
+ return typeof config.size === 'function';
12
+ };
13
+ function getClampedSize(sizes) {
14
+ const [minSize, maxSize] = sizes;
15
+ return t => {
16
+ const clampedT = Math.max(Math.min(t, 1), 0);
17
+ return minSize + clampedT * (maxSize - minSize);
18
+ };
19
+ }
20
+ function getSequentialSizeScale(config) {
21
+ if (config.type === 'piecewise') {
22
+ return (0, _d3Scale.scaleThreshold)(config.thresholds, config.sizes);
23
+ }
24
+ if (isFunctionInterpolator(config)) {
25
+ return (0, _d3Scale.scaleSequential)([config.min ?? 0, config.max ?? 100], config.size);
26
+ }
27
+ const interpolator = config.interpolator ?? 'sqrt';
28
+ switch (interpolator) {
29
+ case 'log':
30
+ return (0, _d3Scale.scaleSequentialLog)([config.min ?? 0, config.max ?? 100], getClampedSize(config.size));
31
+ case 'linear':
32
+ return (0, _d3Scale.scaleSequential)([config.min ?? 0, config.max ?? 100], getClampedSize(config.size));
33
+ case 'sqrt':
34
+ default:
35
+ return (0, _d3Scale.scaleSequentialSqrt)([config.min ?? 0, config.max ?? 100], getClampedSize(config.size));
36
+ }
37
+ }
38
+ function getOrdinalSizeScale(config) {
39
+ if (config.values) {
40
+ return (0, _d3Scale.scaleOrdinal)(config.values, config.sizes).unknown(config.unknownSize ?? null);
41
+ }
42
+ return (0, _d3Scale.scaleOrdinal)(config.sizes.map((_, index) => index), config.sizes).unknown(config.unknownSize ?? null);
43
+ }
44
+ function getSizeScale(config) {
45
+ return config.type === 'ordinal' ? getOrdinalSizeScale(config) : getSequentialSizeScale(config);
46
+ }