@mui/x-charts 6.0.0-alpha.5 → 6.0.0-alpha.7

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 (163) hide show
  1. package/BarChart/BarChart.d.ts +18 -2
  2. package/BarChart/BarChart.js +74 -17
  3. package/BarChart/BarElement.d.ts +22 -0
  4. package/BarChart/BarElement.js +21 -10
  5. package/BarChart/BarPlot.d.ts +14 -1
  6. package/BarChart/BarPlot.js +23 -4
  7. package/BarChart/formatter.js +23 -12
  8. package/CHANGELOG.md +154 -0
  9. package/ChartContainer/index.js +3 -0
  10. package/ChartsAxis/ChartsAxis.d.ts +11 -1
  11. package/ChartsAxis/ChartsAxis.js +51 -6
  12. package/ChartsLegend/ChartsLegend.d.ts +25 -2
  13. package/ChartsLegend/ChartsLegend.js +49 -17
  14. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
  16. package/ChartsXAxis/ChartsXAxis.js +44 -9
  17. package/ChartsYAxis/ChartsYAxis.js +44 -9
  18. package/LineChart/AreaElement.d.ts +22 -0
  19. package/LineChart/AreaElement.js +31 -11
  20. package/LineChart/AreaPlot.d.ts +14 -1
  21. package/LineChart/AreaPlot.js +32 -5
  22. package/LineChart/LineChart.d.ts +20 -2
  23. package/LineChart/LineChart.js +76 -16
  24. package/LineChart/LineElement.d.ts +22 -0
  25. package/LineChart/LineElement.js +31 -10
  26. package/LineChart/LinePlot.d.ts +14 -1
  27. package/LineChart/LinePlot.js +38 -6
  28. package/LineChart/MarkElement.js +1 -1
  29. package/LineChart/MarkPlot.d.ts +24 -1
  30. package/LineChart/MarkPlot.js +30 -6
  31. package/LineChart/formatter.js +23 -12
  32. package/PieChart/PieArcLabel.js +0 -1
  33. package/PieChart/PieChart.d.ts +14 -2
  34. package/PieChart/PieChart.js +60 -13
  35. package/PieChart/PiePlot.d.ts +27 -1
  36. package/PieChart/PiePlot.js +29 -6
  37. package/ScatterChart/ScatterChart.d.ts +18 -2
  38. package/ScatterChart/ScatterChart.js +64 -13
  39. package/ScatterChart/ScatterPlot.d.ts +24 -1
  40. package/ScatterChart/ScatterPlot.js +28 -4
  41. package/SparkLineChart/SparkLineChart.d.ts +73 -0
  42. package/SparkLineChart/SparkLineChart.js +218 -0
  43. package/SparkLineChart/index.d.ts +1 -0
  44. package/SparkLineChart/index.js +12 -0
  45. package/SparkLineChart/package.json +6 -0
  46. package/colorPalettes/colorPalettes.js +2 -2
  47. package/context/CartesianContextProvider.d.ts +3 -1
  48. package/context/CartesianContextProvider.js +50 -14
  49. package/context/SeriesContextProvider.d.ts +3 -2
  50. package/context/SeriesContextProvider.js +5 -3
  51. package/esm/BarChart/BarChart.js +77 -17
  52. package/esm/BarChart/BarElement.js +21 -11
  53. package/esm/BarChart/BarPlot.js +23 -4
  54. package/esm/BarChart/formatter.js +23 -12
  55. package/esm/ChartContainer/index.js +3 -0
  56. package/esm/ChartsAxis/ChartsAxis.js +51 -6
  57. package/esm/ChartsLegend/ChartsLegend.js +47 -14
  58. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  59. package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
  60. package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
  61. package/esm/LineChart/AreaElement.js +31 -11
  62. package/esm/LineChart/AreaPlot.js +33 -5
  63. package/esm/LineChart/LineChart.js +79 -16
  64. package/esm/LineChart/LineElement.js +31 -11
  65. package/esm/LineChart/LinePlot.js +45 -9
  66. package/esm/LineChart/MarkElement.js +1 -1
  67. package/esm/LineChart/MarkPlot.js +31 -6
  68. package/esm/LineChart/formatter.js +23 -13
  69. package/esm/PieChart/PieArcLabel.js +0 -1
  70. package/esm/PieChart/PieChart.js +60 -13
  71. package/esm/PieChart/PiePlot.js +31 -6
  72. package/esm/ScatterChart/ScatterChart.js +64 -13
  73. package/esm/ScatterChart/ScatterPlot.js +29 -4
  74. package/esm/SparkLineChart/SparkLineChart.js +210 -0
  75. package/esm/SparkLineChart/index.js +1 -0
  76. package/esm/colorPalettes/colorPalettes.js +2 -2
  77. package/esm/context/CartesianContextProvider.js +50 -14
  78. package/esm/context/SeriesContextProvider.js +5 -3
  79. package/esm/hooks/useTicks.js +9 -6
  80. package/esm/index.js +1 -0
  81. package/esm/internals/components/AxisSharedComponents.js +10 -10
  82. package/esm/models/index.js +3 -1
  83. package/hooks/useTicks.d.ts +20 -5
  84. package/hooks/useTicks.js +9 -6
  85. package/index.d.ts +1 -0
  86. package/index.js +12 -1
  87. package/internals/components/AxisSharedComponents.d.ts +4 -4
  88. package/internals/components/AxisSharedComponents.js +15 -15
  89. package/internals/defaultizeColor.d.ts +4 -2
  90. package/legacy/BarChart/BarChart.js +75 -17
  91. package/legacy/BarChart/BarElement.js +20 -10
  92. package/legacy/BarChart/BarPlot.js +23 -4
  93. package/legacy/BarChart/formatter.js +23 -10
  94. package/legacy/ChartContainer/index.js +3 -0
  95. package/legacy/ChartsAxis/ChartsAxis.js +51 -6
  96. package/legacy/ChartsLegend/ChartsLegend.js +46 -15
  97. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  98. package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
  99. package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
  100. package/legacy/LineChart/AreaElement.js +30 -10
  101. package/legacy/LineChart/AreaPlot.js +31 -5
  102. package/legacy/LineChart/LineChart.js +77 -16
  103. package/legacy/LineChart/LineElement.js +30 -10
  104. package/legacy/LineChart/LinePlot.js +38 -6
  105. package/legacy/LineChart/MarkElement.js +1 -1
  106. package/legacy/LineChart/MarkPlot.js +29 -6
  107. package/legacy/LineChart/formatter.js +23 -11
  108. package/legacy/PieChart/PieArcLabel.js +0 -1
  109. package/legacy/PieChart/PieChart.js +60 -13
  110. package/legacy/PieChart/PiePlot.js +29 -6
  111. package/legacy/ScatterChart/ScatterChart.js +64 -13
  112. package/legacy/ScatterChart/ScatterPlot.js +27 -4
  113. package/legacy/SparkLineChart/SparkLineChart.js +214 -0
  114. package/legacy/SparkLineChart/index.js +1 -0
  115. package/legacy/colorPalettes/colorPalettes.js +2 -2
  116. package/legacy/context/CartesianContextProvider.js +59 -15
  117. package/legacy/context/SeriesContextProvider.js +6 -4
  118. package/legacy/hooks/useTicks.js +9 -9
  119. package/legacy/index.js +2 -1
  120. package/legacy/internals/components/AxisSharedComponents.js +10 -10
  121. package/legacy/models/index.js +3 -1
  122. package/models/axis.d.ts +34 -3
  123. package/models/index.d.ts +2 -0
  124. package/models/index.js +11 -0
  125. package/models/seriesType/bar.d.ts +8 -1
  126. package/models/seriesType/common.d.ts +2 -2
  127. package/models/seriesType/config.d.ts +4 -1
  128. package/models/seriesType/line.d.ts +8 -1
  129. package/modern/BarChart/BarChart.js +74 -17
  130. package/modern/BarChart/BarElement.js +20 -11
  131. package/modern/BarChart/BarPlot.js +23 -4
  132. package/modern/BarChart/formatter.js +23 -12
  133. package/modern/ChartContainer/index.js +3 -0
  134. package/modern/ChartsAxis/ChartsAxis.js +51 -6
  135. package/modern/ChartsLegend/ChartsLegend.js +46 -14
  136. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  137. package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
  138. package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
  139. package/modern/LineChart/AreaElement.js +30 -11
  140. package/modern/LineChart/AreaPlot.js +33 -5
  141. package/modern/LineChart/LineChart.js +76 -16
  142. package/modern/LineChart/LineElement.js +30 -11
  143. package/modern/LineChart/LinePlot.js +39 -6
  144. package/modern/LineChart/MarkElement.js +1 -1
  145. package/modern/LineChart/MarkPlot.js +30 -6
  146. package/modern/LineChart/formatter.js +23 -13
  147. package/modern/PieChart/PieArcLabel.js +0 -1
  148. package/modern/PieChart/PieChart.js +60 -13
  149. package/modern/PieChart/PiePlot.js +30 -6
  150. package/modern/ScatterChart/ScatterChart.js +64 -13
  151. package/modern/ScatterChart/ScatterPlot.js +28 -4
  152. package/modern/SparkLineChart/SparkLineChart.js +210 -0
  153. package/modern/SparkLineChart/index.js +1 -0
  154. package/modern/colorPalettes/colorPalettes.js +2 -2
  155. package/modern/context/CartesianContextProvider.js +50 -14
  156. package/modern/context/SeriesContextProvider.js +5 -3
  157. package/modern/hooks/useTicks.js +9 -6
  158. package/modern/index.js +2 -1
  159. package/modern/internals/components/AxisSharedComponents.js +10 -10
  160. package/modern/models/index.js +3 -1
  161. package/package.json +4 -2
  162. package/themeAugmentation/components.d.ts +0 -10
  163. package/themeAugmentation/overrides.d.ts +0 -2
