UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

297 lines (293 loc) 11.4 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { delegateCombine, delegateRemove, TypeRegistrar } from "igniteui-react-core"; import { isValidProp, getModifiedProps, toPoint, ensureBool, NamePatcher } from "igniteui-react-core"; import { IgrStackedSeriesCreatedEventArgs } from './igr-stacked-series-created-event-args'; import { IgrCategorySeries } from './igr-category-series'; import { NotifyCollectionChangedAction } from "igniteui-react-core"; import { CollectionAdapter } from "igniteui-react-core"; import { ContentChildrenManager } from "igniteui-react-core"; import { IgrStackedSeriesCollection } from './igr-stacked-series-collection'; /** * Represents a base class for stacked series. */ var IgrStackedSeriesBase = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrStackedSeriesBase, _super); function IgrStackedSeriesBase(props) { var _this = _super.call(this, props) || this; /** * The series actually present in the chart. Do not directly modify this array. * This array's contents can be modified by causing React to reproject the child content. * Or adding and removing series from the manual series collection on the series property. */ _this.actualSeries = []; _this.contentSeries = []; _this._series = null; _this._seriesAdapter = null; _this._seriesCreated = null; _this._seriesCreated_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._seriesAdapter = new CollectionAdapter(_this.contentSeries, _this.i.series, _this.actualSeries, function (c) { return c.i; }, function (i) { i.owner = _this; i.provideRenderer(_this._renderer); // i.provideData(this._dataSource); // i.bindAxes(this.actualAxes); // this._ensureDefaultTooltip(i); // this._ensureTooltipCreated(i); }, function (i) { i.provideRenderer(null); // i.provideData(null); }); _this._contentChildrenManager = new ContentChildrenManager(function (ch) { return ch.key || ch.props.name; }, function (ch) { return ch.key || ch.props.name; }, function () { return _this._updateContentChildren(); }); return _this; } IgrStackedSeriesBase.prototype.createImplementation = function () { return null; }; Object.defineProperty(IgrStackedSeriesBase.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgrStackedSeriesBase.prototype.initializeProperties = function () { var e_1, _a; try { for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = this.props[p]; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } }; IgrStackedSeriesBase.prototype.componentDidMount = function () { this.initializeProperties(); }; IgrStackedSeriesBase.prototype.shouldComponentUpdate = function (nextProps, nextState) { var e_2, _a; var mod = getModifiedProps(this.props, nextProps); try { for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = mod[p]; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } return true; }; IgrStackedSeriesBase.prototype.render = function () { var children = this._contentChildrenManager.getChildren(this.props.children); var div = React.createElement("div", { children: children }); return div; }; IgrStackedSeriesBase._createFromInternal = function (internal) { if (!internal) { return null; } if (!internal.$type) { return null; } var name = internal.$type.name; var externalName = "Igr" + name; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); }; IgrStackedSeriesBase.prototype._updateContentChildren = function () { this.contentSeries.length = 0; var contentChildrenActual = this._contentChildrenManager.contentChildrenActual; for (var i = 0; i < contentChildrenActual.length; i++) { this.contentSeries.push(contentChildrenActual[i]); } if (this._seriesAdapter !== null) { this._seriesAdapter.notifyContentChanged(); } }; Object.defineProperty(IgrStackedSeriesBase.prototype, "series", { /** * A collection or manually added series for the chart. */ get: function () { var _this = this; if (this._series === null) { var coll = new IgrStackedSeriesCollection(); var inner = coll._innerColl; inner.addListener(function (sender, e) { switch (e.action) { case NotifyCollectionChangedAction.Add: _this._seriesAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0)); break; case NotifyCollectionChangedAction.Remove: _this._seriesAdapter.removeManualItemAt(e.oldStartingIndex); break; case NotifyCollectionChangedAction.Replace: _this._seriesAdapter.removeManualItemAt(e.oldStartingIndex); _this._seriesAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0)); break; case NotifyCollectionChangedAction.Reset: _this._seriesAdapter.clearManualItems(); break; } }); this._series = coll; } return this._series; }, enumerable: false, configurable: true }); IgrStackedSeriesBase.prototype._provideRenderer = function (renderer) { this._renderer = renderer; if (this.actualSeries != null) { for (var i = 0; i < this.actualSeries.length; i++) { this.actualSeries[i].provideRenderer(renderer); } } }; Object.defineProperty(IgrStackedSeriesBase.prototype, "autoGenerateSeries", { /** * Gets or sets whether series should be automatically generated. Reqiures the use of GroupBy as the ItemsSource. */ get: function () { return this.i.aba; }, set: function (v) { this.i.aba = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrStackedSeriesBase.prototype, "reverseLegendOrder", { /** * Gets or sets whether the order of the fragment series should be reversed in the legend. */ get: function () { return this.i.abc; }, set: function (v) { this.i.abc = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrStackedSeriesBase.prototype, "isStacked", { /** * Checks if this series is a stacked series */ get: function () { return this.i.isStacked; }, enumerable: false, configurable: true }); Object.defineProperty(IgrStackedSeriesBase.prototype, "isPercentBased", { get: function () { return this.i.abb; }, enumerable: false, configurable: true }); IgrStackedSeriesBase.prototype.findByName = function (name) { var baseResult = _super.prototype.findByName.call(this, name); if (baseResult) { return baseResult; } if (this.series != null && this.series.findByName && this.series.findByName(name)) { return this.series.findByName(name); } return null; }; /** * Called to notify about changes to indexed-based properties, e.g. Brushes, Outlines, MarkerBrushes, MarkerOutlines and refresh series */ IgrStackedSeriesBase.prototype.notifyIndexedPropertiesChanged = function () { this.i.qi(); }; /** * Simulates a pointer hover over the series surface. * @param point * The pointer position relative to the series viewport over which to hover. */ IgrStackedSeriesBase.prototype.simulateHover = function (point) { this.i.sa(toPoint(point)); }; /** * Scrolls the series to display the item for the specified data item. * The series is scrolled by the minimum amount required to place the specified data item within * the central 80% of the visible axis. * @param item * The data item (item) to scroll to. */ IgrStackedSeriesBase.prototype.scrollIntoView = function (item) { var iv = this.i.ge(item); return (iv); }; IgrStackedSeriesBase.prototype.replayTransitionIn = function () { this.i.rz(); }; Object.defineProperty(IgrStackedSeriesBase.prototype, "seriesCreated", { /** * Event raised when a new fragment series is automatically generated. */ get: function () { return this._seriesCreated; }, set: function (ev) { var _this = this; if (this._seriesCreated_wrapped !== null) { this.i.seriesCreated = delegateRemove(this.i.seriesCreated, this._seriesCreated_wrapped); this._seriesCreated_wrapped = null; this._seriesCreated = null; } this._seriesCreated = ev; this._seriesCreated_wrapped = function (o, e) { var outerArgs = new IgrStackedSeriesCreatedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeSeriesCreated) { _this.beforeSeriesCreated(_this, outerArgs); } if (_this._seriesCreated) { _this._seriesCreated(_this, outerArgs); } }; this.i.seriesCreated = delegateCombine(this.i.seriesCreated, this._seriesCreated_wrapped); ; }, enumerable: false, configurable: true }); return IgrStackedSeriesBase; }(IgrCategorySeries)); export { IgrStackedSeriesBase };