UNPKG

scichart

Version:

Fast WebGL JavaScript Charting Library and Framework

962 lines (961 loc) 41.3 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.BaseStackedCollection = void 0; var AnimationFiniteStateMachine_1 = require("../../../Core/Animations/AnimationFiniteStateMachine"); var DeletableEntity_1 = require("../../../Core/DeletableEntity"); var Deleter_1 = require("../../../Core/Deleter"); var IWithXYAxes_1 = require("../../../Core/IWithXYAxes"); var NumberRange_1 = require("../../../Core/NumberRange"); var ObservableArray_1 = require("../../../Core/ObservableArray"); var DefaultRenderLayer_1 = require("../../../types/DefaultRenderLayer"); var SearchMode_1 = require("../../../types/SearchMode"); var YRangeMode_1 = require("../../../types/YRangeMode"); var copyVector_1 = require("../../../utils/copyVector"); var guid_1 = require("../../../utils/guid"); var MemoryUsageHelper_1 = require("../../../utils/MemoryUsageHelper"); var BaseDataSeries_1 = require("../../Model/BaseDataSeries"); var animationHelpers_1 = require("./Animations/animationHelpers"); var constants_1 = require("./constants"); /** * A base class for stacked collections, which are used to create stacked mountain or column chart types. * Concrete types are {@link StackedColumnCollection} and {@link StackedMountainCollection} */ var BaseStackedCollection = /** @class */ (function (_super) { __extends(BaseStackedCollection, _super); /** * Creates an instance of the {@link BaseStackedCollection} * @param webAssemblyContext The {@link TSciChart | SciChart WebAssembly Context} containing * native methods and access to our WebGL2 WebAssembly Drawing Engine * @param options Optional parameters of type {@link IBaseStackedCollectionOptions} to configure the series */ function BaseStackedCollection(webAssemblyContext, options) { var _this = this; var _a, _b, _c, _d, _e, _f, _g, _h, _j; _this = _super.call(this) || this; /** @inheritDoc */ _this.id = (0, guid_1.generateGuid)(); /** @inheritDoc */ _this.isStacked = true; /** @inheritDoc */ _this.isCollection = true; _this.isPolar = false; /** @inheritDoc */ _this.supportsResampling = false; /** @inheritDoc */ _this.isSpline = false; /** @inheritDoc */ _this.enableDrawingOptimisations = true; _this.isAccumulatedVectorDirty = true; _this.firstAnimationRender = false; _this.isVisibleProperty = true; _this.isOneHundredPercentProperty = false; _this.animationQueue = []; _this.yRangeModeProperty = YRangeMode_1.EYRangeMode.Drawn; _this.seriesNameProperty = undefined; _this.surfaceRenderOrderProperty = undefined; _this.renderLayerProperty = DefaultRenderLayer_1.EDefaultRenderLayer.SeriesLayer; _this.renderOrderProperty = undefined; _this.webAssemblyContext = webAssemblyContext; _this.isVisibleProperty = (_a = options === null || options === void 0 ? void 0 : options.isVisible) !== null && _a !== void 0 ? _a : _this.isVisibleProperty; _this.xAxisIdProperty = (_b = options === null || options === void 0 ? void 0 : options.xAxisId) !== null && _b !== void 0 ? _b : _this.xAxisIdProperty; _this.yAxisIdProperty = (_c = options === null || options === void 0 ? void 0 : options.yAxisId) !== null && _c !== void 0 ? _c : _this.yAxisIdProperty; _this.isOneHundredPercentProperty = (_d = options === null || options === void 0 ? void 0 : options.isOneHundredPercent) !== null && _d !== void 0 ? _d : _this.isOneHundredPercentProperty; _this.yRangeModeProperty = (_e = options === null || options === void 0 ? void 0 : options.yRangeMode) !== null && _e !== void 0 ? _e : _this.yRangeModeProperty; _this.updateAnimationProperties = _this.updateAnimationProperties.bind(_this); _this.notifyPropertyChanged = _this.notifyPropertyChanged.bind(_this); _this.getParentSurface = _this.getParentSurface.bind(_this); _this.beforeAnimationStart = _this.beforeAnimationStart.bind(_this); _this.afterAnimationComplete = _this.afterAnimationComplete.bind(_this); _this.updateAnimationProperties = _this.updateAnimationProperties.bind(_this); _this.surfaceRenderOrderProperty = (_f = options === null || options === void 0 ? void 0 : options.surfaceRenderOrder) !== null && _f !== void 0 ? _f : _this.surfaceRenderOrderProperty; _this.renderLayerProperty = (_g = options === null || options === void 0 ? void 0 : options.renderLayer) !== null && _g !== void 0 ? _g : _this.renderLayerProperty; _this.renderOrderProperty = (_h = options === null || options === void 0 ? void 0 : options.renderOrder) !== null && _h !== void 0 ? _h : _this.renderOrderProperty; _this.renderNextToProperty = (_j = options === null || options === void 0 ? void 0 : options.renderNextTo) !== null && _j !== void 0 ? _j : _this.renderNextToProperty; _this.accumulatedValues0 = new _this.webAssemblyContext.SCRTDoubleVector(); _this.accumulatedFinalAnimationValues0 = new _this.webAssemblyContext.SCRTDoubleVector(); try { if (process.env.NODE_ENV !== "production") { if (MemoryUsageHelper_1.MemoryUsageHelper.isMemoryUsageDebugEnabled) { return (0, DeletableEntity_1.createTrackableProxy)(_this); } } } catch (err) { console.warn(err); } return _this; } Object.defineProperty(BaseStackedCollection.prototype, "isVisibleChanged", { /** @inheritDoc */ get: function () { throw new Error("getting visibleChanged event is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "selected", { /** @inheritDoc */ get: function () { throw new Error("getting selected event is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "hovered", { /** @inheritDoc */ get: function () { throw new Error("getting hovered event is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "isSelected", { /** @inheritDoc */ get: function () { return false; }, /** @inheritDoc */ set: function (isSelected) { throw new Error("Setting isSelected is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "isHovered", { /** @inheritDoc */ get: function () { return false; }, /** @inheritDoc */ set: function (isHovered) { throw new Error("Setting isHovered is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "isDigitalLine", { /** @inheritDoc */ get: function () { throw new Error("Setting or getting isDigitalLine is not supported for BaseStackedCollection"); }, /** @inheritDoc */ set: function (isDigitalLine) { throw new Error("Setting or getting isDigitalLine is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "isVisible", { /** @inheritDoc */ get: function () { return this.isVisibleProperty; }, /** @inheritDoc */ set: function (isVisible) { this.isVisibleProperty = isVisible; this.notifyPropertyChanged(constants_1.PROPERTY.IS_VISIBLE); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "xAxisId", { /** @inheritDoc */ get: function () { return this.xAxisIdProperty; }, /** @inheritDoc */ set: function (id) { if (id !== this.xAxisIdProperty) { this.xAxisIdProperty = id; this.xAxisProperty = undefined; this.notifyPropertyChanged(constants_1.PROPERTY.XAXIS_ID); } }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "xAxis", { /** @inheritDoc */ get: function () { return this.xAxisProperty; }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "yAxis", { /** @inheritDoc */ get: function () { return this.yAxisProperty; }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "yAxisId", { /** @inheritDoc */ get: function () { return this.yAxisIdProperty; }, /** @inheritDoc */ set: function (id) { if (id !== this.yAxisIdProperty) { this.yAxisIdProperty = id; this.yAxisProperty = undefined; this.notifyPropertyChanged(constants_1.PROPERTY.YAXIS_ID); } }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "seriesName", { /** @inheritDoc */ get: function () { var _a; return (_a = this.seriesNameProperty) !== null && _a !== void 0 ? _a : this.getDataSeriesName(); }, set: function (value) { if (this.seriesNameProperty !== value) { this.seriesNameProperty = value; this.notifyPropertyChanged(constants_1.PROPERTY.SERIES_NAME); } }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "isOneHundredPercent", { /** * Gets or sets 100% mode. When true, the stacked group becomes a 100% stacked chart */ get: function () { return this.isOneHundredPercentProperty; }, /** * Gets or sets 100% mode. When true, the stacked group becomes a 100% stacked chart */ set: function (value) { this.isOneHundredPercentProperty = value; this.notifyPropertyChanged(constants_1.PROPERTY.IS_ONE_HUNDRED_PERCENT); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "yRangeMode", { /** @inheritDoc */ get: function () { return this.yRangeModeProperty; }, set: function (value) { if (this.yRangeModeProperty !== value) { this.yRangeModeProperty = value; this.notifyPropertyChanged(constants_1.PROPERTY.YRANGEMODE); } }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "dataSeries", { // PROPERTIES END // Un-Supported PROPERTIES /** * dataSeries property is not supported for BaseStackedCollection */ get: function () { throw Error("dataSeries property is not supported for BaseStackedCollection"); }, /** * dataSeries property is not supported for BaseStackedCollection */ set: function (value) { throw Error("dataSeries property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "drawNaNAs", { /** * drawNaNAs property is not supported for BaseStackedCollection */ get: function () { throw Error("drawNaNAs property is not supported for BaseStackedCollection"); }, /** * drawNaNAs property is not supported for BaseStackedCollection */ set: function (value) { throw Error("drawNaNAs property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "drawingProviders", { /** * drawingProviders property is not supported for BaseStackedCollection */ get: function () { throw Error("drawingProviders property is not supported for BaseStackedCollection"); }, /** * drawingProviders property is not supported for BaseStackedCollection */ set: function (value) { throw Error("drawingProviders property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "hitTestProvider", { /** * hitTestProvider property is not supported for BaseStackedCollection */ get: function () { throw Error("hitTestProvider property is not supported for BaseStackedCollection, call hitTestProvider on BaseStackedRenderableSeries instead"); }, /** * hitTestProvider property is not supported for BaseStackedCollection */ set: function (value) { throw Error("hitTestProvider property is not supported for BaseStackedCollection, call hitTestProvider on BaseStackedRenderableSeries instead"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "paletteProvider", { /** * paletteProvider property is not supported for BaseStackedCollection */ get: function () { throw Error("paletteProvider property is not supported for BaseStackedCollection"); }, /** * paletteProvider property is not supported for BaseStackedCollection */ set: function (value) { throw Error("paletteProvider property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "pointMarker", { /** * pointMarker property is not supported for BaseStackedCollection */ get: function () { throw Error("pointMarker property is not supported for BaseStackedCollection"); }, /** * pointMarker property is not supported for BaseStackedCollection */ set: function (value) { throw Error("pointMarker property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "rolloverModifierProps", { /** * rolloverModifierProps property is not supported for BaseStackedCollection */ get: function () { throw Error("rolloverModifierProps property is not supported for BaseStackedCollection"); }, /** * rolloverModifierProps property is not supported for BaseStackedCollection */ set: function (value) { throw Error("rolloverModifierProps property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "stroke", { /** * stroke property is not supported for BaseStackedCollection */ get: function () { throw Error("stroke property is not supported for BaseStackedCollection"); }, /** * stroke property is not supported for BaseStackedCollection */ set: function (value) { throw Error("stroke property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "strokeThickness", { /** * strokeThickness property is not supported for BaseStackedCollection */ get: function () { throw Error("strokeThickness property is not supported for BaseStackedCollection"); }, /** * strokeThickness property is not supported for BaseStackedCollection */ set: function (value) { throw Error("strokeThickness property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "effect", { /** * effect property is not supported for BaseStackedCollection */ get: function () { throw Error("effect property is not supported for BaseStackedCollection"); }, /** * effect property is not supported for BaseStackedCollection */ set: function (effect) { throw Error("effect property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "opacity", { /** * opacity property is not supported for BaseStackedCollection */ get: function () { throw Error("opacity property is not supported for BaseStackedCollection"); }, /** * opacity property is not supported for BaseStackedCollection */ set: function (value) { throw Error("effect property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "rolloverModifierProps1", { /** * rolloverModifierProps1() is not supported for BaseStackedCollection */ get: function () { throw Error("rolloverModifierProps1() method is not supported for BaseStackedCollection"); }, /** * rolloverModifierProps1() is not supported for BaseStackedCollection */ set: function (value) { throw Error("rolloverModifierProps1() method is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "resamplingMode", { /** * resamplingMode property is not supported for BaseStackedCollection */ get: function () { throw Error("resamplingMode property is not supported for BaseStackedCollection"); }, set: function (value) { throw Error("resamplingMode property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "resamplingPrecision", { /** * resamplingPrecision property is not supported for BaseStackedCollection */ get: function () { throw Error("resamplingPrecision property is not supported for BaseStackedCollection"); }, set: function (value) { throw Error("resamplingPrecision property is not supported for BaseStackedCollection"); }, enumerable: false, configurable: true }); /** @inheritDoc */ BaseStackedCollection.prototype.getSurfaceRenderOrder = function () { var _a, _b; return (_a = this.surfaceRenderOrderProperty) !== null && _a !== void 0 ? _a : (_b = this.parentSurface) === null || _b === void 0 ? void 0 : _b.getSurfaceRenderOrder(); }; /** @inheritDoc */ BaseStackedCollection.prototype.setSurfaceRenderOrder = function (value) { if (this.surfaceRenderOrderProperty != value) { this.surfaceRenderOrderProperty = value; this.notifyPropertyChanged(constants_1.PROPERTY.SURFACE_RENDER_ORDER); } }; /** * The render layer grouping within which the series will be draw. Defaults to EDefaultRenderLayer.SeriesLayer (5) */ BaseStackedCollection.prototype.getRenderLayer = function () { if (this.renderLayerProperty === DefaultRenderLayer_1.EDefaultRenderLayer.SeriesLayer) { if (this.isSelected) return DefaultRenderLayer_1.EDefaultRenderLayer.SelectedSeriesLayer; if (this.isHovered) return DefaultRenderLayer_1.EDefaultRenderLayer.HoveredSeriesLayer; } return this.renderLayerProperty; }; /** * The render layer grouping within which the series will be draw. Defaults to EDefaultRenderLayer.SeriesLayer (5) */ BaseStackedCollection.prototype.setRenderLayer = function (value) { if (this.renderLayerProperty != value) { this.renderLayerProperty = value; this.notifyPropertyChanged(constants_1.PROPERTY.RENDER_LAYER); } }; /** @inheritDoc */ BaseStackedCollection.prototype.getRenderOrder = function () { return this.renderOrderProperty; }; /** @inheritDoc */ BaseStackedCollection.prototype.setRenderOrder = function (value) { if (this.renderOrderProperty != value) { this.renderOrderProperty = value; this.notifyPropertyChanged(constants_1.PROPERTY.RENDER_LAYER); } }; /** @inheritDoc */ BaseStackedCollection.prototype.setRenderNextTo = function (renderable, offset) { if (offset === void 0) { offset = 0; } if (renderable === undefined) { this.renderNextToProperty = undefined; } else { this.renderNextToProperty = { renderable: renderable, offset: offset }; } }; /** @inheritDoc */ BaseStackedCollection.prototype.getRenderNextTo = function () { return this.renderNextToProperty; }; /** * Notify the collection that the accumulated values need to be recalculated */ BaseStackedCollection.prototype.setAccumulatedValuesDirty = function () { this.isAccumulatedVectorDirty = true; }; /** @inheritDoc */ BaseStackedCollection.prototype.getIndicesRange = function (xRange) { throw Error("getIndicesRange() method is not supported for BaseStackedCollection"); }; /** @inheritDoc */ BaseStackedCollection.prototype.getDataPointWidth = function (xCoordCalc, widthFraction, widthMode) { throw Error("getDataPointWidth() method is not supported for BaseStackedCollection"); }; Object.defineProperty(BaseStackedCollection.prototype, "canDraw", { get: function () { return animationHelpers_1.animationHelpers.checkCanDraw(this.animationFSM); }, enumerable: false, configurable: true }); /** @inheritDoc */ BaseStackedCollection.prototype.pushPalettedColors = function (color, palettingState) { throw new Error("Method not implemented."); }; /** @inheritDoc */ BaseStackedCollection.prototype.getSeriesInfo = function (hitTestInfo) { throw new Error("Method not implemented."); }; /** @inheritDoc */ BaseStackedCollection.prototype.applyTheme = function (themeProvider) { this.asArray().forEach(function (rs) { rs.applyTheme(themeProvider); }); }; /** @inheritDoc */ BaseStackedCollection.prototype.delete = function () { this.accumulatedValues0 = (0, Deleter_1.deleteSafe)(this.accumulatedValues0); this.accumulatedFinalAnimationValues0 = (0, Deleter_1.deleteSafe)(this.accumulatedFinalAnimationValues0); this.dataLabelProviderProperty = (0, Deleter_1.deleteSafe)(this.dataLabelProvider); this.asArray().forEach(function (series) { series.delete(); }); }; /** @inheritDoc */ BaseStackedCollection.prototype.notifyPropertyChanged = function (propertyName) { this.invalidateParent(); }; /** @inheritDoc */ BaseStackedCollection.prototype.onDpiChanged = function (args) { this.asArray().forEach(function (rs) { return rs.onDpiChanged(args); }); }; /** @inheritDoc */ BaseStackedCollection.prototype.getBaseXValues = function () { // TODO: find out do we need this method at all return []; }; /** @inheritDoc */ BaseStackedCollection.prototype.getDataSeriesName = function () { // TODO: come up with some better name return "Stacked Collection"; }; /** @inheritDoc */ BaseStackedCollection.prototype.getDataSeriesValuesCount = function () { if (!this.getNativeXValues()) { return undefined; } return this.getNativeXValues().size(); }; Object.defineProperty(BaseStackedCollection.prototype, "isRunningDataAnimation", { /** * gets if a data animation is currently running */ get: function () { return (this.isRunningAnimation && this.animationFSM && (this.animationFSM.animation.isDataSeriesAnimation || this.animationFSM.animation.isOnStartAnimation)); }, enumerable: false, configurable: true }); /** @inheritDoc */ BaseStackedCollection.prototype.getNativeXValues = function () { var _a; if (this.size() === 0) { return undefined; } return (_a = this.get(0).dataSeries) === null || _a === void 0 ? void 0 : _a.getNativeXValues(); }; BaseStackedCollection.prototype.getNativeYValues = function () { throw Error("getNativeYValues() method is not supported for BaseStackedCollection"); }; /** @inheritDoc */ BaseStackedCollection.prototype.getYRange = function (xVisibleRange, isXCategoryAxis) { var _this = this; if (!this.isEnoughDataToDraw()) { return new NumberRange_1.NumberRange(); } this.updateAccumulatedVectors(); // Just in case var maxRange; this.getVisibleSeries().forEach(function (rs) { if (rs.accumulatedValues.size() === _this.getNativeXValues().size()) { var range = (0, BaseDataSeries_1.getWindowedYRange)(_this.webAssemblyContext, _this.getNativeXValues(), rs.getAccumulatedValues(_this.isRunningDataAnimation), xVisibleRange, true, isXCategoryAxis, rs.dataSeries.dataDistributionCalculator.isSortedAscending, true, // Potential optimisation, if we know for certain data does not containsNaN, we can use SIMD ops _this.yRangeMode === YRangeMode_1.EYRangeMode.Visible ? SearchMode_1.ESearchMode.RoundUp : SearchMode_1.ESearchMode.RoundDown, _this.yRangeMode === YRangeMode_1.EYRangeMode.Visible ? SearchMode_1.ESearchMode.RoundDown : SearchMode_1.ESearchMode.RoundUp); if (range) { maxRange = maxRange ? maxRange.union(range) : range; } } }); if (maxRange) return maxRange; return new NumberRange_1.NumberRange(); }; /** @inheritDoc */ BaseStackedCollection.prototype.hasDataSeries = function () { return !!this.getNativeXValues(); }; /** @inheritDoc */ BaseStackedCollection.prototype.hasStrokePaletteProvider = function () { // TODO: implement return false; }; /** @inheritDoc */ BaseStackedCollection.prototype.hasFillPaletteProvider = function () { // TODO: implement return false; }; /** @inheritDoc */ BaseStackedCollection.prototype.hasPointMarkerPaletteProvider = function () { // TODO: implement return false; }; /** @inheritDoc */ BaseStackedCollection.prototype.onAttach = function (scs) { this.parentSurface = scs; this.linkAxes(); if (this.invalidateParentCallback) { throw new Error("Invalid operation in sciChartSurface.attachSeries, this series has already been attached to a SciChartSurface. Please detach it from a SciChartSurface before attaching to another"); } this.invalidateParentCallback = scs.invalidateElement; }; /** @inheritDoc */ BaseStackedCollection.prototype.onDetach = function () { this.invalidateParentCallback = undefined; this.parentSurface = undefined; }; /** * Gets visible renderable series array */ BaseStackedCollection.prototype.getVisibleSeries = function () { return this.asArray().filter(function (el) { return el.isVisible; }); }; /** @inheritDoc */ BaseStackedCollection.prototype.enqueueAnimation = function (animation) { this.animationQueue.push(animation); this.invalidateParent(); }; /** @inheritDoc */ BaseStackedCollection.prototype.runAnimation = function (animation) { this.animationQueue = []; this.animationFSM.toCompleted(); this.afterAnimationComplete(); }; Object.defineProperty(BaseStackedCollection.prototype, "animation", { /** * Sets a start up animation class, a child class for {@link BaseAnimation} */ set: function (value) { if (value) { this.animationQueue.push(value); } this.invalidateParent(); }, enumerable: false, configurable: true }); Object.defineProperty(BaseStackedCollection.prototype, "isRunningAnimation", { /** @inheritDoc */ get: function () { if (animationHelpers_1.animationHelpers.checkIsAnimationRunning(this.animationQueue, this.animationFSM)) { return true; } if (this.getVisibleSeries().some(function (s) { return s.isRunningAnimation; })) { return true; } return false; }, enumerable: false, configurable: true }); /** @inheritDoc */ BaseStackedCollection.prototype.onAnimate = function (timeElapsed) { var _a; if (!this.animationFSM || ((_a = this.animationFSM) === null || _a === void 0 ? void 0 : _a.is([AnimationFiniteStateMachine_1.EAnimationState.Completed]))) { if (this.animationQueue.length >= 1) { var animation = this.animationQueue.shift(); this.animationFSM = new AnimationFiniteStateMachine_1.SeriesAnimationFiniteStateMachine(animation, undefined); } else { this.animationFSM = undefined; } } this.getVisibleSeries().forEach(function (rs) { if (rs.isRunningAnimation) { rs.onAnimate(timeElapsed); } }); if (!this.animationFSM) return; animationHelpers_1.animationHelpers.animationUpdate(this.animationFSM, timeElapsed, this.beforeAnimationStart, this.afterAnimationComplete, this.updateAnimationProperties); }; /** * checkIsOutOfDataRange() is not supported for BaseStackedCollection * @param xValue * @param yValue */ BaseStackedCollection.prototype.checkIsOutOfDataRange = function (xValue, yValue) { throw Error("checkIsOutOfDataRange() method is not supported for BaseStackedCollection"); }; /** @inheritDoc */ BaseStackedCollection.prototype.toPointSeries = function (resamplingParams) { // not used for BaseStackedCollection return undefined; }; /** * getCurrentRenderPassData method is not supported for BaseStackedCollection */ BaseStackedCollection.prototype.getCurrentRenderPassData = function () { return this.currentRenderPassData; }; /** @inheritDoc */ BaseStackedCollection.prototype.setCurrentRenderPassData = function (renderPassData) { this.currentRenderPassData = renderPassData; this.updateHitTestProviders(renderPassData); }; /** @inheritDoc */ BaseStackedCollection.prototype.getResamplingParams = function () { return undefined; }; Object.defineProperty(BaseStackedCollection.prototype, "dataLabelProvider", { /** @inheritDoc */ get: function () { return this.dataLabelProviderProperty; }, /** @inheritDoc */ set: function (provider) { this.dataLabelProviderProperty = provider; provider.onAttach(this.webAssemblyContext, this); this.notifyPropertyChanged(constants_1.PROPERTY.SERIES_TEXT_PROVIDER); }, enumerable: false, configurable: true }); /** @inheritDoc */ BaseStackedCollection.prototype.toJSON = function (excludeData) { var _a; if (excludeData === void 0) { excludeData = false; } var series = []; for (var _i = 0, _b = this.asArray(); _i < _b.length; _i++) { var subSeries = _b[_i]; series.push(subSeries.toJSON(excludeData)); } var renderNextTo = this.getRenderNextTo(); var serializedRenderNextTo = renderNextTo && { renderable: typeof renderNextTo.renderable === "string" ? renderNextTo.renderable : renderNextTo.renderable.id, offset: renderNextTo.offset }; var options = { isVisible: this.isVisible, isOneHundredPercent: this.isOneHundredPercent, xAxisId: this.xAxisId, yAxisId: this.yAxisId, yRangeMode: this.yRangeMode, // @ts-ignore dataLabelProvider: (_a = this.dataLabelProvider) === null || _a === void 0 ? void 0 : _a.toJSON(), surfaceRenderOrder: this.surfaceRenderOrderProperty, renderLayer: this.getRenderLayer(), renderOrder: this.getRenderOrder(), renderNextTo: serializedRenderNextTo }; // @ts-ignore return { type: this.type, series: series, options: options }; }; /** @inheritDoc */ BaseStackedCollection.prototype.resolveAutoColors = function (index, maxSeries, theme) { throw Error("resolveAutoColors method is not supported for BaseStackedCollection. Call on collection items individually"); }; /** @inheritDoc */ BaseStackedCollection.prototype.adjustAutoColor = function (propertyName, color) { return color; }; /** @inheritDoc */ BaseStackedCollection.prototype.linkAxes = function () { (0, IWithXYAxes_1.updateAxisIds)(this); if (!this.parentSurface) return; if (!this.xAxisProperty && this.xAxisId) { var xAxis = this.parentSurface.getXAxisById(this.xAxisId); if (xAxis) { this.xAxisProperty = xAxis; } else { console.warn("StackedCollection looked for xAxis Id \"".concat(this.xAxisId, "\" but did not find. Default xAxis will be used")); this.xAxisProperty = this.parentSurface.getDefaultXAxis(); } } if (!this.yAxisProperty && this.yAxisId) { var yAxis = this.parentSurface.getYAxisById(this.yAxisId); if (yAxis) { this.yAxisProperty = yAxis; } else { console.warn("StackedCollection looked for yAxis Id \"".concat(this.yAxisId, "\" but did not find. Default yAxis will be used")); this.yAxisProperty = this.parentSurface.getDefaultYAxis(); } } }; BaseStackedCollection.prototype.isAllDataSeriesSet = function () { var isDataSeriesSet = true; this.asArray().forEach(function (el) { if (!el.dataSeries) { isDataSeriesSet = false; } }); return isDataSeriesSet; }; /** * notifies listeners to {@link invalidateParentCallback} and redraws the {@link SciChartSurface} */ BaseStackedCollection.prototype.invalidateParent = function () { if (this.invalidateParentCallback) { this.invalidateParentCallback(); } }; /** * Gets the first series in the collection, else undefined */ BaseStackedCollection.prototype.getFirstSeries = function () { if (this.size() === 0) { return undefined; } return this.get(0); }; /** * Gets the parent {@link SciChartSurface} */ BaseStackedCollection.prototype.getParentSurface = function () { return this.parentSurface; }; /** * Runs before the animation starts * @protected */ BaseStackedCollection.prototype.beforeAnimationStart = function () { this.updateAccumulatedVectors(); (0, copyVector_1.copyDoubleVector)(this.accumulatedValues0, this.accumulatedFinalAnimationValues0, this.webAssemblyContext); this.getVisibleSeries().forEach(function (rs) { rs.beforeAnimationStart(); }); }; /** * Runs after the animation is complete * @protected */ BaseStackedCollection.prototype.afterAnimationComplete = function () { this.getVisibleSeries().forEach(function (rs) { rs.afterAnimationComplete(); }); }; /** * Internal method that runs on each animation tick * @param progress The current animation progress, a value from 0 to 1 * @param animationFSM The animation finite state machine * @protected */ BaseStackedCollection.prototype.updateAnimationProperties = function (progress, animationFSM) { if (this.isAllDataSeriesSet()) { animationFSM.animation.calculateAnimationValues(this.webAssemblyContext, this.accumulatedFinalAnimationValues0, this.accumulatedValues0, progress); this.getVisibleSeries().forEach(function (rs) { rs.updateAnimationProperties(progress, animationFSM); }); } if (this.invalidateParentCallback) { this.invalidateParentCallback(); } }; BaseStackedCollection.prototype.updateHitTestProviders = function (renderPassData) { this.getVisibleSeries().forEach(function (el) { var _a; (_a = el.hitTestProvider) === null || _a === void 0 ? void 0 : _a.update(renderPassData); }); }; BaseStackedCollection.prototype.isEnoughDataToDraw = function () { var stackedSeriesCount = this.getVisibleSeries().length; if (stackedSeriesCount < 1) { return false; } // All renderableSeries should have dataSeries property for (var i = 0; i < stackedSeriesCount; i++) { if (!this.get(i).dataSeries) { return false; } } // All dataSeries should have some values for (var i = 0; i < stackedSeriesCount; i++) { if (this.get(i).dataSeries.count() === 0) { return false; } } return true; }; return BaseStackedCollection; }(ObservableArray_1.ObservableArray)); exports.BaseStackedCollection = BaseStackedCollection;