UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

53 lines 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var color_1 = require("../utils/color"); var common_1 = require("../utils/common"); var visualizationTypes_1 = require("../../../constants/visualizationTypes"); var measure_1 = require("./colorStrategies/measure"); var attribute_1 = require("./colorStrategies/attribute"); var heatmap_1 = require("./colorStrategies/heatmap"); var treemap_1 = require("./colorStrategies/treemap"); var scatterPlot_1 = require("./colorStrategies/scatterPlot"); var bubbleChart_1 = require("./colorStrategies/bubbleChart"); var bulletChart_1 = require("./colorStrategies/bulletChart"); exports.attributeChartSupportedTypes = [ visualizationTypes_1.VisualizationTypes.PIE, visualizationTypes_1.VisualizationTypes.DONUT, visualizationTypes_1.VisualizationTypes.FUNNEL, visualizationTypes_1.VisualizationTypes.SCATTER, visualizationTypes_1.VisualizationTypes.BUBBLE, ]; function isAttributeColorPalette(type, afm, stackByAttribute) { var attributeChartSupported = common_1.isOneOfTypes(type, exports.attributeChartSupportedTypes); return stackByAttribute || (attributeChartSupported && afm.attributes && afm.attributes.length > 0); } exports.isAttributeColorPalette = isAttributeColorPalette; var ColorFactory = /** @class */ (function () { function ColorFactory() { } ColorFactory.getColorStrategy = function (colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm, type, occupiedMeasureBucketsLocalIdentifiers) { if (colorPalette === void 0) { colorPalette = color_1.DEFAULT_COLOR_PALETTE; } if (common_1.isHeatmap(type)) { return new heatmap_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm); } if (common_1.isTreemap(type)) { return new treemap_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm); } if (common_1.isScatterPlot(type)) { return new scatterPlot_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm); } if (common_1.isBubbleChart(type)) { return new bubbleChart_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm); } if (common_1.isBulletChart(type)) { return new bulletChart_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm, occupiedMeasureBucketsLocalIdentifiers); } if (isAttributeColorPalette(type, afm, stackByAttribute)) { return new attribute_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm); } return new measure_1.default(colorPalette, colorMapping, viewByAttribute, stackByAttribute, executionResponse, afm); }; return ColorFactory; }()); exports.ColorFactory = ColorFactory; //# sourceMappingURL=colorFactory.js.map