@@ -1,9 +1,15 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
3
+ import PropTypes from 'prop-types';
2
4
  import { Scatter } from './Scatter';
3
5
  import { SeriesContext } from '../context/SeriesContextProvider';
4
6
  import { CartesianContext } from '../context/CartesianContextProvider';
5
7
  import { jsx as _jsx } from "react/jsx-runtime";
6
- export function ScatterPlot() {
8
+ function ScatterPlot(props) {
9
+ const {
10
+ slots,
11
+ slotProps
12
+ } = props;
7
13
  const seriesData = React.useContext(SeriesContext).scatter;
8
14
  const axisData = React.useContext(CartesianContext);
9
15
  if (seriesData === undefined) {
@@ -21,6 +27,7 @@ export function ScatterPlot() {
21
27
  } = axisData;
22
28
  const defaultXAxisId = xAxisIds[0];
23
29
  const defaultYAxisId = yAxisIds[0];
30
+ const ScatterItems = slots?.scatter ?? Scatter;
24
31
  return /*#__PURE__*/_jsx(React.Fragment, {
25
32
  children: seriesOrder.map(seriesId => {
26
33
  const {
@@ -32,13 +39,30 @@ export function ScatterPlot() {
32
39
  } = series[seriesId];
33
40
  const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
34
41
  const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
35
- return /*#__PURE__*/_jsx(Scatter, {
42
+ return /*#__PURE__*/_jsx(ScatterItems, _extends({
36
43
  xScale: xScale,
37
44
  yScale: yScale,
38
45
  color: color,
39
46
  markerSize: markerSize ?? 4,
40
47
  series: series[seriesId]
41
- }, id);
48
+ }, slotProps?.scatter), id);
42
49
  })
43
50
  });
44
- }
51
+ }
52
+ process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
53
+ // ----------------------------- Warning --------------------------------
54
+ // | These PropTypes are generated from the TypeScript type definitions |
55
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
56
+ // ----------------------------------------------------------------------
57
+ /**
58
+ * The props used for each component slot.
59
+ * @default {}
60
+ */
61
+ slotProps: PropTypes.object,
62
+ /**
63
+ * Overridable component slots.
64
+ * @default {}
65
+ */
66
+ slots: PropTypes.object
67
+ } : void 0;
68
+ export { ScatterPlot };
@@ -0,0 +1,210 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { styled } from '@mui/material/styles';
5
+ import { BarPlot } from '../BarChart';
6
+ import { LinePlot, MarkPlot, AreaPlot, markElementClasses } from '../LineChart';
7
+ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
8
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
9
+ import { ChartsTooltip } from '../ChartsTooltip';
10
+ import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ const SparkLineMarkPlot = styled(MarkPlot)({
14
+ [`& .${markElementClasses.root}`]: {
15
+ display: 'none',
16
+ [`&.${markElementClasses.highlighted}`]: {
17
+ display: 'inherit'
18
+ }
19
+ }
20
+ });
21
+ const SPARKLINE_DEFAULT_MARGIN = {
22
+ top: 5,
23
+ bottom: 5,
24
+ left: 5,
25
+ right: 5
26
+ };
27
+ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
28
+ const {
29
+ xAxis,
30
+ width,
31
+ height,
32
+ margin = SPARKLINE_DEFAULT_MARGIN,
33
+ colors,
34
+ sx,
35
+ showTooltip,
36
+ tooltip,
37
+ showHighlight,
38
+ axisHighlight: inAxisHighlight,
39
+ children,
40
+ slots,
41
+ slotProps,
42
+ data,
43
+ plotType = 'line',
44
+ valueFormatter = v => v.toString(),
45
+ area,
46
+ curve = 'linear'
47
+ } = props;
48
+ const defaultXHighlight = showHighlight && plotType === 'bar' ? {
49
+ x: 'band'
50
+ } : {
51
+ x: 'none'
52
+ };
53
+ const axisHighlight = _extends({}, defaultXHighlight, inAxisHighlight);
54
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
55
+ ref: ref,
56
+ series: [_extends({
57
+ type: plotType,
58
+ data,
59
+ valueFormatter
60
+ }, plotType === 'bar' ? {} : {
61
+ area,
62
+ curve
63
+ })],
64
+ width: width,
65
+ height: height,
66
+ margin: margin,
67
+ xAxis: [_extends({
68
+ id: DEFAULT_X_AXIS_KEY,
69
+ scaleType: plotType === 'bar' ? 'band' : 'linear',
70
+ data: Array.from({
71
+ length: data.length
72
+ }, (_, index) => index),
73
+ hideTooltip: xAxis === undefined
74
+ }, xAxis)],
75
+ colors: colors,
76
+ sx: sx,
77
+ disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
78
+ children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
79
+ slots: slots,
80
+ slotProps: slotProps
81
+ }), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
82
+ children: [/*#__PURE__*/_jsx(AreaPlot, {
83
+ slots: slots,
84
+ slotProps: slotProps
85
+ }), /*#__PURE__*/_jsx(LinePlot, {
86
+ slots: slots,
87
+ slotProps: slotProps
88
+ }), showHighlight && /*#__PURE__*/_jsx(SparkLineMarkPlot, {})]
89
+ }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
90
+ });
91
+ });
92
+ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
93
+ // ----------------------------- Warning --------------------------------
94
+ // | These PropTypes are generated from the TypeScript type definitions |
95
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
96
+ // ----------------------------------------------------------------------
97
+ /**
98
+ * Set to `true` to fill spark line area.
99
+ * Has no effect if plotType='bar'.
100
+ * @default false
101
+ */
102
+ area: PropTypes.bool,
103
+ axisHighlight: PropTypes.shape({
104
+ x: PropTypes.oneOf(['band', 'line', 'none']),
105
+ y: PropTypes.oneOf(['line', 'none'])
106
+ }),
107
+ children: PropTypes.node,
108
+ className: PropTypes.string,
109
+ /**
110
+ * Color palette used to colorize multiple series.
111
+ */
112
+ colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
113
+ /**
114
+ * @default 'linear'
115
+ */
116
+ curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
117
+ /**
118
+ * Data to plot.
119
+ */
120
+ data: PropTypes.arrayOf(PropTypes.number).isRequired,
121
+ dataset: PropTypes.arrayOf(PropTypes.object),
122
+ desc: PropTypes.string,
123
+ disableAxisListener: PropTypes.bool,
124
+ height: PropTypes.number,
125
+ margin: PropTypes.shape({
126
+ bottom: PropTypes.number,
127
+ left: PropTypes.number,
128
+ right: PropTypes.number,
129
+ top: PropTypes.number
130
+ }),
131
+ /**
132
+ * Type of plot used.
133
+ * @default 'line'
134
+ */
135
+ plotType: PropTypes.oneOf(['bar', 'line']),
136
+ /**
137
+ * Set to `true` to highlight the value.
138
+ * With line, it shows a point.
139
+ * With bar, it shows a highlight band.
140
+ * @default false
141
+ */
142
+ showHighlight: PropTypes.bool,
143
+ /**
144
+ * Set to `true` to enable the tooltip in the sparkline.
145
+ * @default false
146
+ */
147
+ showTooltip: PropTypes.bool,
148
+ /**
149
+ * The props used for each component slot.
150
+ * @default {}
151
+ */
152
+ slotProps: PropTypes.object,
153
+ /**
154
+ * Overridable component slots.
155
+ * @default {}
156
+ */
157
+ slots: PropTypes.object,
158
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
159
+ title: PropTypes.string,
160
+ tooltip: PropTypes.shape({
161
+ axisContent: PropTypes.elementType,
162
+ classes: PropTypes.object,
163
+ itemContent: PropTypes.elementType,
164
+ trigger: PropTypes.oneOf(['axis', 'item', 'none'])
165
+ }),
166
+ /**
167
+ * Formatter used by the tooltip.
168
+ * @param {number} value The value to format.
169
+ * @returns {string} the formatted value.
170
+ */
171
+ valueFormatter: PropTypes.func,
172
+ viewBox: PropTypes.shape({
173
+ height: PropTypes.number,
174
+ width: PropTypes.number,
175
+ x: PropTypes.number,
176
+ y: PropTypes.number
177
+ }),
178
+ width: PropTypes.number,
179
+ /**
180
+ * The xAxis configuration.
181
+ * Notice it is a single configuration object, not an array of configuration.
182
+ */
183
+ xAxis: PropTypes.shape({
184
+ axisId: PropTypes.string,
185
+ classes: PropTypes.object,
186
+ data: PropTypes.array,
187
+ dataKey: PropTypes.string,
188
+ disableLine: PropTypes.bool,
189
+ disableTicks: PropTypes.bool,
190
+ fill: PropTypes.string,
191
+ hideTooltip: PropTypes.bool,
192
+ id: PropTypes.string,
193
+ label: PropTypes.string,
194
+ labelFontSize: PropTypes.number,
195
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
196
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
197
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
198
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
199
+ slotProps: PropTypes.object,
200
+ slots: PropTypes.object,
201
+ stroke: PropTypes.string,
202
+ tickFontSize: PropTypes.number,
203
+ tickMaxStep: PropTypes.number,
204
+ tickMinStep: PropTypes.number,
205
+ tickNumber: PropTypes.number,
206
+ tickSize: PropTypes.number,
207
+ valueFormatter: PropTypes.func
208
+ })
209
+ } : void 0;
210
+ export { SparkLineChart };
@@ -0,0 +1 @@
1
+ export { SparkLineChart } from './SparkLineChart';
@@ -4,6 +4,6 @@ export const blueberryTwilightPalette = mode => mode === 'dark' ? blueberryTwili
4
4
  export const mangoFusionPaletteLight = ['#173A5E', '#00A3A0', '#C91B63', '#EF5350', '#FFA726', '#B800D8', '#60009B', '#2E96FF', '#2731C8', '#03008D'];
