UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

40 lines (39 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; 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; if (valueColorScale) { return dataIndex => { if (dataIndex === undefined) { return series.color; } const value = series.data[dataIndex]; const color = value === null ? series.color : valueColorScale(value); if (color === null) { return series.color; } return color; }; } if (bandColorScale && bandValues) { return dataIndex => { if (dataIndex === undefined) { return series.color; } const value = bandValues[dataIndex]; const color = value === null ? series.color : bandColorScale(value); if (color === null) { return series.color; } return color; }; } return () => series.color; }; var _default = exports.default = getColor;