@mui/x-charts 8.9.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 (76) hide show
  1. package/BarChart/BarChart.js +94 -1
  2. package/BarChart/BarClipPath.d.ts +17 -12
  3. package/BarChart/BarClipPath.js +70 -57
  4. package/BarChart/BarPlot.js +4 -0
  5. package/BarChart/seriesConfig/extremums.js +2 -3
  6. package/BarChart/useBarChartProps.d.ts +1 -1
  7. package/CHANGELOG.md +124 -0
  8. package/ChartContainer/ChartContainer.js +141 -0
  9. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  10. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
  11. package/LineChart/LineChart.js +94 -1
  12. package/LineChart/seriesConfig/extremums.js +2 -3
  13. package/LineChart/useLineChartProps.d.ts +1 -1
  14. package/PieChart/PieChart.js +1 -1
  15. package/RadarChart/RadarChart.d.ts +1 -1
  16. package/RadarChart/RadarChart.js +1 -1
  17. package/RadarChart/useRadarChartProps.d.ts +1 -1
  18. package/ScatterChart/ScatterChart.js +94 -1
  19. package/ScatterChart/seriesConfig/extremums.js +50 -23
  20. package/ScatterChart/useScatterChartProps.d.ts +1 -1
  21. package/SparkLineChart/SparkLineChart.js +93 -0
  22. package/esm/BarChart/BarChart.js +94 -1
  23. package/esm/BarChart/BarClipPath.d.ts +17 -12
  24. package/esm/BarChart/BarClipPath.js +69 -55
  25. package/esm/BarChart/BarPlot.js +4 -0
  26. package/esm/BarChart/seriesConfig/extremums.js +2 -3
  27. package/esm/BarChart/useBarChartProps.d.ts +1 -1
  28. package/esm/ChartContainer/ChartContainer.js +141 -0
  29. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  30. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +31 -6
  31. package/esm/LineChart/LineChart.js +94 -1
  32. package/esm/LineChart/seriesConfig/extremums.js +2 -3
  33. package/esm/LineChart/useLineChartProps.d.ts +1 -1
  34. package/esm/PieChart/PieChart.js +1 -1
  35. package/esm/RadarChart/RadarChart.d.ts +1 -1
  36. package/esm/RadarChart/RadarChart.js +1 -1
  37. package/esm/RadarChart/useRadarChartProps.d.ts +1 -1
  38. package/esm/ScatterChart/ScatterChart.js +94 -1
  39. package/esm/ScatterChart/seriesConfig/extremums.js +50 -23
  40. package/esm/ScatterChart/useScatterChartProps.d.ts +1 -1
  41. package/esm/SparkLineChart/SparkLineChart.js +93 -0
  42. package/esm/index.d.ts +2 -1
  43. package/esm/index.js +6 -2
  44. package/esm/internals/findMinMax.d.ts +1 -0
  45. package/esm/internals/findMinMax.js +13 -0
  46. package/esm/internals/getScale.js +3 -0
  47. package/esm/internals/index.d.ts +1 -1
  48. package/esm/internals/index.js +1 -1
  49. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -1
  50. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  51. package/esm/internals/symlogScale.d.ts +2 -0
  52. package/esm/internals/symlogScale.js +94 -0
  53. package/esm/models/axis.d.ts +20 -4
  54. package/esm/models/axis.js +3 -0
  55. package/index.d.ts +2 -1
  56. package/index.js +13 -1
  57. package/internals/findMinMax.d.ts +1 -0
  58. package/internals/findMinMax.js +19 -0
  59. package/internals/getScale.js +3 -0
  60. package/internals/index.d.ts +1 -1
  61. package/internals/index.js +12 -12
  62. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -0
  63. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  64. package/internals/symlogScale.d.ts +2 -0
  65. package/internals/symlogScale.js +100 -0
  66. package/models/axis.d.ts +20 -4
  67. package/models/axis.js +4 -0
  68. package/package.json +5 -6
  69. package/BarChart/getRadius.d.ts +0 -20
  70. package/BarChart/getRadius.js +0 -37
  71. package/esm/BarChart/getRadius.d.ts +0 -20
  72. package/esm/BarChart/getRadius.js +0 -30
  73. /package/{esm/internals/components/ChartsWrapper → ChartsWrapper}/index.d.ts +0 -0
  74. /package/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
  75. /package/{internals/components → esm}/ChartsWrapper/index.d.ts +0 -0
  76. /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
  };
@@ -417,6 +430,9 @@ export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): s
417
430
  export declare function isPointScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'point'> & {
418
431
  scaleType: 'point';
419
432
  };
433
+ export declare function isSymlogScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'symlog'> & {
434
+ scaleType: 'symlog';
435
+ };
420
436
  /**
421
437
  * The data format returned by onAxisClick.
422
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.9.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,7 +28,7 @@
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",
@@ -37,8 +36,8 @@
37
36
  "reselect": "^5.1.1",
38
37
  "use-sync-external-store": "^1.5.0",
39
38
  "@mui/x-charts-vendor": "8.6.0",
40
- "@mui/x-internal-gestures": "0.2.1",
41
- "@mui/x-internals": "8.8.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",
@@ -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
- };