5
5
  export const mangoFusionPaletteDark = ['#41698F', '#19D0CD', '#DE196B', '#FC5F5C', '#FFD771', '#DA00FF', '#9001CB', '#72CCFF', '#2E96FF', '#3B48E0'];
6
6
  export const mangoFusionPalette = mode => mode === 'dark' ? mangoFusionPaletteDark : mangoFusionPaletteLight;
7
- export const cheerfulFiestaPaletteDark = ['#0072E6', '#66B2FF', '#FFB017', '#1F94AD', '#FF3143', '#FF6C63'];
8
- export const cheerfulFiestaPaletteLight = ['#0059B2', '#2E96FF', '#EA8C00', '#1F94AD', '#C82634', '#FF3143'];
7
+ export const cheerfulFiestaPaletteDark = ['#0059B2', '#2E96FF', '#FFC24C', '#FF9F0E', '#F38200', '#2ABFDE', '#1F94AD', '#BD2C38', '#FF3143', '#FF8282'];
8
+ export const cheerfulFiestaPaletteLight = ['#003A75', '#007FFF', '#FFC24C', '#FF9D09', '#CA6C00', '#127D94', '#1F94AD', '#C82634', '#FF3143', '#FF7E7E'];
9
9
  export const cheerfulFiestaPalette = mode => mode === 'dark' ? cheerfulFiestaPaletteDark : cheerfulFiestaPaletteLight;
