UNPKG

scichart

Version:

Fast WebGL JavaScript Charting Library and Framework

111 lines (110 loc) 5.44 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ChartModifierBase3D = void 0; var ChartModifierBase_1 = require("../../Charting/ChartModifiers/ChartModifierBase"); var IncludedItems_1 = require("../../Core/IncludedItems"); var ModifierType_1 = require("../../types/ModifierType"); /** * Defines a base class to a ChartModifier3D - a class which provides Zoom, Pan, Tooltip or interaction behavior * to SciChart - High Performance Realtime {@link https://www.scichart.com/javascript-chart-features | JavaScript 3D Charts} */ var ChartModifierBase3D = /** @class */ (function (_super) { __extends(ChartModifierBase3D, _super); /** * Creates an instance of a {@link ChartModifierBase3D} * @param options Optional parameters of type {@link IChartModifierBase3DOptions} used to configure the modifier */ function ChartModifierBase3D(options) { var _this = this; var _a, _b, _c, _d; _this = _super.call(this, options) || this; // used to track if registered types were used for function properties, so they can be serialized _this.typeMap = new Map(); /** * The helper property to get and set the list of included renderable series */ _this.includedSeries = new IncludedItems_1.IncludedItems(); if (((_a = options === null || options === void 0 ? void 0 : options.includedSeriesIds) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = options === null || options === void 0 ? void 0 : options.excludedSeriesIds) === null || _b === void 0 ? void 0 : _b.length) > 0) { throw new Error("You should either use `includedSeriesIds` or `excludedSeriesIds`, not both."); } if (((_c = options === null || options === void 0 ? void 0 : options.includedSeriesIds) === null || _c === void 0 ? void 0 : _c.length) > 0) { _this.includedSeries.includeList(options.includedSeriesIds); } if (((_d = options === null || options === void 0 ? void 0 : options.excludedSeriesIds) === null || _d === void 0 ? void 0 : _d.length) > 0) { _this.includedSeries.excludeList(options.excludedSeriesIds); } return _this; } Object.defineProperty(ChartModifierBase3D.prototype, "modifierType", { /** * @inheritDoc */ get: function () { return ModifierType_1.EModifierType.Chart3DModifier; }, enumerable: false, configurable: true }); /** * Gets all series on the parent surface. * @remarks This function allows mocking in tests */ ChartModifierBase3D.prototype.getAllSeries = function () { return this.parentSurface.renderableSeries.asArray(); }; /** * Tests if the series is included or excluded, by default it must also be visible to be included. * To ignore the visibility check, override this with * ```return this.includedSeries.testIsIncluded(series.id);``` * @param series * @private */ ChartModifierBase3D.prototype.testIsIncludedSeries = function (series) { return series.isVisible && this.includedSeries.testIsIncluded(series.id); }; /** * Includes renderable series. Returns True if the included items list has changed after the operation. */ ChartModifierBase3D.prototype.includeSeries = function (series, isIncluded) { if (isIncluded) { return this.includedSeries.include(series.id); } else { return this.includedSeries.exclude(series.id); } }; /** * Returns all visible and included renderable series. The list also contains included visible stacked renderable series * This calls this.testIsIncludedSeries so it is best to customise the including check behaviour there. */ ChartModifierBase3D.prototype.getIncludedRenderableSeries = function () { var _this = this; return this.getAllSeries().filter(function (rs) { return _this.testIsIncludedSeries(rs); }); }; ChartModifierBase3D.prototype.toJSON = function () { var options = { id: this.id, executeCondition: this.executeCondition, includedSeriesIds: this.includedSeries.getIncludedItemIds(), excludedSeriesIds: this.includedSeries.getExcludedItemIds() }; return { type: this.type, options: options }; }; return ChartModifierBase3D; }(ChartModifierBase_1.ChartModifierBase)); exports.ChartModifierBase3D = ChartModifierBase3D;