@mui/x-charts 7.3.1 → 7.3.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.
- package/BarChart/BarChart.d.ts +4 -3
- package/BarChart/BarChart.js +15 -5
- package/BarChart/BarPlot.js +6 -6
- package/CHANGELOG.md +76 -5
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsOverlay/ChartsLoadingOverlay.d.ts +3 -0
- package/ChartsOverlay/ChartsLoadingOverlay.js +43 -0
- package/ChartsOverlay/ChartsNoDataOverlay.d.ts +3 -0
- package/ChartsOverlay/ChartsNoDataOverlay.js +43 -0
- package/ChartsOverlay/ChartsOverlay.d.ts +35 -0
- package/ChartsOverlay/ChartsOverlay.js +41 -0
- package/ChartsOverlay/index.d.ts +3 -0
- package/ChartsOverlay/index.js +26 -0
- package/ChartsOverlay/package.json +6 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsTooltip.d.ts +2 -2
- package/ChartsTooltip/ChartsTooltip.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
- package/ChartsXAxis/ChartsXAxis.js +7 -0
- package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
- package/ChartsYAxis/ChartsYAxis.js +7 -0
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeProvider.d.ts +2 -2
- package/Gauge/GaugeProvider.js +1 -1
- package/Gauge/gaugeClasses.d.ts +2 -2
- package/Gauge/utils.d.ts +1 -1
- package/Gauge/utils.js +4 -4
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/LineChart.d.ts +4 -3
- package/LineChart/LineChart.js +12 -2
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +3 -3
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +3 -3
- package/PieChart/PieChart.d.ts +4 -3
- package/PieChart/PieChart.js +15 -2
- package/ScatterChart/ScatterChart.d.ts +4 -3
- package/ScatterChart/ScatterChart.js +12 -2
- package/context/SeriesContextProvider.js +1 -1
- package/esm/BarChart/BarChart.js +15 -5
- package/esm/BarChart/BarPlot.js +6 -6
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
- package/esm/ChartsOverlay/ChartsOverlay.js +31 -0
- package/esm/ChartsOverlay/index.js +3 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltip.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +7 -0
- package/esm/Gauge/Gauge.js +1 -1
- package/esm/Gauge/GaugeContainer.js +1 -1
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/Gauge/utils.js +4 -4
- package/esm/LineChart/LineChart.js +12 -2
- package/esm/PieChart/PieArcLabel.js +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +3 -3
- package/esm/PieChart/PieArcPlot.js +3 -3
- package/esm/PieChart/PieChart.js +15 -2
- package/esm/ScatterChart/ScatterChart.js +12 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/hooks/useReducedMotion.js +1 -1
- package/esm/hooks/useScale.js +1 -1
- package/esm/hooks/useTicks.js +4 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
- package/esm/internals/utils.js +1 -1
- package/hooks/useReducedMotion.d.ts +1 -1
- package/hooks/useReducedMotion.js +1 -1
- package/hooks/useScale.d.ts +4 -4
- package/hooks/useScale.js +1 -1
- package/hooks/useTicks.js +4 -0
- package/index.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
- package/internals/utils.d.ts +1 -1
- package/internals/utils.js +1 -1
- package/models/axis.d.ts +1 -1
- package/models/seriesType/bar.d.ts +1 -1
- package/models/seriesType/line.d.ts +1 -1
- package/models/seriesType/pie.d.ts +4 -4
- package/modern/BarChart/BarChart.js +15 -5
- package/modern/BarChart/BarPlot.js +6 -6
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
- package/modern/ChartsOverlay/ChartsOverlay.js +31 -0
- package/modern/ChartsOverlay/index.js +3 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsTooltip/ChartsTooltip.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +7 -0
- package/modern/ChartsYAxis/ChartsYAxis.js +7 -0
- package/modern/Gauge/Gauge.js +1 -1
- package/modern/Gauge/GaugeContainer.js +1 -1
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/Gauge/utils.js +4 -4
- package/modern/LineChart/LineChart.js +12 -2
- package/modern/PieChart/PieArcLabel.js +1 -1
- package/modern/PieChart/PieArcLabelPlot.js +3 -3
- package/modern/PieChart/PieArcPlot.js +3 -3
- package/modern/PieChart/PieChart.js +15 -2
- package/modern/ScatterChart/ScatterChart.js +12 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/hooks/useReducedMotion.js +1 -1
- package/modern/hooks/useScale.js +1 -1
- package/modern/hooks/useTicks.js +4 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
- package/modern/internals/utils.js +1 -1
- package/package.json +1 -1
package/modern/hooks/useTicks.js
CHANGED
|
@@ -59,6 +59,10 @@ export function useTicks(options) {
|
|
|
59
59
|
labelOffset: 0
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
62
|
+
if (scale.domain().length === 0 || scale.domain()[0] === scale.domain()[1]) {
|
|
63
|
+
// The axis should not be visible, so ticks should also be hidden.
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
62
66
|
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
63
67
|
return ticks.map(value => ({
|
|
64
68
|
value,
|
package/modern/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export function useChartGradient() {
|
|
|
9
9
|
const {
|
|
10
10
|
chartId
|
|
11
11
|
} = React.useContext(DrawingContext);
|
|
12
|
-
return React.useCallback((axisId, direction) => `${chartId}-
|
|
12
|
+
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
13
13
|
}
|
|
14
14
|
export function ChartsAxesGradients() {
|
|
15
15
|
const {
|
|
@@ -40,7 +40,7 @@ export function ChartsAxesGradients() {
|
|
|
40
40
|
} = yAxis[axisId];
|
|
41
41
|
if (colorMap?.type === 'piecewise') {
|
|
42
42
|
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
43
|
-
|
|
43
|
+
isReversed: !reverse,
|
|
44
44
|
scale: scale,
|
|
45
45
|
colorMap: colorMap,
|
|
46
46
|
size: svgHeight,
|
|
@@ -50,7 +50,7 @@ export function ChartsAxesGradients() {
|
|
|
50
50
|
}
|
|
51
51
|
if (colorMap?.type === 'continuous') {
|
|
52
52
|
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
53
|
-
|
|
53
|
+
isReversed: !reverse,
|
|
54
54
|
scale: scale,
|
|
55
55
|
colorScale: colorScale,
|
|
56
56
|
colorMap: colorMap,
|
|
@@ -70,7 +70,7 @@ export function ChartsAxesGradients() {
|
|
|
70
70
|
} = xAxis[axisId];
|
|
71
71
|
if (colorMap?.type === 'piecewise') {
|
|
72
72
|
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
73
|
-
|
|
73
|
+
isReversed: reverse,
|
|
74
74
|
scale: scale,
|
|
75
75
|
colorMap: colorMap,
|
|
76
76
|
size: svgWidth,
|
|
@@ -80,7 +80,7 @@ export function ChartsAxesGradients() {
|
|
|
80
80
|
}
|
|
81
81
|
if (colorMap?.type === 'continuous') {
|
|
82
82
|
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
83
|
-
|
|
83
|
+
isReversed: reverse,
|
|
84
84
|
scale: scale,
|
|
85
85
|
colorScale: colorScale,
|
|
86
86
|
colorMap: colorMap,
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
const PX_PRECISION = 10;
|
|
5
5
|
export default function ChartsContinuousGradient(props) {
|
|
6
6
|
const {
|
|
7
|
-
|
|
7
|
+
isReversed,
|
|
8
8
|
gradientId,
|
|
9
9
|
size,
|
|
10
10
|
direction,
|
|
@@ -26,7 +26,7 @@ export default function ChartsContinuousGradient(props) {
|
|
|
26
26
|
x2: "0",
|
|
27
27
|
y1: "0",
|
|
28
28
|
y2: "0",
|
|
29
|
-
[`${direction}${
|
|
29
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
30
30
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
31
31
|
,
|
|
32
32
|
children: Array.from({
|
|
@@ -40,7 +40,7 @@ export default function ChartsContinuousGradient(props) {
|
|
|
40
40
|
if (x === undefined) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
const offset =
|
|
43
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
44
44
|
const color = colorScale(value);
|
|
45
45
|
if (color === null) {
|
|
46
46
|
return null;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
export default function ChartsPiecewiseGradient(props) {
|
|
4
4
|
const {
|
|
5
|
-
|
|
5
|
+
isReversed,
|
|
6
6
|
gradientId,
|
|
7
7
|
size,
|
|
8
8
|
direction,
|
|
@@ -15,7 +15,7 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
15
15
|
x2: "0",
|
|
16
16
|
y1: "0",
|
|
17
17
|
y2: "0",
|
|
18
|
-
[`${direction}${
|
|
18
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
19
19
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
20
20
|
,
|
|
21
21
|
children: colorMap.thresholds.map((threshold, index) => {
|
|
@@ -23,7 +23,7 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
23
23
|
if (x === undefined) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
const offset =
|
|
26
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
27
27
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
28
28
|
children: [/*#__PURE__*/_jsx("stop", {
|
|
29
29
|
offset: offset,
|
|
@@ -4,7 +4,7 @@ export function getSymbol(shape) {
|
|
|
4
4
|
return symbolNames.indexOf(shape) || 0;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Transform mouse event position to
|
|
7
|
+
* Transform mouse event position to coordinates inside the SVG.
|
|
8
8
|
* @param svg The SVG element
|
|
9
9
|
* @param event The mouseEvent to transform
|
|
10
10
|
*/
|