@mui/x-charts 8.8.0 → 8.9.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 (164) hide show
  1. package/BarChart/BarChart.d.ts +3 -2
  2. package/BarChart/BarChart.js +95 -2
  3. package/BarChart/BarClipPath.d.ts +17 -12
  4. package/BarChart/BarClipPath.js +70 -57
  5. package/BarChart/BarPlot.js +4 -0
  6. package/BarChart/barClasses.d.ts +1 -1
  7. package/BarChart/seriesConfig/extremums.js +2 -3
  8. package/BarChart/seriesConfig/seriesProcessor.js +5 -3
  9. package/BarChart/useBarChartProps.d.ts +1 -1
  10. package/BarChart/useBarPlotData.js +32 -5
  11. package/CHANGELOG.md +225 -24
  12. package/ChartContainer/ChartContainer.js +141 -0
  13. package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
  14. package/ChartsLabel/index.d.ts +1 -0
  15. package/ChartsLabel/index.js +18 -0
  16. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  17. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  18. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  19. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
  20. package/LineChart/LineChart.d.ts +3 -2
  21. package/LineChart/LineChart.js +95 -2
  22. package/LineChart/seriesConfig/extremums.js +2 -3
  23. package/LineChart/useLineChartProps.d.ts +1 -1
  24. package/PieChart/PieArcLabelPlot.js +3 -0
  25. package/PieChart/PieArcPlot.js +3 -0
  26. package/PieChart/PieChart.d.ts +3 -2
  27. package/PieChart/PieChart.js +2 -2
  28. package/PieChart/pieClasses.d.ts +1 -1
  29. package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
  30. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
  31. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
  32. package/RadarChart/RadarChart.d.ts +3 -2
  33. package/RadarChart/RadarChart.js +24 -3
  34. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
  35. package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
  36. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
  37. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
  38. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
  39. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
  40. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
  41. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
  42. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  43. package/RadarChart/index.d.ts +1 -1
  44. package/RadarChart/useRadarChartProps.d.ts +4 -1
  45. package/RadarChart/useRadarChartProps.js +15 -3
  46. package/ScatterChart/ScatterChart.d.ts +3 -2
  47. package/ScatterChart/ScatterChart.js +95 -2
  48. package/ScatterChart/seriesConfig/extremums.js +50 -23
  49. package/ScatterChart/useScatterChartProps.d.ts +1 -1
  50. package/SparkLineChart/SparkLineChart.js +93 -0
  51. package/esm/BarChart/BarChart.d.ts +3 -2
  52. package/esm/BarChart/BarChart.js +95 -2
  53. package/esm/BarChart/BarClipPath.d.ts +17 -12
  54. package/esm/BarChart/BarClipPath.js +69 -55
  55. package/esm/BarChart/BarPlot.js +4 -0
  56. package/esm/BarChart/barClasses.d.ts +1 -1
  57. package/esm/BarChart/seriesConfig/extremums.js +2 -3
  58. package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
  59. package/esm/BarChart/useBarChartProps.d.ts +1 -1
  60. package/esm/BarChart/useBarPlotData.js +32 -5
  61. package/esm/ChartContainer/ChartContainer.js +141 -0
  62. package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
  63. package/esm/ChartsLabel/index.d.ts +1 -0
  64. package/esm/ChartsLabel/index.js +1 -0
  65. package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  66. package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  67. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  68. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +31 -6
  69. package/esm/LineChart/LineChart.d.ts +3 -2
  70. package/esm/LineChart/LineChart.js +95 -2
  71. package/esm/LineChart/seriesConfig/extremums.js +2 -3
  72. package/esm/LineChart/useLineChartProps.d.ts +1 -1
  73. package/esm/PieChart/PieArcLabelPlot.js +3 -0
  74. package/esm/PieChart/PieArcPlot.js +3 -0
  75. package/esm/PieChart/PieChart.d.ts +3 -2
  76. package/esm/PieChart/PieChart.js +2 -2
  77. package/esm/PieChart/pieClasses.d.ts +1 -1
  78. package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
  79. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
  80. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
  81. package/esm/RadarChart/RadarChart.d.ts +3 -2
  82. package/esm/RadarChart/RadarChart.js +24 -3
  83. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
  84. package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
  85. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
  86. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
  87. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
  88. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
  89. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
  90. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
  91. package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  92. package/esm/RadarChart/index.d.ts +1 -1
  93. package/esm/RadarChart/useRadarChartProps.d.ts +4 -1
  94. package/esm/RadarChart/useRadarChartProps.js +15 -3
  95. package/esm/ScatterChart/ScatterChart.d.ts +3 -2
  96. package/esm/ScatterChart/ScatterChart.js +95 -2
  97. package/esm/ScatterChart/seriesConfig/extremums.js +50 -23
  98. package/esm/ScatterChart/useScatterChartProps.d.ts +1 -1
  99. package/esm/SparkLineChart/SparkLineChart.js +93 -0
  100. package/esm/hooks/useTicks.d.ts +6 -1
  101. package/esm/hooks/useTicks.js +94 -58
  102. package/esm/index.d.ts +2 -1
  103. package/esm/index.js +6 -2
  104. package/esm/internals/findMinMax.d.ts +1 -0
  105. package/esm/internals/findMinMax.js +13 -0
  106. package/esm/internals/getScale.js +3 -0
  107. package/esm/internals/index.d.ts +1 -1
  108. package/esm/internals/index.js +1 -1
  109. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -1
  110. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
  111. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
  112. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
  113. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
  114. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
  115. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
  116. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
  117. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
  118. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  119. package/esm/internals/symlogScale.d.ts +2 -0
  120. package/esm/internals/symlogScale.js +94 -0
  121. package/esm/models/axis.d.ts +47 -5
  122. package/esm/models/axis.js +3 -0
  123. package/esm/models/seriesType/bar.d.ts +11 -1
  124. package/esm/models/seriesType/common.d.ts +9 -3
  125. package/esm/models/seriesType/line.d.ts +3 -1
  126. package/esm/models/seriesType/scatter.d.ts +4 -1
  127. package/esm/tests/web-components.js +49 -0
  128. package/hooks/useTicks.d.ts +6 -1
  129. package/hooks/useTicks.js +95 -58
  130. package/index.d.ts +2 -1
  131. package/index.js +13 -1
  132. package/internals/findMinMax.d.ts +1 -0
  133. package/internals/findMinMax.js +19 -0
  134. package/internals/getScale.js +3 -0
  135. package/internals/index.d.ts +1 -1
  136. package/internals/index.js +12 -12
  137. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -0
  138. package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
  139. package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
  140. package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
  141. package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
  142. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
  143. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
  144. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
  145. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
  146. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  147. package/internals/symlogScale.d.ts +2 -0
  148. package/internals/symlogScale.js +100 -0
  149. package/models/axis.d.ts +47 -5
  150. package/models/axis.js +4 -0
  151. package/models/seriesType/bar.d.ts +11 -1
  152. package/models/seriesType/common.d.ts +9 -3
  153. package/models/seriesType/line.d.ts +3 -1
  154. package/models/seriesType/scatter.d.ts +4 -1
  155. package/package.json +6 -7
  156. package/tests/web-components.js +55 -0
  157. package/BarChart/getRadius.d.ts +0 -20
  158. package/BarChart/getRadius.js +0 -37
  159. package/esm/BarChart/getRadius.d.ts +0 -20
  160. package/esm/BarChart/getRadius.js +0 -30
  161. /package/{esm/internals/components/ChartsWrapper → ChartsWrapper}/index.d.ts +0 -0
  162. /package/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
  163. /package/{internals/components → esm}/ChartsWrapper/index.d.ts +0 -0
  164. /package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.scaleSymlog = scaleSymlog;
