@mui/x-charts
Version:
The community edition of MUI X Charts components.
63 lines (62 loc) • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _getSeriesColorFn = require("../../../internals/getSeriesColorFn");
const getColor = (series, xAxis, yAxis) => {
const verticalLayout = series.layout === 'vertical';
const bandColorScale = verticalLayout ? xAxis?.colorScale : yAxis?.colorScale;
const valueColorScale = verticalLayout ? yAxis?.colorScale : xAxis?.colorScale;
const bandValues = verticalLayout ? xAxis?.data : yAxis?.data;
const getSeriesColor = (0, _getSeriesColorFn.getSeriesColorFn)(series);
if (valueColorScale) {
return dataIndex => {
if (dataIndex === undefined) {
return series.color;
}
const value = series.data[dataIndex];
const color = value === null ? getSeriesColor({
value,
dataIndex
}) : valueColorScale(value);
if (color === null) {
return getSeriesColor({
value,
dataIndex
});
}
return color;
};
}
if (bandColorScale && bandValues) {
return dataIndex => {
if (dataIndex === undefined) {
return series.color;
}
const value = bandValues[dataIndex];
const color = value === null ? getSeriesColor({
value,
dataIndex
}) : bandColorScale(value);
if (color === null) {
return getSeriesColor({
value,
dataIndex
});
}
return color;
};
}
return dataIndex => {
if (dataIndex === undefined) {
return series.color;
}
const value = series.data[dataIndex];
return getSeriesColor({
value,
dataIndex
});
};
};
var _default = exports.default = getColor;