UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

62 lines (61 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveColorProcessor = resolveColorProcessor; var _getSeriesColorFn = require("./getSeriesColorFn"); function resolveColorProcessor(params) { const { series, valueColorScale, categoryColorScale, categoryValues } = params; 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 (categoryColorScale && categoryValues) { return dataIndex => { if (dataIndex === undefined) { return series.color; } const value = categoryValues[dataIndex]; const fallbackValue = { value: series.data[dataIndex], dataIndex }; const color = value === null ? getSeriesColor(fallbackValue) : categoryColorScale(value); if (color === null) { return getSeriesColor(fallbackValue); } return color; }; } return dataIndex => { if (dataIndex === undefined) { return series.color; } const value = series.data[dataIndex]; return getSeriesColor({ value, dataIndex }); }; }