7
+ var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
8
+ function scaleSymlog(_domain, _range) {
9
+ const scale = (0, _d3Scale.scaleSymlog)(_domain, _range);
10
+ const originalTicks = scale.ticks;
11
+ const {
12
+ negativeScale,
13
+ linearScale,
14
+ positiveScale
15
+ } = generateScales(scale);
16
+
17
+ // Workaround for https://github.com/d3/d3-scale/issues/162
18
+ scale.ticks = count => {
19
+ const ticks = originalTicks(count);
20
+ const constant = scale.constant();
21
+ let negativeLogTickCount = 0;
22
+ let linearTickCount = 0;
23
+ let positiveLogTickCount = 0;
24
+ ticks.forEach(tick => {
25
+ if (tick > -constant && tick < constant) {
26
+ linearTickCount += 1;
27
+ }
28
+ if (tick <= -constant) {
29
+ negativeLogTickCount += 1;
30
+ }
31
+ if (tick >= constant) {
32
+ positiveLogTickCount += 1;
33
+ }
34
+ });
35
+ const finalTicks = [];
36
+ if (negativeLogTickCount > 0) {
37
+ finalTicks.push(...negativeScale.ticks(negativeLogTickCount));
38
+ }
39
+ if (linearTickCount > 0) {
40
+ const linearTicks = linearScale.ticks(linearTickCount);
41
+ if (finalTicks.at(-1) === linearTicks[0]) {
42
+ finalTicks.push(...linearTicks.slice(1));
43
+ } else {
44
+ finalTicks.push(...linearTicks);
45
+ }
46
+ }
47
+ if (positiveLogTickCount > 0) {
48
+ const positiveTicks = positiveScale.ticks(positiveLogTickCount);
49
+ if (finalTicks.at(-1) === positiveTicks[0]) {
50
+ finalTicks.push(...positiveTicks.slice(1));
51
+ } else {
52
+ finalTicks.push(...positiveTicks);
53
+ }
54
+ }
55
+ return finalTicks;
56
+ };
57
+ scale.tickFormat = (count = 10, specifier) => {
58
+ // Calculates the proportion of the domain that each scale occupies, and use that ratio to determine the number of ticks for each scale.
59
+ const constant = scale.constant();
60
+ const [start, end] = scale.domain();
61
+ const extent = end - start;
62
+ const negativeScaleDomain = negativeScale.domain();
63
+ const negativeScaleExtent = negativeScaleDomain[1] - negativeScaleDomain[0];
64
+ const negativeScaleRatio = extent === 0 ? 0 : negativeScaleExtent / extent;
65
+ const negativeScaleTickCount = negativeScaleRatio * count;
66
+ const linearScaleDomain = linearScale.domain();
67
+ const linearScaleExtent = linearScaleDomain[1] - linearScaleDomain[0];
68
+ const linearScaleRatio = extent === 0 ? 0 : linearScaleExtent / extent;
69
+ const linearScaleTickCount = linearScaleRatio * count;
70
+ const positiveScaleDomain = positiveScale.domain();
71
+ const positiveScaleExtent = positiveScaleDomain[1] - positiveScaleDomain[0];
72
+ const positiveScaleRatio = extent === 0 ? 0 : positiveScaleExtent / extent;
73
+ const positiveScaleTickCount = positiveScaleRatio * count;
74
+ const negativeTickFormat = negativeScale.tickFormat(negativeScaleTickCount, specifier);
75
+ const linearTickFormat = linearScale.tickFormat(linearScaleTickCount, specifier);
76
+ const positiveTickFormat = positiveScale.tickFormat(positiveScaleTickCount, specifier);
77
+ return tick => {
78
+ const tickFormat =
79
+ // eslint-disable-next-line no-nested-ternary
80
+ tick.valueOf() <= -constant ? negativeTickFormat : tick.valueOf() >= constant ? positiveTickFormat : linearTickFormat;
81
+ return tickFormat(tick);
82
+ };
83
+ };
84
+ return scale;
85
+ }
86
+ function generateScales(scale) {
87
+ const constant = scale.constant();
88
+ const domain = scale.domain();
89
+ const negativeDomain = [domain[0], Math.min(domain[1], -constant)];
90
+ const negativeLogScale = (0, _d3Scale.scaleLog)(negativeDomain, scale.range());
91
+ const linearDomain = [Math.max(domain[0], -constant), Math.min(domain[1], constant)];
92
+ const linearScale = (0, _d3Scale.scaleLinear)(linearDomain, scale.range());
93
+ const positiveDomain = [Math.max(domain[0], constant), domain[1]];
94
+ const positiveLogScale = (0, _d3Scale.scaleLog)(positiveDomain, scale.range());
95
+ return {
96
+ negativeScale: negativeLogScale,
97
+ linearScale,
98
+ positiveScale: positiveLogScale
99
+ };
100
+ }
package/models/axis.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleOrdinal, ScalePoint, ScalePower, ScaleSequential, ScaleThreshold, ScaleTime } from '@mui/x-charts-vendor/d3-scale';
1
+ import type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleOrdinal, ScalePoint, ScalePower, ScaleSequential, ScaleThreshold, ScaleTime, ScaleSymLog } from '@mui/x-charts-vendor/d3-scale';
2
2
  import { SxProps } from '@mui/system/styleFunctionSx';
