UNPKG

@carto/airship-bridge

Version:

Airship bridge to other libs (CARTO VL, CARTO.js)

74 lines (73 loc) 3.22 kB
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 __()); }; })(); import { select } from '../../util/Utils'; import { BaseFilter } from '../base/BaseFilter'; /** * Base class for Filters based on Airship Histogram Widgets * * @export * @abstract * @class BaseHistogramFilter * @extends {BaseFilter} * @template T Type of the selection. Typicall an array of number or strings */ var BaseHistogramFilter = /** @class */ (function (_super) { __extends(BaseHistogramFilter, _super); /** * Creates an instance of BaseHistogramFilter. * @param {('categorical' | 'numerical')} type Whether it is a categorical or a numerical histogram * @param {*} carto The CARTO VL namespace * @param {*} layer A CARTO VL layer * @param {(any | string)} histogram An Airship Histogram or TimeSeries HTML element, or a selector * @param {string} columnName The column to pull data from * @param {*} source A CARTO VL source * @param {boolean} [readOnly=true] Whether the widget will be able to filter the visualization or not * @param {object} [inputExpression=null] VL Expression to use instead of s.prop for the histogram input * @memberof BaseHistogramFilter */ function BaseHistogramFilter(type, carto, layer, histogram, columnName, source, readOnly, weight, showTotals, inputExpression) { if (readOnly === void 0) { readOnly = true; } if (showTotals === void 0) { showTotals = false; } if (inputExpression === void 0) { inputExpression = null; } var _this = _super.call(this, "histogram_" + type, carto, columnName, layer, source, readOnly, weight) || this; _this._selection = null; _this._inputExpression = null; _this._totals = false; _this._widget = select(histogram); _this._carto = carto; _this._totals = showTotals; _this._widget.disableInteractivity = readOnly; _this._widget.showClearButton = !readOnly; _this._inputExpression = inputExpression; _this.selectionChanged = _this.selectionChanged.bind(_this); if (!readOnly) { _this._widget.addEventListener('selectionChanged', _this.selectionChanged); } return _this; } BaseHistogramFilter.prototype.removeHistogramLayer = function () { this._layer.remove(); }; BaseHistogramFilter.prototype.setDataLayer = function (layer) { this._dataLayer = layer; this.bindDataLayer(); }; BaseHistogramFilter.prototype._getLegendConfig = function () { return { samples: this._buckets }; }; return BaseHistogramFilter; }(BaseFilter)); export { BaseHistogramFilter };