UNPKG

@gooddata/react-components

Version:

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

59 lines 2.77 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var colorStrategy_1 = require("../colorStrategy"); var attribute_1 = require("./attribute"); var color_1 = require("../../utils/color"); var utils_1 = require("./utils"); var GeoChartColorStrategy = /** @class */ (function (_super) { __extends(GeoChartColorStrategy, _super); function GeoChartColorStrategy() { return _super !== null && _super.apply(this, arguments) || this; } GeoChartColorStrategy.prototype.createColorAssignment = function (colorPalette, colorMapping, locationAttribute, segmentByAttribute, executionResponse, afm) { // color follows SegmentBy if (segmentByAttribute) { return { fullColorAssignment: this.getColorStrategyForSegmentBy(colorPalette, colorMapping, segmentByAttribute, executionResponse, afm), }; } // color follows Location return { fullColorAssignment: [ this.getColorStrategyForLocation(colorPalette, colorMapping, locationAttribute, executionResponse, afm), ], }; }; GeoChartColorStrategy.prototype.getColorStrategyForSegmentBy = function (colorPalette, colorMapping, segmentByAttribute, executionResponse, afm) { var colorStrategy = new attribute_1.default(colorPalette, colorMapping, null, segmentByAttribute, executionResponse, afm); return colorStrategy.getColorAssignment(); }; GeoChartColorStrategy.prototype.getColorStrategyForLocation = function (colorPalette, colorMapping, locationAttribute, executionResponse, afm) { var mappedColor = color_1.getColorFromMapping(locationAttribute, colorMapping, executionResponse, afm); var color = utils_1.isValidMappedColor(mappedColor, colorPalette) ? mappedColor : { type: "guid", value: colorPalette[0].guid, }; return { headerItem: locationAttribute, color: color, }; }; return GeoChartColorStrategy; }(colorStrategy_1.default)); exports.default = GeoChartColorStrategy; //# sourceMappingURL=geoChart.js.map