3
3
  import { type MakeOptional, MakeRequired } from '@mui/x-internals/types';
4
4
  import type { DefaultizedZoomOptions } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
@@ -9,8 +9,8 @@ import { ContinuousColorConfig, OrdinalColorConfig, PiecewiseColorConfig } from
9
9
  export type AxisId = string | number;
10
10
  export type D3Scale<Domain extends {
11
11
  toString(): string;
12
- } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
13
- export type D3ContinuousScale<Range = number, Output = number> = ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
12
+ } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleSymLog<Range, Output> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
13
+ export type D3ContinuousScale<Range = number, Output = number> = ScaleSymLog<Range, Output> | ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
14
14
  export interface ChartsAxisSlots {
15
15
  /**
16
16
  * Custom component for the axis main line.
@@ -179,7 +179,7 @@ export interface ChartsRadiusAxisProps extends ChartsAxisProps {
179
179
  maxRadius?: number;
180
180
  }
181
181
  export type ScaleName = keyof AxisScaleConfig;
182
- export type ContinuousScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
182
+ export type ContinuousScaleName = 'linear' | 'log' | 'symlog' | 'pow' | 'sqrt' | 'time' | 'utc';
183
183
  export interface AxisScaleConfig {
184
184
  band: {
185
185
  scaleType: 'band';
@@ -208,6 +208,16 @@ export interface AxisScaleConfig {
208
208
  scale: ScaleLogarithmic<number, number>;
209
209
  colorMap?: ContinuousColorConfig | PiecewiseColorConfig;
210
210
  };
211
+ symlog: {
212
+ scaleType: 'symlog';
213
+ scale: ScaleSymLog<number, number>;
214
+ colorMap?: ContinuousColorConfig | PiecewiseColorConfig;
215
+ /**
216
+ * The constant used to define the zero point of the symlog scale.
217
+ * @default 1
218
+ */
219
+ constant?: number;
220
+ };
211
221
  pow: {
212
222
  scaleType: 'pow';
213
223
  scale: ScalePower<number, number>;
@@ -248,6 +258,9 @@ export interface AxisScaleComputedConfig {
248
258
  log: {
249
259
  colorScale?: ScaleSequential<string, string | null> | ScaleThreshold<number, string | null>;
250
260
  };
261
+ symlog: {
262
+ colorScale?: ScaleSequential<string, string | null> | ScaleThreshold<number, string | null>;
263
+ };
251
264
  pow: {
252
265
  colorScale?: ScaleSequential<string, string | null> | ScaleThreshold<number, string | null>;
253
266
  };
@@ -281,11 +294,37 @@ export type AxisValueFormatterContext<S extends ScaleName = ScaleName> = {
281
294
  * - `'legend'` The value is displayed in the legend when using color legend.
282
295
  * - `'zoom-slider-tooltip'` The value is displayed in the zoom slider tooltip.
283
296
  */
284
- location: 'tick' | 'tooltip' | 'zoom-slider-tooltip';
297
+ location: 'tooltip' | 'zoom-slider-tooltip';
285
298
  /**
286
299
  * The d3-scale instance associated to the axis.
287
300
  */
288
301
  scale: AxisScaleConfig[S]['scale'];
302
+ } | {
303
+ /**
304
+ * Location indicates where the value will be displayed.
305
+ * - `'tick'` The value is displayed on the axis ticks.
306
+ * - `'tooltip'` The value is displayed in the tooltip when hovering the chart.
307
+ * - `'legend'` The value is displayed in the legend when using color legend.
308
+ * - `'zoom-slider-tooltip'` The value is displayed in the zoom slider tooltip.
309
+ */
310
+ location: 'tick';
311
+ /**
312
+ * The d3-scale instance associated to the axis.
313
+ */
314
+ scale: AxisScaleConfig[S]['scale'];
315
+ /**
316
+ * The tick label shown by default if the value isn't formatted.
317
+ * This value might be an empty string if no tick label should be displayed, which is particularly useful in log
318
+ * scales where we want to show ticks to demonstrate it's a log scale, but not labels to avoid them overlapping.
319
+ * @see See {@link https://d3js.org/d3-scale/log#log_tickFormat D3 log scale docs} for more details.
320
+ */
321
+ defaultTickLabel: string;
322
+ /**
323
+ * A suggestion of the number of ticks to show.
324
+ * Can be provided to the scale's `ticks` method to compute the ticks, or to `tickFormat` to format the ticks.
325
+ * Can be `undefined` if the scale doesn't support it, e.g., band, point scales.
326
+ */
327
+ tickNumber?: number;
289
328
  };
290
329
  /**
291
330
  * Config that is shared between cartesian and polar axes.
@@ -391,6 +430,9 @@ export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): s
391
430
  export declare function isPointScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'point'> & {
392
431
  scaleType: 'point';
393
432
  };
433
+ export declare function isSymlogScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'symlog'> & {
434
+ scaleType: 'symlog';
435
+ };
394
436
  /**
395
437
  * The data format returned by onAxisClick.
396
438
  */
package/models/axis.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isBandScaleConfig = isBandScaleConfig;
7
7
  exports.isPointScaleConfig = isPointScaleConfig;
8
+ exports.isSymlogScaleConfig = isSymlogScaleConfig;
8
9
  /**
9
10
  * Use this type instead of `AxisScaleConfig` when the values
10
11
  * shouldn't be provided by the user.
@@ -24,6 +25,9 @@ function isBandScaleConfig(scaleConfig) {
24
25
  function isPointScaleConfig(scaleConfig) {
25
26
  return scaleConfig.scaleType === 'point';
26
27
  }
28
+ function isSymlogScaleConfig(scaleConfig) {
29
+ return scaleConfig.scaleType === 'symlog';
30
+ }
27
31
 
28
32
  /**
29
33
  * The data format returned by onAxisClick.
@@ -25,6 +25,16 @@ export interface BarSeriesType extends CommonSeriesType<number | null>, Cartesia
25
25
  * @default 'diverging'
26
26
  */
27
27
  stackOffset?: StackOffsetType;
28
+ /**
29
+ * If provided, the value will be used as the minimum size of the bar in pixels.
30
+ * This is useful to avoid bars with a size of 0.
31
+ *
32
+ * The property is ignored if the series value is `null` or `0`.
33
+ * It also doesn't work with stacked series.
34
+ *
35
+ * @default 0px
36
+ */
37
+ minBarSize?: number;
28
38
  }
29
39
  /**
30
40
  * An object that allows to identify a single bar.
@@ -35,4 +45,4 @@ export type BarItemIdentifier = {
35
45
  seriesId: SeriesId;
36
46
  dataIndex: number;
37
47
  };
38
- export interface DefaultizedBarSeriesType extends DefaultizedProps<BarSeriesType, CommonDefaultizedProps | 'color' | 'layout'> {}
48
+ export interface DefaultizedBarSeriesType extends DefaultizedProps<BarSeriesType, CommonDefaultizedProps | 'color' | 'layout' | 'minBarSize'> {}
@@ -1,6 +1,6 @@
1
- import type { ChartsLabelMarkProps } from "../../ChartsLabel/index.js";
2
1
  import { HighlightScope } from "../../internals/plugins/featurePlugins/useChartHighlight/highlightConfig.types.js";
3
2
  import type { StackOffsetType, StackOrderType } from "../stacking.js";
3
+ import type { ChartsLabelMarkType } from "../../ChartsLabel/ChartsLabelMark.js";
4
4
  export type SeriesId = number | string;
5
5
  export type SeriesValueFormatterContext = {
6
6
  /**
@@ -10,7 +10,13 @@ export type SeriesValueFormatterContext = {
10
10
  };
11
11
  export type SeriesValueFormatter<TValue> = (value: TValue, context: SeriesValueFormatterContext) => string | null;
12
12
  export type CommonSeriesType<TValue> = {
13
+ /**
14
+ * The id of this series.
15
+ */
13
16
  id?: SeriesId;
17
+ /**
18
+ * Color to use when displaying the series.
19
+ */
14
20
  color?: string;
15
21
  /**
16
22
  * Formatter used to render values in tooltip or other data display.
@@ -22,13 +28,13 @@ export type CommonSeriesType<TValue> = {
22
28
  /**
23
29
  * The scope to apply when the series is highlighted.
24
30
  */
25
- highlightScope?: Partial<HighlightScope>;
31
+ highlightScope?: HighlightScope;
26
32
  /**
27
33
  * Defines the mark type for the series.
28
34
  *
29
35
  * There is a default mark type for each series type.
30
36
  */
31
- labelMarkType?: ChartsLabelMarkProps['type'];
37
+ labelMarkType?: ChartsLabelMarkType;
32
38
  };
