@mui/x-charts 9.2.0 → 9.3.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.js +10 -10
- package/BarChart/BarChart.mjs +10 -10
- package/BarChart/seriesConfig/bar/getColor.js +7 -53
- package/BarChart/seriesConfig/bar/getColor.mjs +7 -53
- package/BarChart/seriesConfig/bar/seriesProcessor.js +3 -1
- package/BarChart/seriesConfig/bar/seriesProcessor.mjs +3 -1
- package/BarChart/seriesConfig/bar/tooltip.js +4 -27
- package/BarChart/seriesConfig/bar/tooltip.mjs +4 -27
- package/CHANGELOG.md +118 -0
- package/ChartsContainer/ChartsContainer.js +9 -9
- package/ChartsContainer/ChartsContainer.mjs +9 -9
- package/ChartsLabel/ChartsLabelMark.js +0 -2
- package/ChartsLabel/ChartsLabelMark.mjs +0 -2
- package/ChartsLabel/labelMarkClasses.d.mts +0 -1
- package/ChartsLabel/labelMarkClasses.d.ts +0 -1
- package/ChartsLabel/labelMarkClasses.js +1 -2
- package/ChartsLabel/labelMarkClasses.mjs +2 -2
- package/ChartsLayerContainer/ChartsLayerContainer.js +36 -30
- package/ChartsLayerContainer/ChartsLayerContainer.mjs +36 -30
- package/ChartsXAxis/ChartsXAxis.js +3 -1
- package/ChartsXAxis/ChartsXAxis.mjs +3 -1
- package/ChartsYAxis/ChartsYAxis.js +3 -1
- package/ChartsYAxis/ChartsYAxis.mjs +3 -1
- package/LineChart/LineChart.js +6 -6
- package/LineChart/LineChart.mjs +6 -6
- package/LineChart/seriesConfig/curveEvaluation.js +12 -1
- package/LineChart/seriesConfig/curveEvaluation.mjs +12 -1
- package/LineChart/seriesConfig/getColor.js +7 -54
- package/LineChart/seriesConfig/getColor.mjs +7 -54
- package/LineChart/seriesConfig/seriesProcessor.d.mts +2 -4
- package/LineChart/seriesConfig/seriesProcessor.d.ts +2 -4
- package/LineChart/seriesConfig/seriesProcessor.js +2 -139
- package/LineChart/seriesConfig/seriesProcessor.mjs +2 -138
- package/LineChart/seriesConfig/tooltip.js +4 -25
- package/LineChart/seriesConfig/tooltip.mjs +4 -25
- package/PieChart/PieChart.js +6 -6
- package/PieChart/PieChart.mjs +6 -6
- package/RadarChart/RadarAxis/useRadarAxis.js +1 -1
- package/RadarChart/RadarAxis/useRadarAxis.mjs +1 -1
- package/RadarChart/RadarChart.js +8 -8
- package/RadarChart/RadarChart.mjs +8 -8
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +1 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +1 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.mjs +1 -0
- package/ScatterChart/ScatterChart.js +11 -11
- package/ScatterChart/ScatterChart.mjs +11 -11
- package/ScatterChart/seriesConfig/tooltip.js +2 -24
- package/ScatterChart/seriesConfig/tooltip.mjs +2 -24
- package/SparkLineChart/SparkLineChart.js +27 -27
- package/SparkLineChart/SparkLineChart.mjs +27 -27
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +1 -1
- package/internals/getLineLikeTooltip.d.mts +9 -0
- package/internals/getLineLikeTooltip.d.ts +9 -0
- package/internals/getLineLikeTooltip.js +38 -0
- package/internals/getLineLikeTooltip.mjs +31 -0
- package/internals/index.d.mts +3 -0
- package/internals/index.d.ts +3 -0
- package/internals/index.js +24 -0
- package/internals/index.mjs +3 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.mts +4 -2
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.ts +4 -2
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +3 -0
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.mjs +3 -0
- package/internals/processLineLikeSeries.d.mts +6 -0
- package/internals/processLineLikeSeries.d.ts +6 -0
- package/internals/processLineLikeSeries.js +145 -0
- package/internals/processLineLikeSeries.mjs +138 -0
- package/internals/resolveColorProcessor.d.mts +11 -0
- package/internals/resolveColorProcessor.d.ts +11 -0
- package/internals/resolveColorProcessor.js +62 -0
- package/internals/resolveColorProcessor.mjs +56 -0
- package/package.json +3 -3
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.processLineLikeSeries = processLineLikeSeries;
|
|
8
|
+
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
11
|
+
var _warning = require("@mui/x-internals/warning");
|
|
12
|
+
var _stacking = require("./stacking");
|
|
13
|
+
const defaultShapes = ['circle', 'square', 'diamond', 'cross', 'star', 'triangle', 'wye'];
|
|
14
|
+
const lineValueFormatter = v => v == null ? '' : v.toLocaleString();
|
|
15
|
+
function processLineLikeSeries(params, dataset, isItemVisible, seriesType) {
|
|
16
|
+
const {
|
|
17
|
+
seriesOrder,
|
|
18
|
+
series
|
|
19
|
+
} = params;
|
|
20
|
+
const stackingGroups = (0, _stacking.getStackingGroups)((0, _extends2.default)({}, params, {
|
|
21
|
+
defaultStrategy: {
|
|
22
|
+
stackOffset: 'none'
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
const idToIndex = new Map();
|
|
26
|
+
const d3Dataset = dataset ?? [];
|
|
27
|
+
seriesOrder.forEach((id, seriesIndex) => {
|
|
28
|
+
idToIndex.set(id, seriesIndex);
|
|
29
|
+
const data = series[id].data;
|
|
30
|
+
if (data !== undefined) {
|
|
31
|
+
data.forEach((value, dataIndex) => {
|
|
32
|
+
if (d3Dataset.length <= dataIndex) {
|
|
33
|
+
d3Dataset.push({
|
|
34
|
+
[id]: value
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
d3Dataset[dataIndex][id] = value;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} else if (series[id].valueGetter && dataset) {
|
|
41
|
+
dataset.forEach((entry, dataIndex) => {
|
|
42
|
+
const value = series[id].valueGetter(entry);
|
|
43
|
+
if (d3Dataset.length <= dataIndex) {
|
|
44
|
+
d3Dataset.push({
|
|
45
|
+
[id]: value
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
d3Dataset[dataIndex][id] = value;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
52
|
+
const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
|
|
53
|
+
// TODO: fix mui/no-guarded-throw
|
|
54
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
55
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${titleCase} series with id="${id}" has no data. ` + 'The chart cannot render this series without data. ' + 'Provide a data property to the series or use the dataset prop.' : (0, _formatErrorMessage2.default)(276, titleCase, id));
|
|
56
|
+
}
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
+
if (!data && dataset) {
|
|
59
|
+
const dataKey = series[id].dataKey;
|
|
60
|
+
if (!dataKey && !series[id].valueGetter) {
|
|
61
|
+
const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
|
|
62
|
+
// TODO: fix mui/no-guarded-throw
|
|
63
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
64
|
+
throw new Error(`MUI X Charts: ${titleCase} series with id="${id}" has no data, no dataKey, and no valueGetter. ` + 'When using the dataset prop, each series must have a dataKey or valueGetter to identify which dataset values to use. ' + 'Add a dataKey or valueGetter property to the series configuration.');
|
|
65
|
+
}
|
|
66
|
+
if (dataKey) {
|
|
67
|
+
const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
|
|
68
|
+
const lowerCase = seriesType === 'line' ? 'lines' : 'radial lines';
|
|
69
|
+
dataset.forEach((entry, index) => {
|
|
70
|
+
const value = entry[dataKey];
|
|
71
|
+
if (value != null && typeof value !== 'number') {
|
|
72
|
+
(0, _warning.warnOnce)(`MUI X Charts: your dataset key "${dataKey}" is used for plotting ${lowerCase}, but the dataset contains the non-null non-numerical element "${value}" at index ${index}.
|
|
73
|
+
${titleCase} plots only support numeric and null values.`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const completedSeries = {};
|
|
81
|
+
stackingGroups.forEach(stackingGroup => {
|
|
82
|
+
const {
|
|
83
|
+
ids,
|
|
84
|
+
stackingOffset,
|
|
85
|
+
stackingOrder
|
|
86
|
+
} = stackingGroup;
|
|
87
|
+
const keys = ids.map(id => {
|
|
88
|
+
const dataKey = series[id].dataKey;
|
|
89
|
+
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
90
|
+
});
|
|
91
|
+
const stackedData = (0, _d3Shape.stack)().keys(keys).value((d, key) => d[key] ?? 0).order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
92
|
+
const idOrder = stackedData.map(s => s.index);
|
|
93
|
+
const fixedOrder = () => idOrder;
|
|
94
|
+
const visibleStackedData = (0, _d3Shape.stack)().keys(keys).value((d, key) => {
|
|
95
|
+
const keyIndex = keys.indexOf(key);
|
|
96
|
+
const seriesId = ids[keyIndex];
|
|
97
|
+
if (!isItemVisible?.({
|
|
98
|
+
type: seriesType,
|
|
99
|
+
seriesId
|
|
100
|
+
})) {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
return d[key] ?? 0;
|
|
104
|
+
}).order(fixedOrder).offset(stackingOffset)(d3Dataset);
|
|
105
|
+
ids.forEach((id, index) => {
|
|
106
|
+
const {
|
|
107
|
+
dataKey,
|
|
108
|
+
valueGetter
|
|
109
|
+
} = series[id];
|
|
110
|
+
let data;
|
|
111
|
+
if (valueGetter) {
|
|
112
|
+
data = dataset.map(d => valueGetter(d));
|
|
113
|
+
} else if (dataKey) {
|
|
114
|
+
data = dataset.map(d => {
|
|
115
|
+
const value = d[dataKey];
|
|
116
|
+
return typeof value === 'number' ? value : null;
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
data = series[id].data;
|
|
120
|
+
}
|
|
121
|
+
const hidden = !isItemVisible?.({
|
|
122
|
+
type: seriesType,
|
|
123
|
+
seriesId: id
|
|
124
|
+
});
|
|
125
|
+
// SAFETY: 'line' and 'radialLine' series inputs are structurally identical for the
|
|
126
|
+
// fields needed to build the defaultized series result. The differing axis-ID fields
|
|
127
|
+
// are passed through via spread without being read.
|
|
128
|
+
completedSeries[id] = (0, _extends2.default)({
|
|
129
|
+
labelMarkType: 'line+mark'
|
|
130
|
+
}, series[id], {
|
|
131
|
+
shape: series[id].shape ?? defaultShapes[(idToIndex.get(id) ?? 0) % defaultShapes.length],
|
|
132
|
+
data,
|
|
133
|
+
valueFormatter: series[id].valueFormatter ?? lineValueFormatter,
|
|
134
|
+
hidden,
|
|
135
|
+
stackedData: stackedData[index],
|
|
136
|
+
visibleStackedData: visibleStackedData[index]
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
seriesOrder,
|
|
142
|
+
stackingGroups,
|
|
143
|
+
series: completedSeries
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
|
|
4
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
5
|
+
import { getStackingGroups } from "./stacking/index.mjs";
|
|
6
|
+
const defaultShapes = ['circle', 'square', 'diamond', 'cross', 'star', 'triangle', 'wye'];
|
|
7
|
+
const lineValueFormatter = v => v == null ? '' : v.toLocaleString();
|
|
8
|
+
export function processLineLikeSeries(params, dataset, isItemVisible, seriesType) {
|
|
9
|
+
const {
|
|
10
|
+
seriesOrder,
|
|
11
|
+
series
|
|
12
|
+
} = params;
|
|
13
|
+
const stackingGroups = getStackingGroups(_extends({}, params, {
|
|
14
|
+
defaultStrategy: {
|
|
15
|
+
stackOffset: 'none'
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
const idToIndex = new Map();
|
|
19
|
+
const d3Dataset = dataset ?? [];
|
|
20
|
+
seriesOrder.forEach((id, seriesIndex) => {
|
|
21
|
+
idToIndex.set(id, seriesIndex);
|
|
22
|
+
const data = series[id].data;
|
|
23
|
+
if (data !== undefined) {
|
|
24
|
+
data.forEach((value, dataIndex) => {
|
|
25
|
+
if (d3Dataset.length <= dataIndex) {
|
|
26
|
+
d3Dataset.push({
|
|
27
|
+
[id]: value
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
d3Dataset[dataIndex][id] = value;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} else if (series[id].valueGetter && dataset) {
|
|
34
|
+
dataset.forEach((entry, dataIndex) => {
|
|
35
|
+
const value = series[id].valueGetter(entry);
|
|
36
|
+
if (d3Dataset.length <= dataIndex) {
|
|
37
|
+
d3Dataset.push({
|
|
38
|
+
[id]: value
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
d3Dataset[dataIndex][id] = value;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
45
|
+
const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
|
|
46
|
+
// TODO: fix mui/no-guarded-throw
|
|
47
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
48
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: ${titleCase} series with id="${id}" has no data. ` + 'The chart cannot render this series without data. ' + 'Provide a data property to the series or use the dataset prop.' : _formatErrorMessage(276, titleCase, id));
|
|
49
|
+
}
|
|
50
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
51
|
+
if (!data && dataset) {
|
|
52
|
+
const dataKey = series[id].dataKey;
|
|
53
|
+
if (!dataKey && !series[id].valueGetter) {
|
|
54
|
+
const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
|
|
55
|
+
// TODO: fix mui/no-guarded-throw
|
|
56
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
57
|
+
throw new Error(`MUI X Charts: ${titleCase} series with id="${id}" has no data, no dataKey, and no valueGetter. ` + 'When using the dataset prop, each series must have a dataKey or valueGetter to identify which dataset values to use. ' + 'Add a dataKey or valueGetter property to the series configuration.');
|
|
58
|
+
}
|
|
59
|
+
if (dataKey) {
|
|
60
|
+
const titleCase = seriesType === 'line' ? 'Line' : 'Radial line';
|
|
61
|
+
const lowerCase = seriesType === 'line' ? 'lines' : 'radial lines';
|
|
62
|
+
dataset.forEach((entry, index) => {
|
|
63
|
+
const value = entry[dataKey];
|
|
64
|
+
if (value != null && typeof value !== 'number') {
|
|
65
|
+
warnOnce(`MUI X Charts: your dataset key "${dataKey}" is used for plotting ${lowerCase}, but the dataset contains the non-null non-numerical element "${value}" at index ${index}.
|
|
66
|
+
${titleCase} plots only support numeric and null values.`);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const completedSeries = {};
|
|
74
|
+
stackingGroups.forEach(stackingGroup => {
|
|
75
|
+
const {
|
|
76
|
+
ids,
|
|
77
|
+
stackingOffset,
|
|
78
|
+
stackingOrder
|
|
79
|
+
} = stackingGroup;
|
|
80
|
+
const keys = ids.map(id => {
|
|
81
|
+
const dataKey = series[id].dataKey;
|
|
82
|
+
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
83
|
+
});
|
|
84
|
+
const stackedData = d3Stack().keys(keys).value((d, key) => d[key] ?? 0).order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
85
|
+
const idOrder = stackedData.map(s => s.index);
|
|
86
|
+
const fixedOrder = () => idOrder;
|
|
87
|
+
const visibleStackedData = d3Stack().keys(keys).value((d, key) => {
|
|
88
|
+
const keyIndex = keys.indexOf(key);
|
|
89
|
+
const seriesId = ids[keyIndex];
|
|
90
|
+
if (!isItemVisible?.({
|
|
91
|
+
type: seriesType,
|
|
92
|
+
seriesId
|
|
93
|
+
})) {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
return d[key] ?? 0;
|
|
97
|
+
}).order(fixedOrder).offset(stackingOffset)(d3Dataset);
|
|
98
|
+
ids.forEach((id, index) => {
|
|
99
|
+
const {
|
|
100
|
+
dataKey,
|
|
101
|
+
valueGetter
|
|
102
|
+
} = series[id];
|
|
103
|
+
let data;
|
|
104
|
+
if (valueGetter) {
|
|
105
|
+
data = dataset.map(d => valueGetter(d));
|
|
106
|
+
} else if (dataKey) {
|
|
107
|
+
data = dataset.map(d => {
|
|
108
|
+
const value = d[dataKey];
|
|
109
|
+
return typeof value === 'number' ? value : null;
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
data = series[id].data;
|
|
113
|
+
}
|
|
114
|
+
const hidden = !isItemVisible?.({
|
|
115
|
+
type: seriesType,
|
|
116
|
+
seriesId: id
|
|
117
|
+
});
|
|
118
|
+
// SAFETY: 'line' and 'radialLine' series inputs are structurally identical for the
|
|
119
|
+
// fields needed to build the defaultized series result. The differing axis-ID fields
|
|
120
|
+
// are passed through via spread without being read.
|
|
121
|
+
completedSeries[id] = _extends({
|
|
122
|
+
labelMarkType: 'line+mark'
|
|
123
|
+
}, series[id], {
|
|
124
|
+
shape: series[id].shape ?? defaultShapes[(idToIndex.get(id) ?? 0) % defaultShapes.length],
|
|
125
|
+
data,
|
|
126
|
+
valueFormatter: series[id].valueFormatter ?? lineValueFormatter,
|
|
127
|
+
hidden,
|
|
128
|
+
stackedData: stackedData[index],
|
|
129
|
+
visibleStackedData: visibleStackedData[index]
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
seriesOrder,
|
|
135
|
+
stackingGroups,
|
|
136
|
+
series: completedSeries
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DefaultizedSeriesType } from "../models/seriesType/index.mjs";
|
|
2
|
+
import type { ChartSeriesType } from "../models/seriesType/config.mjs";
|
|
3
|
+
type LineOrBarSeriesType = Extract<ChartSeriesType, 'line' | 'bar' | 'radialLine' | 'radialBar'>;
|
|
4
|
+
export interface ResolveColorProcessorParams<SeriesType extends LineOrBarSeriesType, V> {
|
|
5
|
+
series: Pick<DefaultizedSeriesType<SeriesType>, 'color' | 'data' | 'colorGetter'>;
|
|
6
|
+
valueColorScale?: (value: number) => string | null;
|
|
7
|
+
categoryColorScale?: (value: V) => string | null;
|
|
8
|
+
categoryValues?: readonly V[];
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveColorProcessor<SeriesType extends LineOrBarSeriesType, V>(params: ResolveColorProcessorParams<SeriesType, V>): (dataIndex?: number) => string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DefaultizedSeriesType } from "../models/seriesType/index.js";
|
|
2
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
3
|
+
type LineOrBarSeriesType = Extract<ChartSeriesType, 'line' | 'bar' | 'radialLine' | 'radialBar'>;
|
|
4
|
+
export interface ResolveColorProcessorParams<SeriesType extends LineOrBarSeriesType, V> {
|
|
5
|
+
series: Pick<DefaultizedSeriesType<SeriesType>, 'color' | 'data' | 'colorGetter'>;
|
|
6
|
+
valueColorScale?: (value: number) => string | null;
|
|
7
|
+
categoryColorScale?: (value: V) => string | null;
|
|
8
|
+
categoryValues?: readonly V[];
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveColorProcessor<SeriesType extends LineOrBarSeriesType, V>(params: ResolveColorProcessorParams<SeriesType, V>): (dataIndex?: number) => string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveColorProcessor = resolveColorProcessor;
|
|
7
|
+
var _getSeriesColorFn = require("./getSeriesColorFn");
|
|
8
|
+
function resolveColorProcessor(params) {
|
|
9
|
+
const {
|
|
10
|
+
series,
|
|
11
|
+
valueColorScale,
|
|
12
|
+
categoryColorScale,
|
|
13
|
+
categoryValues
|
|
14
|
+
} = params;
|
|
15
|
+
const getSeriesColor = (0, _getSeriesColorFn.getSeriesColorFn)(series);
|
|
16
|
+
if (valueColorScale) {
|
|
17
|
+
return dataIndex => {
|
|
18
|
+
if (dataIndex === undefined) {
|
|
19
|
+
return series.color;
|
|
20
|
+
}
|
|
21
|
+
const value = series.data[dataIndex];
|
|
22
|
+
const color = value === null ? getSeriesColor({
|
|
23
|
+
value,
|
|
24
|
+
dataIndex
|
|
25
|
+
}) : valueColorScale(value);
|
|
26
|
+
if (color === null) {
|
|
27
|
+
return getSeriesColor({
|
|
28
|
+
value,
|
|
29
|
+
dataIndex
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return color;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (categoryColorScale && categoryValues) {
|
|
36
|
+
return dataIndex => {
|
|
37
|
+
if (dataIndex === undefined) {
|
|
38
|
+
return series.color;
|
|
39
|
+
}
|
|
40
|
+
const value = categoryValues[dataIndex];
|
|
41
|
+
const fallbackValue = {
|
|
42
|
+
value: series.data[dataIndex],
|
|
43
|
+
dataIndex
|
|
44
|
+
};
|
|
45
|
+
const color = value === null ? getSeriesColor(fallbackValue) : categoryColorScale(value);
|
|
46
|
+
if (color === null) {
|
|
47
|
+
return getSeriesColor(fallbackValue);
|
|
48
|
+
}
|
|
49
|
+
return color;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return dataIndex => {
|
|
53
|
+
if (dataIndex === undefined) {
|
|
54
|
+
return series.color;
|
|
55
|
+
}
|
|
56
|
+
const value = series.data[dataIndex];
|
|
57
|
+
return getSeriesColor({
|
|
58
|
+
value,
|
|
59
|
+
dataIndex
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getSeriesColorFn } from "./getSeriesColorFn.mjs";
|
|
2
|
+
export function resolveColorProcessor(params) {
|
|
3
|
+
const {
|
|
4
|
+
series,
|
|
5
|
+
valueColorScale,
|
|
6
|
+
categoryColorScale,
|
|
7
|
+
categoryValues
|
|
8
|
+
} = params;
|
|
9
|
+
const getSeriesColor = getSeriesColorFn(series);
|
|
10
|
+
if (valueColorScale) {
|
|
11
|
+
return dataIndex => {
|
|
12
|
+
if (dataIndex === undefined) {
|
|
13
|
+
return series.color;
|
|
14
|
+
}
|
|
15
|
+
const value = series.data[dataIndex];
|
|
16
|
+
const color = value === null ? getSeriesColor({
|
|
17
|
+
value,
|
|
18
|
+
dataIndex
|
|
19
|
+
}) : valueColorScale(value);
|
|
20
|
+
if (color === null) {
|
|
21
|
+
return getSeriesColor({
|
|
22
|
+
value,
|
|
23
|
+
dataIndex
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return color;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (categoryColorScale && categoryValues) {
|
|
30
|
+
return dataIndex => {
|
|
31
|
+
if (dataIndex === undefined) {
|
|
32
|
+
return series.color;
|
|
33
|
+
}
|
|
34
|
+
const value = categoryValues[dataIndex];
|
|
35
|
+
const fallbackValue = {
|
|
36
|
+
value: series.data[dataIndex],
|
|
37
|
+
dataIndex
|
|
38
|
+
};
|
|
39
|
+
const color = value === null ? getSeriesColor(fallbackValue) : categoryColorScale(value);
|
|
40
|
+
if (color === null) {
|
|
41
|
+
return getSeriesColor(fallbackValue);
|
|
42
|
+
}
|
|
43
|
+
return color;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return dataIndex => {
|
|
47
|
+
if (dataIndex === undefined) {
|
|
48
|
+
return series.color;
|
|
49
|
+
}
|
|
50
|
+
const value = series.data[dataIndex];
|
|
51
|
+
return getSeriesColor({
|
|
52
|
+
value,
|
|
53
|
+
dataIndex
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The community edition of MUI X Charts components.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"prop-types": "^15.8.1",
|
|
35
35
|
"reselect": "^5.1.1",
|
|
36
36
|
"use-sync-external-store": "^1.6.0",
|
|
37
|
+
"@mui/x-internal-gestures": "^9.3.0",
|
|
37
38
|
"@mui/x-charts-vendor": "^9.0.0",
|
|
38
|
-
"@mui/x-internals": "^9.1.0"
|
|
39
|
-
"@mui/x-internal-gestures": "^9.2.0"
|
|
39
|
+
"@mui/x-internals": "^9.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@emotion/react": "^11.9.0",
|