UNPKG

@patternfly/react-charts

Version:

This library provides a set of React chart components for use with the PatternFly reference implementation.

100 lines 4.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBulletThemeWithLegendColorScale = exports.getColorScale = void 0; const chart_bullet_data_1 = require("./chart-bullet-data"); const chart_theme_types_1 = require("../../ChartUtils/chart-theme-types"); const ChartThemeColor_1 = require("../../ChartTheme/ChartThemeColor"); const skeleton_theme_1 = require("../../ChartTheme/themes/colors/skeleton-theme"); /** * Returns legend color scale * * @private Not intended as public API and subject to change */ const getLegendColorScale = (computedData, legendData) => { const colorScale = []; legendData.forEach((data, index) => { for (const i of computedData) { if (index === i._index) { colorScale.push(i._color); } } }); return colorScale; }; /** * Returns color scale * * @private Not intended as public API and subject to change */ const getColorScale = ({ comparativeErrorMeasureData, comparativeErrorMeasureLegendData, comparativeWarningMeasureData, comparativeWarningMeasureLegendData, invert, primaryDotMeasureData, primaryDotMeasureLegendData, primarySegmentedMeasureData, primarySegmentedMeasureLegendData, qualitativeRangeData, qualitativeRangeLegendData, themeColor }) => { const colorScale = []; if (primaryDotMeasureLegendData && primaryDotMeasureLegendData.length) { const computedData = (0, chart_bullet_data_1.getPrimaryDotMeasureData)({ data: primaryDotMeasureData, invert }); colorScale.push(...getLegendColorScale(computedData, primaryDotMeasureLegendData)); } if (primarySegmentedMeasureLegendData && primarySegmentedMeasureLegendData.length) { const computedData = (0, chart_bullet_data_1.getPrimarySegmentedMeasureData)({ data: primarySegmentedMeasureData, invert, themeColor }); colorScale.push(...getLegendColorScale(computedData, primarySegmentedMeasureLegendData)); } if (comparativeWarningMeasureLegendData && comparativeWarningMeasureLegendData.length) { const computedData = (0, chart_bullet_data_1.getComparativeWarningMeasureData)({ data: comparativeWarningMeasureData, invert, themeColor }); colorScale.push(...getLegendColorScale(computedData, comparativeWarningMeasureLegendData)); } if (comparativeErrorMeasureLegendData && comparativeErrorMeasureLegendData.length) { const computedData = (0, chart_bullet_data_1.getComparativeErrorMeasureData)({ data: comparativeErrorMeasureData, invert, themeColor }); colorScale.push(...getLegendColorScale(computedData, comparativeErrorMeasureLegendData)); } if (qualitativeRangeLegendData && qualitativeRangeLegendData.length) { const computedData = (0, chart_bullet_data_1.getQualitativeRangeData)({ data: qualitativeRangeData, invert }); colorScale.push(...getLegendColorScale(computedData, qualitativeRangeLegendData)); } return colorScale; }; exports.getColorScale = getColorScale; /** * Returns bullet chart theme with legend color scale * * @private Not intended as public API and subject to change */ const getBulletThemeWithLegendColorScale = ({ comparativeErrorMeasureData, comparativeErrorMeasureLegendData, comparativeWarningMeasureData, comparativeWarningMeasureLegendData, invert, primaryDotMeasureData, primaryDotMeasureLegendData, primarySegmentedMeasureData, primarySegmentedMeasureLegendData, qualitativeRangeData, qualitativeRangeLegendData, themeColor }) => { const colorScale = (0, exports.getColorScale)({ comparativeErrorMeasureData, comparativeErrorMeasureLegendData, comparativeWarningMeasureData, comparativeWarningMeasureLegendData, invert, primaryDotMeasureData, primaryDotMeasureLegendData, primarySegmentedMeasureData, primarySegmentedMeasureLegendData, qualitativeRangeData, qualitativeRangeLegendData, themeColor }); const theme = (0, chart_theme_types_1.getBulletTheme)(themeColor); theme.legend.colorScale = [...colorScale]; if (themeColor === ChartThemeColor_1.ChartThemeColor.skeleton) { theme.legend.colorScale = skeleton_theme_1.SkeletonColorTheme.legend.colorScale; } return theme; }; exports.getBulletThemeWithLegendColorScale = getBulletThemeWithLegendColorScale; //# sourceMappingURL=chart-bullet-theme.js.map