33
39
  export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';
34
40
  export type CartesianSeriesType = {
@@ -34,7 +34,9 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
34
34
  * The key used to retrieve data from the dataset.
35
35
  */
36
36
  dataKey?: string;
37
- stack?: string;
37
+ /**
38
+ * If `true`, the series is rendered as an area instead of a line.
39
+ */
38
40
  area?: boolean;
39
41
  /**
40
42
  * The label to display on the tooltip or the legend. It can be a string or a function.
@@ -12,6 +12,9 @@ export type ScatterValueType = {
12
12
  export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType | null>, CartesianSeriesType {
13
13
  type: 'scatter';
14
14
  data?: readonly ScatterValueType[];
15
+ /**
16
+ * Size of the markers in the scatter plot, in pixels.
17
+ */
15
18
  markerSize?: number;
16
19
  /**
17
20
  * The label to display on the tooltip or the legend. It can be a string or a function.
@@ -52,7 +55,7 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType | n
52
55
  };
53
56
  preview?: {
54
57
  /**
55
- * The size of the preview marker.
58
+ * The size of the preview marker in pixels.
56
59
  * @default 1
57
60
  */
58
61
  markerSize?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.8.0",
3
+ "version": "8.9.2",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of MUI X Charts components.",
6
6
  "main": "./index.js",
@@ -11,8 +11,7 @@
11
11
  "homepage": "https://mui.com/x/react-charts/",
12
12
  "sideEffects": false,
13
13
  "publishConfig": {
14
- "access": "public",
15
- "directory": "build"
14
+ "access": "public"
16
15
  },
17
16
  "keywords": [
18
17
  "react",
@@ -29,16 +28,16 @@
29
28
  "directory": "packages/x-charts"
30
29
  },
31
30
  "dependencies": {
32
- "@babel/runtime": "^7.27.6",
31
+ "@babel/runtime": "^7.28.2",
33
32
  "@mui/utils": "^7.2.0",
34
33
  "bezier-easing": "^2.1.0",
35
34
  "clsx": "^2.1.1",
36
35
  "prop-types": "^15.8.1",
37
36
  "reselect": "^5.1.1",
38
37
  "use-sync-external-store": "^1.5.0",
39
- "@mui/x-charts-vendor": "8.5.3",
40
- "@mui/x-internals": "8.8.0",
41
- "@mui/x-internal-gestures": "0.2.1"
38
+ "@mui/x-charts-vendor": "8.6.0",
39
+ "@mui/x-internal-gestures": "0.2.2",
40
+ "@mui/x-internals": "8.9.2"
42
41
  },
43
42
  "peerDependencies": {
44
43
  "@emotion/react": "^11.9.0",
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.reactToWebComponent = reactToWebComponent;
7
+ const renderSymbol = Symbol.for('render');
8
+ const connectedSymbol = Symbol.for('connected');
9
+ const contextSymbol = Symbol.for('context');
10
+ const propsSymbol = Symbol.for('props');
11
+
12
+ // This function creates a custom web component that wraps a React component.
13
+ // Adapted from https://github.com/bitovi/react-to-web-component/blob/b1372bfd7bc67fe49920db840f1ed9cf736b2724/packages/core/src/core.ts
14
+ function reactToWebComponent(ReactComponent, options, renderer) {
15
+ class ReactWebComponent extends HTMLElement {
16
+ static get observedAttributes() {
17
+ return [];
18
+ }
19
+ constructor() {
20
+ super();
21
+ this[connectedSymbol] = true;
22
+ this[contextSymbol] = void 0;
23
+ this[propsSymbol] = {};
24
+ this.container = void 0;
25
+ if (options.shadow) {
26
+ this.container = this.attachShadow({
27
+ mode: options.shadow
28
+ });
29
+ } else {
30
+ this.container = this;
31
+ }
32
+ this[propsSymbol].container = this.container;
33
+ }
34
+ connectedCallback() {
35
+ this[connectedSymbol] = true;
36
+ this[renderSymbol]();
37
+ }
38
+ disconnectedCallback() {
39
+ this[connectedSymbol] = false;
40
+ if (this[contextSymbol]) {
41
+ renderer.unmount(this[contextSymbol]);
42
+ }
43
+ delete this[contextSymbol];
44
+ }
45
+ [renderSymbol]() {
46
+ if (!this[connectedSymbol]) {
47
+ return;
48
+ }
49
+ if (!this[contextSymbol]) {
50
+ this[contextSymbol] = renderer.mount(this.container, ReactComponent, this[propsSymbol]);
51
+ }
52
+ }
53
+ }
54
+ return ReactWebComponent;
55
+ }
@@ -1,20 +0,0 @@
1
- export type GetRadiusData = {
2
- hasNegative: boolean;
3
- hasPositive: boolean;
4
- borderRadius?: number;
5
- layout?: 'vertical' | 'horizontal';
6
- };
7
- type GetRadiusCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
8
- /**
9
- * Returns if the corner should have a radius or not based on the layout and the data.
10
- * @param {GetRadiusCorner} corner The corner to check.
11
- * @param {GetRadiusData} cornerData The data for the corner.
12
- * @returns {number} The radius for the corner.
13
- */
14
- export declare const getRadius: (corner: GetRadiusCorner, {
15
- hasNegative,
16
- hasPositive,
17
- borderRadius,
18
- layout
19
- }: GetRadiusData) => number;
20
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRadius = void 0;
7
- /**
8
- * Returns if the corner should have a radius or not based on the layout and the data.
9
- * @param {GetRadiusCorner} corner The corner to check.
10
- * @param {GetRadiusData} cornerData The data for the corner.
11
- * @returns {number} The radius for the corner.
12
- */
13
- const getRadius = (corner, {
14
- hasNegative,
15
- hasPositive,
16
- borderRadius,
17
- layout
18
- }) => {
19
- if (!borderRadius) {
20
- return 0;
21
- }
22
- const isVertical = layout === 'vertical';
23
- if (corner === 'top-left' && (isVertical && hasPositive || !isVertical && hasNegative)) {
24
- return borderRadius;
25
- }
26
- if (corner === 'top-right' && (isVertical && hasPositive || !isVertical && hasPositive)) {
27
- return borderRadius;
28
- }
29
- if (corner === 'bottom-right' && (isVertical && hasNegative || !isVertical && hasPositive)) {
30
- return borderRadius;
31
- }
32
- if (corner === 'bottom-left' && (isVertical && hasNegative || !isVertical && hasNegative)) {
33
- return borderRadius;
34
- }
35
- return 0;
36
- };
37
- exports.getRadius = getRadius;
@@ -1,20 +0,0 @@
1
- export type GetRadiusData = {
2
- hasNegative: boolean;
3
- hasPositive: boolean;
4
- borderRadius?: number;
5
- layout?: 'vertical' | 'horizontal';
6
- };
7
- type GetRadiusCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
8
- /**
9
- * Returns if the corner should have a radius or not based on the layout and the data.
10
- * @param {GetRadiusCorner} corner The corner to check.
11
- * @param {GetRadiusData} cornerData The data for the corner.
12
- * @returns {number} The radius for the corner.
13
- */
14
- export declare const getRadius: (corner: GetRadiusCorner, {
15
- hasNegative,
16
- hasPositive,
17
- borderRadius,
18
- layout
19
- }: GetRadiusData) => number;
20
- export {};
@@ -1,30 +0,0 @@
1
- /**
2
- * Returns if the corner should have a radius or not based on the layout and the data.
3
- * @param {GetRadiusCorner} corner The corner to check.
4
- * @param {GetRadiusData} cornerData The data for the corner.
5
- * @returns {number} The radius for the corner.
6
- */
7
- export const getRadius = (corner, {
8
- hasNegative,
9
- hasPositive,
10
- borderRadius,
11
- layout
12
- }) => {
13
- if (!borderRadius) {
14
- return 0;
15
- }
16
- const isVertical = layout === 'vertical';
17
- if (corner === 'top-left' && (isVertical && hasPositive || !isVertical && hasNegative)) {
18
- return borderRadius;
19
- }
20
- if (corner === 'top-right' && (isVertical && hasPositive || !isVertical && hasPositive)) {
21
- return borderRadius;
22
- }
23
- if (corner === 'bottom-right' && (isVertical && hasNegative || !isVertical && hasPositive)) {
24
- return borderRadius;
25
- }
26
- if (corner === 'bottom-left' && (isVertical && hasNegative || !isVertical && hasNegative)) {
27
- return borderRadius;
28
- }
29
- return 0;
30
- };