@mui/x-charts 7.2.0 → 7.3.1
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 +1 -0
- package/BarChart/BarChart.js +40 -99
- package/BarChart/BarElement.d.ts +63 -62
- package/BarChart/BarElement.js +1 -2
- package/BarChart/BarPlot.js +14 -7
- package/BarChart/getColor.d.ts +3 -0
- package/BarChart/getColor.js +33 -0
- package/CHANGELOG.md +204 -2
- package/ChartContainer/ChartContainer.js +38 -5
- package/ChartsAxis/ChartsAxis.js +11 -103
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsClipPath/ChartsClipPath.js +3 -3
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsLegend/ChartsLegend.js +3 -3
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsSurface.js +1 -1
- package/ChartsText/ChartsText.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +4 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +21 -3
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +6 -0
- package/ChartsTooltip/ChartsItemTooltipContent.js +32 -2
- package/ChartsTooltip/ChartsTooltip.js +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -7
- package/ChartsTooltip/ChartsTooltipTable.js +8 -9
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -7
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -8
- package/ChartsTooltip/utils.d.ts +5 -1
- package/ChartsTooltip/utils.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +7 -7
- package/ChartsXAxis/ChartsXAxis.js +3 -3
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeProvider.js +6 -6
- package/Gauge/GaugeReferenceArc.js +1 -1
- package/Gauge/GaugeValueArc.js +1 -1
- package/Gauge/GaugeValueText.js +1 -1
- package/LineChart/AnimatedArea.d.ts +63 -62
- package/LineChart/AnimatedArea.js +7 -6
- package/LineChart/AnimatedLine.d.ts +63 -62
- package/LineChart/AnimatedLine.js +8 -6
- package/LineChart/AreaElement.d.ts +1 -0
- package/LineChart/AreaElement.js +5 -2
- package/LineChart/AreaPlot.js +8 -2
- package/LineChart/LineChart.d.ts +1 -0
- package/LineChart/LineChart.js +40 -99
- package/LineChart/LineElement.d.ts +1 -0
- package/LineChart/LineElement.js +5 -2
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +5 -2
- package/LineChart/LinePlot.js +8 -2
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.js +6 -6
- package/LineChart/getColor.d.ts +3 -0
- package/LineChart/getColor.js +31 -0
- package/PieChart/PieArc.d.ts +1 -0
- package/PieChart/PieArc.js +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -0
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.d.ts +1 -0
- package/PieChart/PieChart.js +40 -99
- package/PieChart/PiePlot.js +27 -7
- package/PieChart/dataTransform/transition.d.ts +1 -0
- package/PieChart/dataTransform/useTransformData.js +1 -1
- package/PieChart/formatter.js +4 -2
- package/PieChart/getColor.d.ts +2 -0
- package/PieChart/getColor.js +11 -0
- package/PieChart/getPieCoordinates.d.ts +7 -0
- package/PieChart/getPieCoordinates.js +25 -0
- package/PieChart/index.d.ts +1 -0
- package/PieChart/index.js +11 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +35 -3
- package/ResponsiveChartContainer/useChartContainerDimensions.js +1 -1
- package/ScatterChart/Scatter.d.ts +1 -0
- package/ScatterChart/Scatter.js +7 -4
- package/ScatterChart/ScatterChart.d.ts +3 -1
- package/ScatterChart/ScatterChart.js +95 -126
- package/ScatterChart/ScatterPlot.js +11 -1
- package/ScatterChart/getColor.d.ts +4 -0
- package/ScatterChart/getColor.js +48 -0
- package/SparkLineChart/SparkLineChart.js +16 -1
- package/context/CartesianContextProvider.d.ts +4 -3
- package/context/CartesianContextProvider.js +24 -9
- package/context/DrawingProvider.js +1 -1
- package/context/HighlightProvider.js +1 -1
- package/context/InteractionProvider.js +1 -1
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +33 -0
- package/context/ZAxisContextProvider.js +98 -0
- package/context/index.d.ts +2 -0
- package/context/index.js +8 -1
- package/esm/BarChart/BarChart.js +40 -100
- package/esm/BarChart/BarElement.js +0 -1
- package/esm/BarChart/BarPlot.js +15 -7
- package/esm/BarChart/getColor.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +38 -5
- package/esm/ChartsAxis/ChartsAxis.js +11 -104
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/esm/ChartsClipPath/ChartsClipPath.js +2 -2
- package/esm/ChartsGrid/ChartsGrid.js +1 -2
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/esm/ChartsSurface.js +1 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
- package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +3 -4
- package/esm/ChartsYAxis/ChartsYAxis.js +3 -4
- package/esm/Gauge/Gauge.js +1 -2
- package/esm/Gauge/GaugeProvider.js +5 -5
- package/esm/LineChart/AnimatedArea.js +7 -7
- package/esm/LineChart/AnimatedLine.js +8 -7
- package/esm/LineChart/AreaElement.js +4 -1
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/LineChart.js +40 -100
- package/esm/LineChart/LineElement.js +4 -1
- package/esm/LineChart/LineHighlightPlot.js +4 -1
- package/esm/LineChart/LinePlot.js +7 -1
- package/esm/LineChart/MarkPlot.js +5 -5
- package/esm/LineChart/getColor.js +25 -0
- package/esm/PieChart/PieChart.js +40 -100
- package/esm/PieChart/PiePlot.js +27 -8
- package/esm/PieChart/formatter.js +4 -2
- package/esm/PieChart/getColor.js +5 -0
- package/esm/PieChart/getPieCoordinates.js +19 -0
- package/esm/PieChart/index.js +2 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
- package/esm/ScatterChart/Scatter.js +6 -3
- package/esm/ScatterChart/ScatterChart.js +95 -127
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/ScatterChart/getColor.js +42 -0
- package/esm/SparkLineChart/SparkLineChart.js +16 -2
- package/esm/context/CartesianContextProvider.js +23 -8
- package/esm/context/ZAxisContextProvider.js +89 -0
- package/esm/context/index.js +1 -1
- package/esm/hooks/index.js +4 -1
- package/esm/hooks/useAxisEvents.js +7 -6
- package/esm/hooks/useChartId.js +8 -0
- package/esm/hooks/useSeries.js +64 -0
- package/esm/hooks/useSvgRef.js +9 -0
- package/esm/internals/colorGetter.js +22 -0
- package/esm/internals/colorScale.js +16 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
- package/esm/internals/components/ChartsAxesGradients/index.js +1 -0
- package/esm/models/colorMapping.js +1 -0
- package/esm/models/seriesType/index.js +6 -1
- package/esm/models/z-axis.js +1 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +65 -1
- package/hooks/useAxisEvents.js +8 -7
- package/hooks/useChartDimensions.js +1 -1
- package/hooks/useChartId.d.ts +1 -0
- package/hooks/useChartId.js +16 -0
- package/hooks/useDrawingArea.js +1 -1
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useMounted.js +1 -1
- package/hooks/useScale.js +1 -1
- package/hooks/useSeries.d.ts +45 -0
- package/hooks/useSeries.js +75 -0
- package/hooks/useSvgRef.d.ts +2 -0
- package/hooks/useSvgRef.js +17 -0
- package/hooks/useTicks.js +1 -1
- package/index.js +1 -1
- package/internals/colorGetter.d.ts +7 -0
- package/internals/colorGetter.js +29 -0
- package/internals/colorScale.d.ts +5 -0
- package/internals/colorScale.js +24 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +3 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +63 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +12 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
- package/internals/components/ChartsAxesGradients/index.d.ts +1 -0
- package/internals/components/ChartsAxesGradients/index.js +16 -0
- package/internals/defaultizeColor.d.ts +5 -4
- package/internals/defaultizeValueFormatter.d.ts +5 -5
- package/internals/getScale.d.ts +2 -2
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +1 -1
- package/models/axis.d.ts +44 -4
- package/models/colorMapping.d.ts +46 -0
- package/models/colorMapping.js +5 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/common.d.ts +10 -2
- package/models/seriesType/index.d.ts +2 -0
- package/models/seriesType/index.js +17 -1
- package/models/seriesType/pie.d.ts +5 -0
- package/models/seriesType/scatter.d.ts +5 -0
- package/models/z-axis.d.ts +14 -0
- package/models/z-axis.js +5 -0
- package/modern/BarChart/BarChart.js +40 -100
- package/modern/BarChart/BarElement.js +0 -1
- package/modern/BarChart/BarPlot.js +15 -7
- package/modern/BarChart/getColor.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +38 -5
- package/modern/ChartsAxis/ChartsAxis.js +11 -104
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/modern/ChartsClipPath/ChartsClipPath.js +2 -2
- package/modern/ChartsGrid/ChartsGrid.js +1 -2
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/modern/ChartsSurface.js +1 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
- package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +3 -4
- package/modern/ChartsYAxis/ChartsYAxis.js +3 -4
- package/modern/Gauge/Gauge.js +1 -2
- package/modern/Gauge/GaugeProvider.js +5 -5
- package/modern/LineChart/AnimatedArea.js +7 -7
- package/modern/LineChart/AnimatedLine.js +8 -7
- package/modern/LineChart/AreaElement.js +4 -1
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/LineChart.js +40 -100
- package/modern/LineChart/LineElement.js +4 -1
- package/modern/LineChart/LineHighlightPlot.js +4 -1
- package/modern/LineChart/LinePlot.js +7 -1
- package/modern/LineChart/MarkPlot.js +5 -5
- package/modern/LineChart/getColor.js +25 -0
- package/modern/PieChart/PieChart.js +40 -100
- package/modern/PieChart/PiePlot.js +27 -8
- package/modern/PieChart/formatter.js +4 -2
- package/modern/PieChart/getColor.js +5 -0
- package/modern/PieChart/getPieCoordinates.js +19 -0
- package/modern/PieChart/index.js +2 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
- package/modern/ScatterChart/Scatter.js +6 -3
- package/modern/ScatterChart/ScatterChart.js +95 -127
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/ScatterChart/getColor.js +42 -0
- package/modern/SparkLineChart/SparkLineChart.js +16 -2
- package/modern/context/CartesianContextProvider.js +23 -8
- package/modern/context/ZAxisContextProvider.js +89 -0
- package/modern/context/index.js +1 -1
- package/modern/hooks/index.js +4 -1
- package/modern/hooks/useAxisEvents.js +7 -6
- package/modern/hooks/useChartId.js +8 -0
- package/modern/hooks/useSeries.js +64 -0
- package/modern/hooks/useSvgRef.js +9 -0
- package/modern/index.js +1 -1
- package/modern/internals/colorGetter.js +22 -0
- package/modern/internals/colorScale.js +16 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
- package/modern/internals/components/ChartsAxesGradients/index.js +1 -0
- package/modern/models/colorMapping.js +1 -0
- package/modern/models/seriesType/index.js +6 -1
- package/modern/models/z-axis.js +1 -0
- package/package.json +3 -5
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ZAxisContext = void 0;
|
|
8
|
+
exports.ZAxisContextProvider = ZAxisContextProvider;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _colorScale = require("../internals/colorScale");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
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; }
|
|
16
|
+
const ZAxisContext = exports.ZAxisContext = /*#__PURE__*/React.createContext({
|
|
17
|
+
zAxis: {},
|
|
18
|
+
zAxisIds: []
|
|
19
|
+
});
|
|
20
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
21
|
+
ZAxisContext.displayName = 'ZAxisContext';
|
|
22
|
+
}
|
|
23
|
+
function ZAxisContextProvider(props) {
|
|
24
|
+
const {
|
|
25
|
+
zAxis: inZAxis,
|
|
26
|
+
dataset,
|
|
27
|
+
children
|
|
28
|
+
} = props;
|
|
29
|
+
const zAxis = React.useMemo(() => inZAxis?.map(axisConfig => {
|
|
30
|
+
const dataKey = axisConfig.dataKey;
|
|
31
|
+
if (dataKey === undefined || axisConfig.data !== undefined) {
|
|
32
|
+
return axisConfig;
|
|
33
|
+
}
|
|
34
|
+
if (dataset === undefined) {
|
|
35
|
+
throw Error('MUI X Charts: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
36
|
+
}
|
|
37
|
+
return (0, _extends2.default)({}, axisConfig, {
|
|
38
|
+
data: dataset.map(d => d[dataKey])
|
|
39
|
+
});
|
|
40
|
+
}), [inZAxis, dataset]);
|
|
41
|
+
const value = React.useMemo(() => {
|
|
42
|
+
const allZAxis = zAxis?.map((axis, index) => (0, _extends2.default)({
|
|
43
|
+
id: `defaultized-z-axis-${index}`
|
|
44
|
+
}, axis)) ?? [];
|
|
45
|
+
const completedZAxis = {};
|
|
46
|
+
allZAxis.forEach(axis => {
|
|
47
|
+
completedZAxis[axis.id] = (0, _extends2.default)({}, axis, {
|
|
48
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' && axis.data ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
49
|
+
values: axis.data
|
|
50
|
+
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap))
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
zAxis: completedZAxis,
|
|
55
|
+
zAxisIds: allZAxis.map(({
|
|
56
|
+
id
|
|
57
|
+
}) => id)
|
|
58
|
+
};
|
|
59
|
+
}, [zAxis]);
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ZAxisContext.Provider, {
|
|
61
|
+
value: value,
|
|
62
|
+
children: children
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
66
|
+
// ----------------------------- Warning --------------------------------
|
|
67
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
68
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
69
|
+
// ----------------------------------------------------------------------
|
|
70
|
+
children: _propTypes.default.node,
|
|
71
|
+
/**
|
|
72
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
73
|
+
*/
|
|
74
|
+
dataset: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
75
|
+
/**
|
|
76
|
+
* The configuration of the z-axes.
|
|
77
|
+
*/
|
|
78
|
+
zAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
79
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
80
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
81
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
82
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
83
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
84
|
+
}), _propTypes.default.shape({
|
|
85
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
86
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
87
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
88
|
+
}), _propTypes.default.shape({
|
|
89
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
90
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
91
|
+
unknownColor: _propTypes.default.string,
|
|
92
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
93
|
+
})]),
|
|
94
|
+
data: _propTypes.default.array,
|
|
95
|
+
dataKey: _propTypes.default.string,
|
|
96
|
+
id: _propTypes.default.string
|
|
97
|
+
}))
|
|
98
|
+
} : void 0;
|
package/context/index.d.ts
CHANGED
package/context/index.js
CHANGED
|
@@ -2,4 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ZAxisContextProvider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ZAxisContextProvider.ZAxisContextProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _ZAxisContextProvider = require("./ZAxisContextProvider");
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -12,8 +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 { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
16
|
/**
|
|
18
17
|
* Demos:
|
|
19
18
|
*
|
|
@@ -137,30 +136,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
137
136
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
138
137
|
* @default xAxisIds[0] The id of the first provided axis
|
|
139
138
|
*/
|
|
140
|
-
bottomAxis: PropTypes.oneOfType([PropTypes.
|
|
141
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
142
|
-
classes: PropTypes.object,
|
|
143
|
-
disableLine: PropTypes.bool,
|
|
144
|
-
disableTicks: PropTypes.bool,
|
|
145
|
-
fill: PropTypes.string,
|
|
146
|
-
label: PropTypes.string,
|
|
147
|
-
labelFontSize: PropTypes.number,
|
|
148
|
-
labelStyle: PropTypes.object,
|
|
149
|
-
position: PropTypes.oneOf(['bottom', 'top']),
|
|
150
|
-
slotProps: PropTypes.object,
|
|
151
|
-
slots: PropTypes.object,
|
|
152
|
-
stroke: PropTypes.string,
|
|
153
|
-
tickFontSize: PropTypes.number,
|
|
154
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
155
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
156
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
157
|
-
tickLabelStyle: PropTypes.object,
|
|
158
|
-
tickMaxStep: PropTypes.number,
|
|
159
|
-
tickMinStep: PropTypes.number,
|
|
160
|
-
tickNumber: PropTypes.number,
|
|
161
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
162
|
-
tickSize: PropTypes.number
|
|
163
|
-
}), PropTypes.string]),
|
|
139
|
+
bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
164
140
|
children: PropTypes.node,
|
|
165
141
|
className: PropTypes.string,
|
|
166
142
|
/**
|
|
@@ -200,30 +176,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
200
176
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
201
177
|
* @default yAxisIds[0] The id of the first provided axis
|
|
202
178
|
*/
|
|
203
|
-
leftAxis: PropTypes.oneOfType([PropTypes.
|
|
204
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
205
|
-
classes: PropTypes.object,
|
|
206
|
-
disableLine: PropTypes.bool,
|
|
207
|
-
disableTicks: PropTypes.bool,
|
|
208
|
-
fill: PropTypes.string,
|
|
209
|
-
label: PropTypes.string,
|
|
210
|
-
labelFontSize: PropTypes.number,
|
|
211
|
-
labelStyle: PropTypes.object,
|
|
212
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
213
|
-
slotProps: PropTypes.object,
|
|
214
|
-
slots: PropTypes.object,
|
|
215
|
-
stroke: PropTypes.string,
|
|
216
|
-
tickFontSize: PropTypes.number,
|
|
217
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
218
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
219
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
220
|
-
tickLabelStyle: PropTypes.object,
|
|
221
|
-
tickMaxStep: PropTypes.number,
|
|
222
|
-
tickMinStep: PropTypes.number,
|
|
223
|
-
tickNumber: PropTypes.number,
|
|
224
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
225
|
-
tickSize: PropTypes.number
|
|
226
|
-
}), PropTypes.string]),
|
|
179
|
+
leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
227
180
|
/**
|
|
228
181
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
229
182
|
*/
|
|
@@ -268,32 +221,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
268
221
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
269
222
|
* @default null
|
|
270
223
|
*/
|
|
271
|
-
rightAxis: PropTypes.oneOfType([PropTypes.
|
|
272
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
273
|
-
classes: PropTypes.object,
|
|
274
|
-
disableLine: PropTypes.bool,
|
|
275
|
-
disableTicks: PropTypes.bool,
|
|
276
|
-
fill: PropTypes.string,
|
|
277
|
-
label: PropTypes.string,
|
|
278
|
-
labelFontSize: PropTypes.number,
|
|
279
|
-
labelStyle: PropTypes.object,
|
|
280
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
281
|
-
slotProps: PropTypes.object,
|
|
282
|
-
slots: PropTypes.object,
|
|
283
|
-
stroke: PropTypes.string,
|
|
284
|
-
tickFontSize: PropTypes.number,
|
|
285
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
286
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
287
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
288
|
-
tickLabelStyle: PropTypes.object,
|
|
289
|
-
tickMaxStep: PropTypes.number,
|
|
290
|
-
tickMinStep: PropTypes.number,
|
|
291
|
-
tickNumber: PropTypes.number,
|
|
292
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
293
|
-
tickSize: PropTypes.number
|
|
294
|
-
}), PropTypes.string]),
|
|
224
|
+
rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
295
225
|
/**
|
|
296
226
|
* The series to display in the bar chart.
|
|
227
|
+
* An array of [[BarSeriesType]] objects.
|
|
297
228
|
*/
|
|
298
229
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
299
230
|
/**
|
|
@@ -330,30 +261,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
330
261
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
331
262
|
* @default null
|
|
332
263
|
*/
|
|
333
|
-
topAxis: PropTypes.oneOfType([PropTypes.
|
|
334
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
335
|
-
classes: PropTypes.object,
|
|
336
|
-
disableLine: PropTypes.bool,
|
|
337
|
-
disableTicks: PropTypes.bool,
|
|
338
|
-
fill: PropTypes.string,
|
|
339
|
-
label: PropTypes.string,
|
|
340
|
-
labelFontSize: PropTypes.number,
|
|
341
|
-
labelStyle: PropTypes.object,
|
|
342
|
-
position: PropTypes.oneOf(['bottom', 'top']),
|
|
343
|
-
slotProps: PropTypes.object,
|
|
344
|
-
slots: PropTypes.object,
|
|
345
|
-
stroke: PropTypes.string,
|
|
346
|
-
tickFontSize: PropTypes.number,
|
|
347
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
348
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
349
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
350
|
-
tickLabelStyle: PropTypes.object,
|
|
351
|
-
tickMaxStep: PropTypes.number,
|
|
352
|
-
tickMinStep: PropTypes.number,
|
|
353
|
-
tickNumber: PropTypes.number,
|
|
354
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
355
|
-
tickSize: PropTypes.number
|
|
356
|
-
}), PropTypes.string]),
|
|
264
|
+
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
357
265
|
viewBox: PropTypes.shape({
|
|
358
266
|
height: PropTypes.number,
|
|
359
267
|
width: PropTypes.number,
|
|
@@ -366,11 +274,27 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
366
274
|
width: PropTypes.number,
|
|
367
275
|
/**
|
|
368
276
|
* The configuration of the x-axes.
|
|
369
|
-
* If not provided, a default axis config is used
|
|
277
|
+
* If not provided, a default axis config is used.
|
|
278
|
+
* An array of [[AxisConfig]] objects.
|
|
370
279
|
*/
|
|
371
280
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
372
281
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
373
282
|
classes: PropTypes.object,
|
|
283
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
284
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
285
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
286
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
287
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
288
|
+
}), PropTypes.shape({
|
|
289
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
290
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
291
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
292
|
+
}), PropTypes.shape({
|
|
293
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
294
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
295
|
+
unknownColor: PropTypes.string,
|
|
296
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
297
|
+
})]),
|
|
374
298
|
data: PropTypes.array,
|
|
375
299
|
dataKey: PropTypes.string,
|
|
376
300
|
disableLine: PropTypes.bool,
|
|
@@ -403,11 +327,27 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
403
327
|
})),
|
|
404
328
|
/**
|
|
405
329
|
* The configuration of the y-axes.
|
|
406
|
-
* If not provided, a default axis config is used
|
|
330
|
+
* If not provided, a default axis config is used.
|
|
331
|
+
* An array of [[AxisConfig]] objects.
|
|
407
332
|
*/
|
|
408
333
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
409
334
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
410
335
|
classes: PropTypes.object,
|
|
336
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
337
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
338
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
339
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
340
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
341
|
+
}), PropTypes.shape({
|
|
342
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
343
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
344
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
345
|
+
}), PropTypes.shape({
|
|
346
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
347
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
348
|
+
unknownColor: PropTypes.string,
|
|
349
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
350
|
+
})]),
|
|
411
351
|
data: PropTypes.array,
|
|
412
352
|
dataKey: PropTypes.string,
|
|
413
353
|
disableLine: PropTypes.bool,
|
|
@@ -35,7 +35,6 @@ export const BarElementPath = styled(animated.rect, {
|
|
|
35
35
|
ownerState
|
|
36
36
|
}) => ({
|
|
37
37
|
stroke: 'none',
|
|
38
|
-
shapeRendering: 'crispEdges',
|
|
39
38
|
fill: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
|
|
40
39
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
41
40
|
opacity: ownerState.isFaded && 0.3 || 1
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -7,9 +7,10 @@ import { useTransition } from '@react-spring/web';
|
|
|
7
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
8
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
9
|
import { BarElement } from './BarElement';
|
|
10
|
-
import { isBandScaleConfig } from '../models/axis';
|
|
10
|
+
import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
|
|
11
11
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
12
|
-
import
|
|
12
|
+
import getColor from './getColor';
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* Solution of the equations
|
|
15
16
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -19,6 +20,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
19
20
|
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
20
21
|
* @returns The bar width and the offset between bars.
|
|
21
22
|
*/
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
24
|
function getBandSize({
|
|
23
25
|
bandWidth: W,
|
|
24
26
|
numberOfGroups: N,
|
|
@@ -74,6 +76,9 @@ const useAggregatedData = () => {
|
|
|
74
76
|
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud have data property.`);
|
|
75
77
|
}
|
|
76
78
|
baseScaleConfig = xAxisConfig;
|
|
79
|
+
if (isBandScaleConfig(yAxisConfig) || isPointScaleConfig(yAxisConfig)) {
|
|
80
|
+
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud be a continuous type to display the bar series of id "${seriesId}".`);
|
|
81
|
+
}
|
|
77
82
|
} else {
|
|
78
83
|
if (!isBandScaleConfig(yAxisConfig)) {
|
|
79
84
|
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}".`);
|
|
@@ -82,9 +87,13 @@ const useAggregatedData = () => {
|
|
|
82
87
|
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud have data property.`);
|
|
83
88
|
}
|
|
84
89
|
baseScaleConfig = yAxisConfig;
|
|
90
|
+
if (isBandScaleConfig(xAxisConfig) || isPointScaleConfig(xAxisConfig)) {
|
|
91
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud be a continuous type to display the bar series of id "${seriesId}".`);
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
const xScale = xAxisConfig.scale;
|
|
87
95
|
const yScale = yAxisConfig.scale;
|
|
96
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
|
|
88
97
|
const bandWidth = baseScaleConfig.scale.bandwidth();
|
|
89
98
|
const {
|
|
90
99
|
barWidth,
|
|
@@ -96,13 +105,12 @@ const useAggregatedData = () => {
|
|
|
96
105
|
});
|
|
97
106
|
const barOffset = groupIndex * (barWidth + offset);
|
|
98
107
|
const {
|
|
99
|
-
stackedData
|
|
100
|
-
color
|
|
108
|
+
stackedData
|
|
101
109
|
} = series[seriesId];
|
|
102
110
|
return stackedData.map((values, dataIndex) => {
|
|
103
111
|
const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
|
|
104
|
-
const minValueCoord = Math.min(...valueCoordinates);
|
|
105
|
-
const maxValueCoord = Math.max(...valueCoordinates);
|
|
112
|
+
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
113
|
+
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
106
114
|
return {
|
|
107
115
|
seriesId,
|
|
108
116
|
dataIndex,
|
|
@@ -113,7 +121,7 @@ const useAggregatedData = () => {
|
|
|
113
121
|
yOrigin: yScale(0),
|
|
114
122
|
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
115
123
|
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
116
|
-
color,
|
|
124
|
+
color: colorGetter(dataIndex),
|
|
117
125
|
highlightScope: series[seriesId].highlightScope
|
|
118
126
|
};
|
|
119
127
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default function getColor(series, xAxis, yAxis) {
|
|
2
|
+
const verticalLayout = series.layout === 'vertical';
|
|
3
|
+
const bandColorScale = verticalLayout ? xAxis.colorScale : yAxis.colorScale;
|
|
4
|
+
const valueColorScale = verticalLayout ? yAxis.colorScale : xAxis.colorScale;
|
|
5
|
+
const bandValues = verticalLayout ? xAxis.data : yAxis.data;
|
|
6
|
+
if (valueColorScale) {
|
|
7
|
+
return dataIndex => {
|
|
8
|
+
const value = series.data[dataIndex];
|
|
9
|
+
const color = value === null ? series.color : valueColorScale(value);
|
|
10
|
+
if (color === null) {
|
|
11
|
+
return series.color;
|
|
12
|
+
}
|
|
13
|
+
return color;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (bandColorScale) {
|
|
17
|
+
return dataIndex => {
|
|
18
|
+
const value = bandValues[dataIndex];
|
|
19
|
+
const color = value === null ? series.color : bandColorScale(value);
|
|
20
|
+
if (color === null) {
|
|
21
|
+
return series.color;
|
|
22
|
+
}
|
|
23
|
+
return color;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return () => series.color;
|
|
27
|
+
}
|
|
@@ -8,7 +8,8 @@ import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
|
8
8
|
import { ChartsSurface } from '../ChartsSurface';
|
|
9
9
|
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
10
10
|
import { HighlightProvider } from '../context/HighlightProvider';
|
|
11
|
-
import {
|
|
11
|
+
import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
13
14
|
const {
|
|
14
15
|
width,
|
|
@@ -44,7 +45,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
44
45
|
dataset: dataset,
|
|
45
46
|
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
46
47
|
children: /*#__PURE__*/_jsx(HighlightProvider, {
|
|
47
|
-
children: /*#__PURE__*/
|
|
48
|
+
children: /*#__PURE__*/_jsxs(ChartsSurface, {
|
|
48
49
|
width: width,
|
|
49
50
|
height: height,
|
|
50
51
|
ref: handleRef,
|
|
@@ -52,7 +53,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
52
53
|
title: title,
|
|
53
54
|
desc: desc,
|
|
54
55
|
disableAxisListener: disableAxisListener,
|
|
55
|
-
children: children
|
|
56
|
+
children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
|
|
56
57
|
})
|
|
57
58
|
})
|
|
58
59
|
})
|
|
@@ -119,11 +120,27 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
119
120
|
width: PropTypes.number.isRequired,
|
|
120
121
|
/**
|
|
121
122
|
* The configuration of the x-axes.
|
|
122
|
-
* If not provided, a default axis config is used
|
|
123
|
+
* If not provided, a default axis config is used.
|
|
124
|
+
* An array of [[AxisConfig]] objects.
|
|
123
125
|
*/
|
|
124
126
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
125
127
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
126
128
|
classes: PropTypes.object,
|
|
129
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
130
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
131
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
132
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
133
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
134
|
+
}), PropTypes.shape({
|
|
135
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
136
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
137
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
138
|
+
}), PropTypes.shape({
|
|
139
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
140
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
141
|
+
unknownColor: PropTypes.string,
|
|
142
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
143
|
+
})]),
|
|
127
144
|
data: PropTypes.array,
|
|
128
145
|
dataKey: PropTypes.string,
|
|
129
146
|
disableLine: PropTypes.bool,
|
|
@@ -156,11 +173,27 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
156
173
|
})),
|
|
157
174
|
/**
|
|
158
175
|
* The configuration of the y-axes.
|
|
159
|
-
* If not provided, a default axis config is used
|
|
176
|
+
* If not provided, a default axis config is used.
|
|
177
|
+
* An array of [[AxisConfig]] objects.
|
|
160
178
|
*/
|
|
161
179
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
162
180
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
163
181
|
classes: PropTypes.object,
|
|
182
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
183
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
184
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
185
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
186
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
187
|
+
}), PropTypes.shape({
|
|
188
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
189
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
190
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
191
|
+
}), PropTypes.shape({
|
|
192
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
193
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
194
|
+
unknownColor: PropTypes.string,
|
|
195
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
196
|
+
})]),
|
|
164
197
|
data: PropTypes.array,
|
|
165
198
|
dataKey: PropTypes.string,
|
|
166
199
|
disableLine: PropTypes.bool,
|
|
@@ -4,14 +4,13 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
5
5
|
import { ChartsXAxis } from '../ChartsXAxis';
|
|
6
6
|
import { ChartsYAxis } from '../ChartsYAxis';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
const getAxisId = propsValue => {
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const getAxisId = (propsValue, defaultAxisId) => {
|
|
10
9
|
if (propsValue == null) {
|
|
11
10
|
return null;
|
|
12
11
|
}
|
|
13
12
|
if (typeof propsValue === 'object') {
|
|
14
|
-
return propsValue.axisId ?? null;
|
|
13
|
+
return propsValue.axisId ?? defaultAxisId ?? null;
|
|
15
14
|
}
|
|
16
15
|
return propsValue;
|
|
17
16
|
};
|
|
@@ -53,10 +52,10 @@ function ChartsAxis(props) {
|
|
|
53
52
|
// TODO: use for plotting line without ticks or any thing
|
|
54
53
|
// const drawingArea = React.useContext(DrawingContext);
|
|
55
54
|
|
|
56
|
-
const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis);
|
|
57
|
-
const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis);
|
|
58
|
-
const topId = getAxisId(topAxis);
|
|
59
|
-
const rightId = getAxisId(rightAxis);
|
|
55
|
+
const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis, yAxisIds[0]);
|
|
56
|
+
const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis, xAxisIds[0]);
|
|
57
|
+
const topId = getAxisId(topAxis, xAxisIds[0]);
|
|
58
|
+
const rightId = getAxisId(rightAxis, yAxisIds[0]);
|
|
60
59
|
if (topId !== null && !xAxis[topId]) {
|
|
61
60
|
throw Error([`MUI X Charts: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
62
61
|
}
|
|
@@ -99,88 +98,19 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
99
98
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
100
99
|
* @default xAxisIds[0] The id of the first provided axis
|
|
101
100
|
*/
|
|
102
|
-
bottomAxis: PropTypes.oneOfType([PropTypes.
|
|
103
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
104
|
-
classes: PropTypes.object,
|
|
105
|
-
disableLine: PropTypes.bool,
|
|
106
|
-
disableTicks: PropTypes.bool,
|
|
107
|
-
fill: PropTypes.string,
|
|
108
|
-
label: PropTypes.string,
|
|
109
|
-
labelFontSize: PropTypes.number,
|
|
110
|
-
labelStyle: PropTypes.object,
|
|
111
|
-
position: PropTypes.oneOf(['bottom', 'top']),
|
|
112
|
-
slotProps: PropTypes.object,
|
|
113
|
-
slots: PropTypes.object,
|
|
114
|
-
stroke: PropTypes.string,
|
|
115
|
-
tickFontSize: PropTypes.number,
|
|
116
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
117
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
118
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
119
|
-
tickLabelStyle: PropTypes.object,
|
|
120
|
-
tickMaxStep: PropTypes.number,
|
|
121
|
-
tickMinStep: PropTypes.number,
|
|
122
|
-
tickNumber: PropTypes.number,
|
|
123
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
124
|
-
tickSize: PropTypes.number
|
|
125
|
-
}), PropTypes.string]),
|
|
101
|
+
bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
126
102
|
/**
|
|
127
103
|
* Indicate which axis to display the left of the charts.
|
|
128
104
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
129
105
|
* @default yAxisIds[0] The id of the first provided axis
|
|
130
106
|
*/
|
|
131
|
-
leftAxis: PropTypes.oneOfType([PropTypes.
|
|
132
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
133
|
-
classes: PropTypes.object,
|
|
134
|
-
disableLine: PropTypes.bool,
|
|
135
|
-
disableTicks: PropTypes.bool,
|
|
136
|
-
fill: PropTypes.string,
|
|
137
|
-
label: PropTypes.string,
|
|
138
|
-
labelFontSize: PropTypes.number,
|
|
139
|
-
labelStyle: PropTypes.object,
|
|
140
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
141
|
-
slotProps: PropTypes.object,
|
|
142
|
-
slots: PropTypes.object,
|
|
143
|
-
stroke: PropTypes.string,
|
|
144
|
-
tickFontSize: PropTypes.number,
|
|
145
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
146
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
147
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
148
|
-
tickLabelStyle: PropTypes.object,
|
|
149
|
-
tickMaxStep: PropTypes.number,
|
|
150
|
-
tickMinStep: PropTypes.number,
|
|
151
|
-
tickNumber: PropTypes.number,
|
|
152
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
153
|
-
tickSize: PropTypes.number
|
|
154
|
-
}), PropTypes.string]),
|
|
107
|
+
leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
155
108
|
/**
|
|
156
109
|
* Indicate which axis to display the right of the charts.
|
|
157
110
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
158
111
|
* @default null
|
|
159
112
|
*/
|
|
160
|
-
rightAxis: PropTypes.oneOfType([PropTypes.
|
|
161
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
162
|
-
classes: PropTypes.object,
|
|
163
|
-
disableLine: PropTypes.bool,
|
|
164
|
-
disableTicks: PropTypes.bool,
|
|
165
|
-
fill: PropTypes.string,
|
|
166
|
-
label: PropTypes.string,
|
|
167
|
-
labelFontSize: PropTypes.number,
|
|
168
|
-
labelStyle: PropTypes.object,
|
|
169
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
170
|
-
slotProps: PropTypes.object,
|
|
171
|
-
slots: PropTypes.object,
|
|
172
|
-
stroke: PropTypes.string,
|
|
173
|
-
tickFontSize: PropTypes.number,
|
|
174
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
175
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
176
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
177
|
-
tickLabelStyle: PropTypes.object,
|
|
178
|
-
tickMaxStep: PropTypes.number,
|
|
179
|
-
tickMinStep: PropTypes.number,
|
|
180
|
-
tickNumber: PropTypes.number,
|
|
181
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
182
|
-
tickSize: PropTypes.number
|
|
183
|
-
}), PropTypes.string]),
|
|
113
|
+
rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
184
114
|
/**
|
|
185
115
|
* The props used for each component slot.
|
|
186
116
|
* @default {}
|
|
@@ -196,29 +126,6 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
196
126
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
197
127
|
* @default null
|
|
198
128
|
*/
|
|
199
|
-
topAxis: PropTypes.oneOfType([PropTypes.
|
|
200
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
201
|
-
classes: PropTypes.object,
|
|
202
|
-
disableLine: PropTypes.bool,
|
|
203
|
-
disableTicks: PropTypes.bool,
|
|
204
|
-
fill: PropTypes.string,
|
|
205
|
-
label: PropTypes.string,
|
|
206
|
-
labelFontSize: PropTypes.number,
|
|
207
|
-
labelStyle: PropTypes.object,
|
|
208
|
-
position: PropTypes.oneOf(['bottom', 'top']),
|
|
209
|
-
slotProps: PropTypes.object,
|
|
210
|
-
slots: PropTypes.object,
|
|
211
|
-
stroke: PropTypes.string,
|
|
212
|
-
tickFontSize: PropTypes.number,
|
|
213
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
214
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
215
|
-
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
216
|
-
tickLabelStyle: PropTypes.object,
|
|
217
|
-
tickMaxStep: PropTypes.number,
|
|
218
|
-
tickMinStep: PropTypes.number,
|
|
219
|
-
tickNumber: PropTypes.number,
|
|
220
|
-
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
221
|
-
tickSize: PropTypes.number
|
|
222
|
-
}), PropTypes.string])
|
|
129
|
+
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
|
|
223
130
|
} : void 0;
|
|
224
131
|
export { ChartsAxis };
|