UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

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