UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

61 lines (60 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _getSeriesColorFn = require("../../internals/getSeriesColorFn"); const getColor = (series, xAxis, yAxis) => { const yColorScale = yAxis?.colorScale; const xColorScale = xAxis?.colorScale; const getSeriesColor = (0, _getSeriesColorFn.getSeriesColorFn)(series); if (yColorScale) { return dataIndex => { if (dataIndex === undefined) { return series.color; } const value = series.data[dataIndex]; const color = value === null ? getSeriesColor({ value, dataIndex }) : yColorScale(value); if (color === null) { return getSeriesColor({ value, dataIndex }); } return color; }; } if (xColorScale) { return dataIndex => { if (dataIndex === undefined) { return series.color; } const value = xAxis.data?.[dataIndex]; const color = value === null ? getSeriesColor({ value, dataIndex }) : xColorScale(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;