@mui/x-charts 7.3.1 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +4 -3
- package/BarChart/BarChart.js +22 -6
- package/BarChart/BarClipPath.d.ts +14 -0
- package/BarChart/BarClipPath.js +50 -0
- package/BarChart/BarPlot.d.ts +4 -0
- package/BarChart/BarPlot.js +108 -36
- package/BarChart/getRadius.d.ts +15 -0
- package/BarChart/getRadius.js +37 -0
- package/BarChart/types.d.ts +25 -0
- package/BarChart/types.js +5 -0
- package/CHANGELOG.md +141 -5
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsGrid/ChartsGrid.js +22 -11
- 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 +22 -6
- package/esm/BarChart/BarClipPath.js +42 -0
- package/esm/BarChart/BarPlot.js +109 -37
- package/esm/BarChart/getRadius.js +30 -0
- package/esm/BarChart/types.js +1 -0
- package/esm/ChartsGrid/ChartsGrid.js +23 -12
- 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 +22 -6
- package/modern/BarChart/BarClipPath.js +42 -0
- package/modern/BarChart/BarPlot.js +109 -37
- package/modern/BarChart/getRadius.js +30 -0
- package/modern/BarChart/types.js +1 -0
- package/modern/ChartsGrid/ChartsGrid.js +23 -12
- 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 +2 -2
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +2 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -129,7 +129,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
129
129
|
value: PropTypes.number.isRequired
|
|
130
130
|
})).isRequired,
|
|
131
131
|
/**
|
|
132
|
-
* Override the arc
|
|
132
|
+
* Override the arc attributes when it is faded.
|
|
133
133
|
* @default { additionalRadius: -5 }
|
|
134
134
|
*/
|
|
135
135
|
faded: PropTypes.shape({
|
|
@@ -142,7 +142,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
142
142
|
paddingAngle: PropTypes.number
|
|
143
143
|
}),
|
|
144
144
|
/**
|
|
145
|
-
* Override the arc
|
|
145
|
+
* Override the arc attributes when it is highlighted.
|
|
146
146
|
*/
|
|
147
147
|
highlighted: PropTypes.shape({
|
|
148
148
|
additionalRadius: PropTypes.number,
|
|
@@ -159,7 +159,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
159
159
|
}),
|
|
160
160
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
161
161
|
/**
|
|
162
|
-
* The radius between circle center and the
|
|
162
|
+
* The radius between circle center and the beginning of the arc.
|
|
163
163
|
* @default 0
|
|
164
164
|
*/
|
|
165
165
|
innerRadius: PropTypes.number,
|
|
@@ -109,7 +109,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
109
109
|
value: PropTypes.number.isRequired
|
|
110
110
|
})).isRequired,
|
|
111
111
|
/**
|
|
112
|
-
* Override the arc
|
|
112
|
+
* Override the arc attributes when it is faded.
|
|
113
113
|
* @default { additionalRadius: -5 }
|
|
114
114
|
*/
|
|
115
115
|
faded: PropTypes.shape({
|
|
@@ -122,7 +122,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
122
122
|
paddingAngle: PropTypes.number
|
|
123
123
|
}),
|
|
124
124
|
/**
|
|
125
|
-
* Override the arc
|
|
125
|
+
* Override the arc attributes when it is highlighted.
|
|
126
126
|
*/
|
|
127
127
|
highlighted: PropTypes.shape({
|
|
128
128
|
additionalRadius: PropTypes.number,
|
|
@@ -139,7 +139,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
139
139
|
}),
|
|
140
140
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
141
141
|
/**
|
|
142
|
-
* The radius between circle center and the
|
|
142
|
+
* The radius between circle center and the beginning of the arc.
|
|
143
143
|
* @default 0
|
|
144
144
|
*/
|
|
145
145
|
innerRadius: PropTypes.number,
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -9,6 +9,7 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
9
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
10
|
import { PiePlot } from './PiePlot';
|
|
11
11
|
import { useIsRTL } from '../internals/useIsRTL';
|
|
12
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const defaultMargin = {
|
|
14
15
|
top: 5,
|
|
@@ -59,7 +60,8 @@ function PieChart(props) {
|
|
|
59
60
|
children,
|
|
60
61
|
slots,
|
|
61
62
|
slotProps,
|
|
62
|
-
onItemClick
|
|
63
|
+
onItemClick,
|
|
64
|
+
loading
|
|
63
65
|
} = props;
|
|
64
66
|
const isRTL = useIsRTL();
|
|
65
67
|
const margin = _extends({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
|
|
@@ -98,10 +100,17 @@ function PieChart(props) {
|
|
|
98
100
|
slotProps: slotProps,
|
|
99
101
|
onItemClick: onItemClick,
|
|
100
102
|
skipAnimation: skipAnimation
|
|
103
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
104
|
+
loading: loading,
|
|
105
|
+
slots: slots,
|
|
106
|
+
slotProps: slotProps
|
|
101
107
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
102
108
|
slots: slots,
|
|
103
109
|
slotProps: slotProps
|
|
104
|
-
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
110
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
111
|
+
slots: slots,
|
|
112
|
+
slotProps: slotProps
|
|
113
|
+
})), children]
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
@@ -168,6 +177,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
168
177
|
slotProps: PropTypes.object,
|
|
169
178
|
slots: PropTypes.object
|
|
170
179
|
}),
|
|
180
|
+
/**
|
|
181
|
+
* If `true`, a loading overlay is displayed.
|
|
182
|
+
*/
|
|
183
|
+
loading: PropTypes.bool,
|
|
171
184
|
/**
|
|
172
185
|
* The margin between the SVG and the drawing area.
|
|
173
186
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -6,6 +6,7 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
|
6
6
|
import { ChartsAxis } from '../ChartsAxis';
|
|
7
7
|
import { ChartsTooltip } from '../ChartsTooltip';
|
|
8
8
|
import { ChartsLegend } from '../ChartsLegend';
|
|
9
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
9
10
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
11
|
import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
11
12
|
import { ChartsGrid } from '../ChartsGrid';
|
|
@@ -45,7 +46,8 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
45
46
|
onItemClick,
|
|
46
47
|
children,
|
|
47
48
|
slots,
|
|
48
|
-
slotProps
|
|
49
|
+
slotProps,
|
|
50
|
+
loading
|
|
49
51
|
} = props;
|
|
50
52
|
return /*#__PURE__*/_jsx(ResponsiveChartContainer, {
|
|
51
53
|
ref: ref,
|
|
@@ -78,13 +80,17 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
78
80
|
slots: slots,
|
|
79
81
|
slotProps: slotProps,
|
|
80
82
|
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
83
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
84
|
+
loading: loading,
|
|
85
|
+
slots: slots,
|
|
86
|
+
slotProps: slotProps
|
|
81
87
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
82
88
|
slots: slots,
|
|
83
89
|
slotProps: slotProps
|
|
84
90
|
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
85
91
|
x: "none",
|
|
86
92
|
y: "none"
|
|
87
|
-
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
93
|
+
}, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
88
94
|
trigger: "item"
|
|
89
95
|
}, tooltip)), children]
|
|
90
96
|
})
|
|
@@ -164,6 +170,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
164
170
|
slotProps: PropTypes.object,
|
|
165
171
|
slots: PropTypes.object
|
|
166
172
|
}),
|
|
173
|
+
/**
|
|
174
|
+
* If `true`, a loading overlay is displayed.
|
|
175
|
+
*/
|
|
176
|
+
loading: PropTypes.bool,
|
|
167
177
|
/**
|
|
168
178
|
* The margin between the SVG and the drawing area.
|
|
169
179
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -50,7 +50,7 @@ const formatSeries = (series, colors, dataset) => {
|
|
|
50
50
|
seriesGroups[type].seriesOrder.push(id);
|
|
51
51
|
});
|
|
52
52
|
const formattedSeries = {};
|
|
53
|
-
// Apply
|
|
53
|
+
// Apply formatter on a type group
|
|
54
54
|
Object.keys(seriesTypeFormatter).forEach(type => {
|
|
55
55
|
if (seriesGroups[type] !== undefined) {
|
|
56
56
|
formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
|
|
@@ -5,7 +5,7 @@ import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
|
|
|
5
5
|
* set skipAnimations to the value of the user's
|
|
6
6
|
* `prefers-reduced-motion` query.
|
|
7
7
|
*
|
|
8
|
-
* The return value, post-effect, is the value of their
|
|
8
|
+
* The return value, post-effect, is the value of their preferred setting
|
|
9
9
|
*/
|
|
10
10
|
export const useReducedMotion = () => {
|
|
11
11
|
// Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
|
package/esm/hooks/useScale.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
3
3
|
import { isBandScale } from '../internals/isBandScale';
|
|
4
4
|
/**
|
|
5
5
|
* For a given scale return a function that map value to their position.
|
|
6
|
-
*
|
|
6
|
+
* Useful when dealing with specific scale such as band.
|
|
7
7
|
* @param scale The scale to use
|
|
8
8
|
* @returns (value: any) => number
|
|
9
9
|
*/
|
package/esm/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,
|
|
@@ -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,
|
package/esm/internals/utils.js
CHANGED
|
@@ -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
|
*/
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* set skipAnimations to the value of the user's
|
|
4
4
|
* `prefers-reduced-motion` query.
|
|
5
5
|
*
|
|
6
|
-
* The return value, post-effect, is the value of their
|
|
6
|
+
* The return value, post-effect, is the value of their preferred setting
|
|
7
7
|
*/
|
|
8
8
|
export declare const useReducedMotion: () => void;
|
|
@@ -10,7 +10,7 @@ var _web = require("@react-spring/web");
|
|
|
10
10
|
* set skipAnimations to the value of the user's
|
|
11
11
|
* `prefers-reduced-motion` query.
|
|
12
12
|
*
|
|
13
|
-
* The return value, post-effect, is the value of their
|
|
13
|
+
* The return value, post-effect, is the value of their preferred setting
|
|
14
14
|
*/
|
|
15
15
|
const useReducedMotion = () => {
|
|
16
16
|
// Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
|
package/hooks/useScale.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { D3Scale } from '../models/axis';
|
|
1
|
+
import { AxisScaleConfig, D3Scale, ScaleName } from '../models/axis';
|
|
2
2
|
/**
|
|
3
3
|
* For a given scale return a function that map value to their position.
|
|
4
|
-
*
|
|
4
|
+
* Useful when dealing with specific scale such as band.
|
|
5
5
|
* @param scale The scale to use
|
|
6
6
|
* @returns (value: any) => number
|
|
7
7
|
*/
|
|
8
8
|
export declare function getValueToPositionMapper(scale: D3Scale): (value: any) => number;
|
|
9
|
-
export declare function useXScale(identifier?: number | string):
|
|
10
|
-
export declare function useYScale(identifier?: number | string):
|
|
9
|
+
export declare function useXScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'];
|
|
10
|
+
export declare function useYScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'];
|
package/hooks/useScale.js
CHANGED
|
@@ -13,7 +13,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
/**
|
|
15
15
|
* For a given scale return a function that map value to their position.
|
|
16
|
-
*
|
|
16
|
+
* Useful when dealing with specific scale such as band.
|
|
17
17
|
* @param scale The scale to use
|
|
18
18
|
* @returns (value: any) => number
|
|
19
19
|
*/
|
package/hooks/useTicks.js
CHANGED
|
@@ -68,6 +68,10 @@ function useTicks(options) {
|
|
|
68
68
|
labelOffset: 0
|
|
69
69
|
}));
|
|
70
70
|
}
|
|
71
|
+
if (scale.domain().length === 0 || scale.domain()[0] === scale.domain()[1]) {
|
|
72
|
+
// The axis should not be visible, so ticks should also be hidden.
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
71
75
|
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
72
76
|
return ticks.map(value => ({
|
|
73
77
|
value,
|
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ function useChartGradient() {
|
|
|
19
19
|
const {
|
|
20
20
|
chartId
|
|
21
21
|
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
22
|
-
return React.useCallback((axisId, direction) => `${chartId}-
|
|
22
|
+
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
23
23
|
}
|
|
24
24
|
function ChartsAxesGradients() {
|
|
25
25
|
const {
|
|
@@ -50,7 +50,7 @@ function ChartsAxesGradients() {
|
|
|
50
50
|
} = yAxis[axisId];
|
|
51
51
|
if (colorMap?.type === 'piecewise') {
|
|
52
52
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsPiecewiseGradient.default, {
|
|
53
|
-
|
|
53
|
+
isReversed: !reverse,
|
|
54
54
|
scale: scale,
|
|
55
55
|
colorMap: colorMap,
|
|
56
56
|
size: svgHeight,
|
|
@@ -60,7 +60,7 @@ function ChartsAxesGradients() {
|
|
|
60
60
|
}
|
|
61
61
|
if (colorMap?.type === 'continuous') {
|
|
62
62
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
|
|
63
|
-
|
|
63
|
+
isReversed: !reverse,
|
|
64
64
|
scale: scale,
|
|
65
65
|
colorScale: colorScale,
|
|
66
66
|
colorMap: colorMap,
|
|
@@ -80,7 +80,7 @@ function ChartsAxesGradients() {
|
|
|
80
80
|
} = xAxis[axisId];
|
|
81
81
|
if (colorMap?.type === 'piecewise') {
|
|
82
82
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsPiecewiseGradient.default, {
|
|
83
|
-
|
|
83
|
+
isReversed: reverse,
|
|
84
84
|
scale: scale,
|
|
85
85
|
colorMap: colorMap,
|
|
86
86
|
size: svgWidth,
|
|
@@ -90,7 +90,7 @@ function ChartsAxesGradients() {
|
|
|
90
90
|
}
|
|
91
91
|
if (colorMap?.type === 'continuous') {
|
|
92
92
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
|
|
93
|
-
|
|
93
|
+
isReversed: reverse,
|
|
94
94
|
scale: scale,
|
|
95
95
|
colorScale: colorScale,
|
|
96
96
|
colorMap: colorMap,
|
|
@@ -12,7 +12,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
12
12
|
const PX_PRECISION = 10;
|
|
13
13
|
function ChartsContinuousGradient(props) {
|
|
14
14
|
const {
|
|
15
|
-
|
|
15
|
+
isReversed,
|
|
16
16
|
gradientId,
|
|
17
17
|
size,
|
|
18
18
|
direction,
|
|
@@ -34,7 +34,7 @@ function ChartsContinuousGradient(props) {
|
|
|
34
34
|
x2: "0",
|
|
35
35
|
y1: "0",
|
|
36
36
|
y2: "0",
|
|
37
|
-
[`${direction}${
|
|
37
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
38
38
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
39
39
|
,
|
|
40
40
|
children: Array.from({
|
|
@@ -48,7 +48,7 @@ function ChartsContinuousGradient(props) {
|
|
|
48
48
|
if (x === undefined) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
-
const offset =
|
|
51
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
52
52
|
const color = colorScale(value);
|
|
53
53
|
if (color === null) {
|
|
54
54
|
return null;
|
|
@@ -10,7 +10,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
function ChartsPiecewiseGradient(props) {
|
|
12
12
|
const {
|
|
13
|
-
|
|
13
|
+
isReversed,
|
|
14
14
|
gradientId,
|
|
15
15
|
size,
|
|
16
16
|
direction,
|
|
@@ -23,7 +23,7 @@ function ChartsPiecewiseGradient(props) {
|
|
|
23
23
|
x2: "0",
|
|
24
24
|
y1: "0",
|
|
25
25
|
y2: "0",
|
|
26
|
-
[`${direction}${
|
|
26
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
27
27
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
28
28
|
,
|
|
29
29
|
children: colorMap.thresholds.map((threshold, index) => {
|
|
@@ -31,7 +31,7 @@ function ChartsPiecewiseGradient(props) {
|
|
|
31
31
|
if (x === undefined) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
|
-
const offset =
|
|
34
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
35
35
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
36
36
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("stop", {
|
|
37
37
|
offset: offset,
|
package/internals/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type Without<T, U> = {
|
|
|
5
5
|
};
|
|
6
6
|
export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
7
7
|
/**
|
|
8
|
-
* Transform mouse event position to
|
|
8
|
+
* Transform mouse event position to coordinates inside the SVG.
|
|
9
9
|
* @param svg The SVG element
|
|
10
10
|
* @param event The mouseEvent to transform
|
|
11
11
|
*/
|
package/internals/utils.js
CHANGED
|
@@ -13,7 +13,7 @@ function getSymbol(shape) {
|
|
|
13
13
|
return symbolNames.indexOf(shape) || 0;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Transform mouse event position to
|
|
16
|
+
* Transform mouse event position to coordinates inside the SVG.
|
|
17
17
|
* @param svg The SVG element
|
|
18
18
|
* @param event The mouseEvent to transform
|
|
19
19
|
*/
|
package/models/axis.d.ts
CHANGED
|
@@ -128,7 +128,7 @@ export interface ChartsXAxisProps extends ChartsAxisProps {
|
|
|
128
128
|
}
|
|
129
129
|
export type ScaleName = 'linear' | 'band' | 'point' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
|
|
130
130
|
export type ContinuousScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
|
|
131
|
-
interface AxisScaleConfig {
|
|
131
|
+
export interface AxisScaleConfig {
|
|
132
132
|
band: {
|
|
133
133
|
scaleType: 'band';
|
|
134
134
|
scale: ScaleBand<number | Date | string>;
|
|
@@ -8,7 +8,7 @@ export interface BarSeriesType extends CommonSeriesType<number | null>, Cartesia
|
|
|
8
8
|
*/
|
|
9
9
|
data?: (number | null)[];
|
|
10
10
|
/**
|
|
11
|
-
* The key used to
|
|
11
|
+
* The key used to retrieve data from the dataset.
|
|
12
12
|
*/
|
|
13
13
|
dataKey?: string;
|
|
14
14
|
label?: string;
|
|
@@ -31,7 +31,7 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
|
|
|
31
31
|
*/
|
|
32
32
|
data?: (number | null)[];
|
|
33
33
|
/**
|
|
34
|
-
* The key used to
|
|
34
|
+
* The key used to retrieve data from the dataset.
|
|
35
35
|
*/
|
|
36
36
|
dataKey?: string;
|
|
37
37
|
stack?: string;
|
|
@@ -20,7 +20,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
|
|
|
20
20
|
type: 'pie';
|
|
21
21
|
data: Tdata[];
|
|
22
22
|
/**
|
|
23
|
-
* The radius between circle center and the
|
|
23
|
+
* The radius between circle center and the beginning of the arc.
|
|
24
24
|
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
25
25
|
* The '100%' is the maximal radius that fit into the drawing area.
|
|
26
26
|
* @default 0
|
|
@@ -90,7 +90,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
|
|
|
90
90
|
*/
|
|
91
91
|
cy?: number | string;
|
|
92
92
|
/**
|
|
93
|
-
* Override the arc
|
|
93
|
+
* Override the arc attributes when it is highlighted.
|
|
94
94
|
*/
|
|
95
95
|
highlighted?: {
|
|
96
96
|
/**
|
|
@@ -106,7 +106,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
|
|
|
106
106
|
color?: string;
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
109
|
-
* Override the arc
|
|
109
|
+
* Override the arc attributes when it is faded.
|
|
110
110
|
*/
|
|
111
111
|
faded?: {
|
|
112
112
|
/**
|
|
@@ -139,7 +139,7 @@ export interface DefaultizedPieSeriesType extends DefaultizedProps<PieSeriesType
|
|
|
139
139
|
*/
|
|
140
140
|
export interface ComputedPieRadius {
|
|
141
141
|
/**
|
|
142
|
-
* The radius between circle center and the
|
|
142
|
+
* The radius between circle center and the beginning of the arc.
|
|
143
143
|
* @default 0
|
|
144
144
|
*/
|
|
145
145
|
innerRadius?: number;
|
|
@@ -12,6 +12,7 @@ import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
|
12
12
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
13
13
|
import { ChartsGrid } from '../ChartsGrid';
|
|
14
14
|
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
15
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
/**
|
|
17
18
|
* Demos:
|
|
@@ -45,11 +46,13 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
45
46
|
rightAxis,
|
|
46
47
|
bottomAxis,
|
|
47
48
|
skipAnimation,
|
|
49
|
+
borderRadius,
|
|
48
50
|
onItemClick,
|
|
49
51
|
onAxisClick,
|
|
50
52
|
children,
|
|
51
53
|
slots,
|
|
52
|
-
slotProps
|
|
54
|
+
slotProps,
|
|
55
|
+
loading
|
|
53
56
|
} = props;
|
|
54
57
|
const id = useId();
|
|
55
58
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -90,14 +93,19 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
90
93
|
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
91
94
|
vertical: grid.vertical,
|
|
92
95
|
horizontal: grid.horizontal
|
|
93
|
-
}), /*#__PURE__*/
|
|
96
|
+
}), /*#__PURE__*/_jsxs("g", {
|
|
94
97
|
clipPath: `url(#${clipPathId})`,
|
|
95
|
-
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
98
|
+
children: [/*#__PURE__*/_jsx(BarPlot, {
|
|
96
99
|
slots: slots,
|
|
97
100
|
slotProps: slotProps,
|
|
98
101
|
skipAnimation: skipAnimation,
|
|
99
|
-
onItemClick: onItemClick
|
|
100
|
-
|
|
102
|
+
onItemClick: onItemClick,
|
|
103
|
+
borderRadius: borderRadius
|
|
104
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
105
|
+
loading: loading,
|
|
106
|
+
slots: slots,
|
|
107
|
+
slotProps: slotProps
|
|
108
|
+
})]
|
|
101
109
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
102
110
|
topAxis: topAxis,
|
|
103
111
|
leftAxis: leftAxis,
|
|
@@ -108,7 +116,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
108
116
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
109
117
|
slots: slots,
|
|
110
118
|
slotProps: slotProps
|
|
111
|
-
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, defaultizedAxisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
119
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, defaultizedAxisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
112
120
|
slots: slots,
|
|
113
121
|
slotProps: slotProps
|
|
114
122
|
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
@@ -131,6 +139,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
131
139
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
132
140
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
133
141
|
}),
|
|
142
|
+
/**
|
|
143
|
+
* Defines the border radius of the bar element.
|
|
144
|
+
*/
|
|
145
|
+
borderRadius: PropTypes.number,
|
|
134
146
|
/**
|
|
135
147
|
* Indicate which axis to display the bottom of the charts.
|
|
136
148
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
@@ -191,6 +203,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
191
203
|
slotProps: PropTypes.object,
|
|
192
204
|
slots: PropTypes.object
|
|
193
205
|
}),
|
|
206
|
+
/**
|
|
207
|
+
* If `true`, a loading overlay is displayed.
|
|
208
|
+
*/
|
|
209
|
+
loading: PropTypes.bool,
|
|
194
210
|
/**
|
|
195
211
|
* The margin between the SVG and the drawing area.
|
|
196
212
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|