@@ -32,12 +32,37 @@ export const CartesianContext = /*#__PURE__*/React.createContext({
32
32
  yAxisIds: []
33
33
  });
34
34
  function CartesianContextProvider({
35
- xAxis,
36
- yAxis,
35
+ xAxis: inXAxis,
36
+ yAxis: inYAxis,
37
+ dataset,
37
38
  children
38
39
  }) {
39
40
  const formattedSeries = React.useContext(SeriesContext);
40
41
  const drawingArea = React.useContext(DrawingContext);
42
+ const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
43
+ const dataKey = axisConfig.dataKey;
44
+ if (dataKey === undefined || axisConfig.data !== undefined) {
45
+ return axisConfig;
46
+ }
47
+ if (dataset === undefined) {
48
+ throw Error('MUI: x-axis uses `dataKey` but no `dataset` is provided.');
49
+ }
50
+ return _extends({}, axisConfig, {
51
+ data: dataset.map(d => d[dataKey])
52
+ });
53
+ }), [inXAxis, dataset]);
54
+ const yAxis = React.useMemo(() => inYAxis?.map(axisConfig => {
55
+ const dataKey = axisConfig.dataKey;
56
+ if (dataKey === undefined || axisConfig.data !== undefined) {
57
+ return axisConfig;
58
+ }
59
+ if (dataset === undefined) {
60
+ throw Error('MUI: y-axis uses `dataKey` but no `dataset` is provided.');
61
+ }
62
+ return _extends({}, axisConfig, {
63
+ data: dataset.map(d => d[dataKey])
64
+ });
65
+ }), [inYAxis, dataset]);
41
66
  const value = React.useMemo(() => {
42
67
  const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis) => {
43
68
  const getter = getters[chartType];
@@ -98,7 +123,8 @@ function CartesianContextProvider({
98
123
  const scaleType = axis.scaleType ?? 'linear';
99
124
  const extremums = [axis.min ?? minData, axis.max ?? maxData];
100
125
  const ticksNumber = getTicksNumber(_extends({}, axis, {
101
- range
126
+ range,
127
+ domain: extremums
102
128
  }));
103
129
  const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
104
130
  const niceDomain = niceScale.domain();
@@ -145,7 +171,8 @@ function CartesianContextProvider({
145
171
  const scaleType = axis.scaleType ?? 'linear';
146
172
  const extremums = [axis.min ?? minData, axis.max ?? maxData];
147
173
  const ticksNumber = getTicksNumber(_extends({}, axis, {
148
- range
174
+ range,
175
+ domain: extremums
149
176
  }));
150
177
  const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
151
178
  const niceDomain = niceScale.domain();
@@ -180,48 +207,57 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
180
207
  // | To update them edit the TypeScript types and run "yarn proptypes" |
181
208
  // ----------------------------------------------------------------------
182
209
  children: PropTypes.node,
210
+ dataset: PropTypes.arrayOf(PropTypes.object),
183
211
  xAxis: PropTypes.arrayOf(PropTypes.shape({
184
212
  axisId: PropTypes.string,
185
213
  classes: PropTypes.object,
186
214
  data: PropTypes.array,
215
+ dataKey: PropTypes.string,
187
216
  disableLine: PropTypes.bool,
188
217
  disableTicks: PropTypes.bool,
189
218
  fill: PropTypes.string,
219
+ hideTooltip: PropTypes.bool,
190
220
  id: PropTypes.string,
191
221
  label: PropTypes.string,
192
222
  labelFontSize: PropTypes.number,
193
- max: PropTypes.number,
194
- maxTicks: PropTypes.number,
195
- min: PropTypes.number,
196
- minTicks: PropTypes.number,
223
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
224
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
197
225
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
198
226
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
227
+ slotProps: PropTypes.object,
228
+ slots: PropTypes.object,
199
229
  stroke: PropTypes.string,
200
230
  tickFontSize: PropTypes.number,
231
+ tickMaxStep: PropTypes.number,
232
+ tickMinStep: PropTypes.number,
233
+ tickNumber: PropTypes.number,
201
234
  tickSize: PropTypes.number,
202
- tickSpacing: PropTypes.number,
203
235
  valueFormatter: PropTypes.func
204
236
  })),
205
237
  yAxis: PropTypes.arrayOf(PropTypes.shape({
206
238
  axisId: PropTypes.string,
207
239
  classes: PropTypes.object,
208
240
  data: PropTypes.array,
241
+ dataKey: PropTypes.string,
209
242
  disableLine: PropTypes.bool,
210
243
  disableTicks: PropTypes.bool,
211
244
  fill: PropTypes.string,
245
+ hideTooltip: PropTypes.bool,
212
246
  id: PropTypes.string,
213
247
  label: PropTypes.string,
214
248
  labelFontSize: PropTypes.number,
215
- max: PropTypes.number,
216
- maxTicks: PropTypes.number,
217
- min: PropTypes.number,
218
- minTicks: PropTypes.number,
249
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
250
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
219
251
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
220
252
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
253
+ slotProps: PropTypes.object,
254
+ slots: PropTypes.object,
221
255
  stroke: PropTypes.string,
222
256
  tickFontSize: PropTypes.number,
257
+ tickMaxStep: PropTypes.number,
258
+ tickMinStep: PropTypes.number,
259
+ tickNumber: PropTypes.number,
223
260
  tickSize: PropTypes.number,
224
- tickSpacing: PropTypes.number,
225
261
  valueFormatter: PropTypes.func
226
262
  }))
227
263
  } : void 0;
@@ -15,6 +15,7 @@ const seriesTypeFormatter = {
15
15
  line: lineSeriesFormatter,
16
16
  pie: pieSeriesFormatter
17
17
  };
18
+
18
19
  /**
19
20
  * This methods is the interface between what the developer is providing and what components receives
20
21
  * To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
@@ -23,7 +24,7 @@ const seriesTypeFormatter = {
23
24
  * @param colors The color palette used to defaultize series colors
24
25
  * @returns An object structuring all the series by type.
25
26
  */
26
- const formatSeries = (series, colors) => {
27
+ const formatSeries = (series, colors, dataset) => {
27
28
  // Group series by type
28
29
  const seriesGroups = {};
29
30
  series.forEach((seriesData, seriesIndex) => {
@@ -49,18 +50,19 @@ const formatSeries = (series, colors) => {
49
50
  // Apply formater on a type group
50
51
  Object.keys(seriesTypeFormatter).forEach(type => {
51
52
  if (seriesGroups[type] !== undefined) {
52
- formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type]) ?? seriesGroups[type];
53
+ formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
53
54
  }
54
55
  });
55
56
  return formattedSeries;
56
57
  };
57
58
  export function SeriesContextProvider({
58
59
  series,
60
+ dataset,
59
61
  colors = blueberryTwilightPalette,
60
62
  children
61
63
  }) {
62
64
  const theme = useTheme();
63
- const formattedSeries = React.useMemo(() => formatSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors), [series, colors, theme.palette.mode]);
65
+ const formattedSeries = React.useMemo(() => formatSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, dataset), [series, colors, theme.palette.mode, dataset]);
64
66
  return /*#__PURE__*/_jsx(SeriesContext.Provider, {
65
67
  value: formattedSeries,
66
68
  children: children
@@ -2,13 +2,16 @@ import * as React from 'react';
2
2
  import { isBandScale } from '../internals/isBandScale';
3
3
  export function getTicksNumber(params) {
4
4
  const {
5
- maxTicks = 999,
6
- minTicks = 2,
7
- tickSpacing = 50,
8
- range
5
+ tickMaxStep,
6
+ tickMinStep,
7
+ tickNumber,
8
+ range,
9
+ domain
9
10
  } = params;
10
- const estimatedTickNumber = Math.floor(Math.abs(range[1] - range[0]) / tickSpacing);
11
- return Math.min(maxTicks, Math.max(minTicks, estimatedTickNumber));
11
+ const maxTicks = tickMinStep === undefined ? 999 : Math.floor(Math.abs(domain[1] - domain[0]) / tickMinStep);
12
+ const minTicks = tickMaxStep === undefined ? 2 : Math.ceil(Math.abs(domain[1] - domain[0]) / tickMaxStep);
13
+ const defaultizedTickNumber = tickNumber ?? Math.floor(Math.abs(range[1] - range[0]) / 50);
14
+ return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
12
15
  }
13
16
  function useTicks(options) {
14
17
  const {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.0.0-alpha.5
2
+ * @mui/x-charts v6.0.0-alpha.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -20,5 +20,6 @@ export * from './BarChart';
20
20
  export * from './LineChart';
21
21
  export * from './PieChart';
22
22
  export * from './ScatterChart';
23
+ export * from './SparkLineChart';
23
24
  export * from './ChartContainer';
24
25
  export * from './ResponsiveChartContainer';
@@ -8,39 +8,39 @@ export const AxisRoot = styled('g', {
8
8
  })({
9
9
  [`&.${axisClasses.directionY}`]: {
10
10
  [`.${axisClasses.tickLabel}`]: {
11
- alignmentBaseline: 'middle'
11
+ dominantBaseline: 'middle'
12
12
  },
13
13
  [`.${axisClasses.label}`]: {
14
- alignmentBaseline: 'baseline',
14
+ dominantBaseline: 'auto',
15
15
  textAnchor: 'middle'
16
16
  }
17
17
  },
18
18
  [`&.${axisClasses.left}`]: {
19
19
  [`.${axisClasses.tickLabel}`]: {
20
- alignmentBaseline: 'central',
20
+ dominantBaseline: 'central',
21
21
  textAnchor: 'end'
22
22
  }
23
23
  },
24
24
  [`&.${axisClasses.right}`]: {
25
25
  [`.${axisClasses.tickLabel}`]: {
26
- alignmentBaseline: 'central',
26
+ dominantBaseline: 'central',
27
27
  textAnchor: 'start'
28
28
  }
29
29
  },
30
30
  [`&.${axisClasses.bottom}`]: {
31
31
  [`.${axisClasses.tickLabel}, .${axisClasses.label}`]: {
32
- alignmentBaseline: 'hanging',
32
+ dominantBaseline: 'hanging',
33
33
  textAnchor: 'middle'
34
34
  }
35
35
  },
36
36
  [`&.${axisClasses.top}`]: {
37
37
  [`.${axisClasses.tickLabel}, .${axisClasses.label}`]: {
38
- alignmentBaseline: 'baseline',
38
+ dominantBaseline: 'baseline',
39
39
  textAnchor: 'middle'
40
40
  }
41
41
  }
42
42
  });
43
- export const Line = styled('line', {
43
+ export const ChartsLine = styled('line', {
44
44
  name: 'MuiChartsAxis',
45
45
  slot: 'Line',
46
46
  overridesResolver: (props, styles) => styles.line
@@ -51,7 +51,7 @@ export const Line = styled('line', {
51
51
  shapeRendering: 'crispEdges',
52
52
  strokeWidth: 1
53
53
  }));
54
- export const Tick = styled('line', {
54
+ export const ChartsTick = styled('line', {
55
55
  name: 'MuiChartsAxis',
56
56
  slot: 'Tick',
57
57
  overridesResolver: (props, styles) => styles.tick
@@ -61,7 +61,7 @@ export const Tick = styled('line', {
61
61
  stroke: theme.palette.text.primary,
62
62
  shapeRendering: 'crispEdges'
63
63
  }));
64
- export const TickLabel = styled('text', {
64
+ export const ChartsTickLabel = styled('text', {
65
65
  name: 'MuiChartsAxis',
66
66
  slot: 'TickLabel',
67
67
  overridesResolver: (props, styles) => styles.tickLabel
@@ -70,7 +70,7 @@ export const TickLabel = styled('text', {
70
70
  }) => _extends({}, theme.typography.caption, {
71
71
  fill: theme.palette.text.primary
72
72
  }));
73
- export const Label = styled('text', {
73
+ export const ChartsLabel = styled('text', {
74
74
  name: 'MuiChartsAxis',
75
75
  slot: 'Label',
76
76
  overridesResolver: (props, styles) => styles.label
@@ -1 +1,3 @@
1
- export * from './seriesType';
1
+ export * from './seriesType';
2
+ export * from './layout';
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "6.0.0-alpha.5",
3
+ "version": "6.0.0-alpha.7",
4
4
  "description": "The community edition of the charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.22.6",
31
- "clsx": "^1.2.1",
31
+ "clsx": "^2.0.0",
32
32
  "d3-color": "^3.1.0",
33
33
  "d3-scale": "^4.0.2",
34
34
  "d3-shape": "^3.2.0",
@@ -52,10 +52,12 @@
52
52
  },
53
53
  "exports": {
54
54
  ".": {
55
+ "types": "./index.d.ts",
55
56
  "require": "./index.js",
56
57
  "import": "./esm/index.js"
57
58
  },
58
59
  "./*": {
60
+ "types": "./*/index.d.ts",
59
61
  "require": "./*",
60
62
  "import": "./esm/*"
61
63
  }
@@ -7,19 +7,15 @@ export interface ChartsComponents {
7
7
  };
8
8
  MuiChartsXAxis?: {
9
9
  defaultProps?: ComponentsProps['MuiChartsXAxis'];
10
- styleOverrides?: ComponentsOverrides['MuiChartsXAxis'];
11
10
  };
12
11
  MuiChartsYAxis?: {
13
12
  defaultProps?: ComponentsProps['MuiChartsYAxis'];
14
- styleOverrides?: ComponentsOverrides['MuiChartsYAxis'];
15
13
  };
16
14
  MuiChartsAxisHighlight?: {
17
15
  defaultProps?: ComponentsProps['MuiChartsAxisHighlight'];
18
- styleOverrides?: never; // ComponentsOverrides['MuiChartsAxisHighlight'];
19
16
  };
20
17
  MuiChartsClipPath?: {
21
18
  defaultProps?: ComponentsProps['MuiChartsClipPath'];
22
- styleOverrides?: never; // ComponentsOverrides['MuiChartsClipPath'];
23
19
  };
24
20
  MuiChartsLegend?: {
25
21
  defaultProps?: ComponentsProps['MuiChartsLegend'];
@@ -27,15 +23,12 @@ export interface ChartsComponents {
27
23
  };
28
24
  MuiChartsTooltip?: {
29
25
  defaultProps?: ComponentsProps['MuiChartsTooltip'];
30
- styleOverrides?: never; // ComponentsOverrides['MuiChartsTooltip'];
31
26
  };
32
27
  MuiChartsSurface?: {
33
28
  defaultProps?: ComponentsProps['MuiChartsSurface'];
34
- styleOverrides?: never; // ComponentsOverrides['MuiChartsSurface'];
35
29
  };
36
30
  MuiBarChart?: {
37
31
  defaultProps?: ComponentsProps['MuiBarChart'];
38
- styleOverrides?: never; // ComponentsOverrides['MuiBarChart'];
39
32
  };
40
33
  MuiBarElement?: {
41
34
  defaultProps?: ComponentsProps['MuiBarElement'];
@@ -43,7 +36,6 @@ export interface ChartsComponents {
43
36
  };
44
37
  MuiLineChart?: {
45
38
  defaultProps?: ComponentsProps['MuiLineChart'];
46
- styleOverrides?: never; // ComponentsOverrides['MuiLineChart'];
47
39
  };
48
40
  MuiAreaElement?: {
49
41
  defaultProps?: ComponentsProps['MuiAreaElement'];
@@ -59,11 +51,9 @@ export interface ChartsComponents {
59
51
  };
60
52
  MuiScatterChart?: {
61
53
  defaultProps?: ComponentsProps['MuiScatterChart'];
62
- styleOverrides?: never; // ComponentsOverrides['MuiScatterChart'];
63
54
  };
64
55
  MuiScatter?: {
65
56
  defaultProps?: ComponentsProps['MuiScatter'];
66
- styleOverrides?: never; // ComponentsOverrides['MuiScatter'];
67
57
  };
68
58
  }
69
59
 
@@ -6,8 +6,6 @@ import { AreaElementClassKey, LineElementClassKey, MarkElementClassKey } from '.
6
6
  // prettier-ignore
7
7
  export interface PickersComponentNameToClassKey {
8
8
  MuiChartsAxis: ChartsAxisClassKey;
9
- MuiChartsXAxis: ChartsAxisClassKey;
10
- MuiChartsYAxis: ChartsAxisClassKey;
11
9
  MuiChartsLegend: ChartsLegendClassKey;
12
10
 
13
11
  // BarChart components