igniteui-webcomponents-charts
Version:
Ignite UI Web Components charting components for building rich data visualizations using TypeScript APIs.
266 lines (262 loc) • 10.8 kB
JavaScript
import { __extends, __values } from "tslib";
import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core";
import { toSpinal, getAllPropertyNames, toPoint, ensureBool } from "igniteui-webcomponents-core";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { IgcStackedSeriesCreatedEventArgs } from './igc-stacked-series-created-event-args';
import { IgcCategorySeriesComponent } from './igc-category-series-component';
import { NotifyCollectionChangedAction } from "igniteui-webcomponents-core";
import { IgcStackedFragmentSeriesComponent } from './igc-stacked-fragment-series-component';
import { CollectionAdapter } from "igniteui-webcomponents-core";
import { IgcStackedSeriesCollection } from './igc-stacked-series-collection';
/**
* Represents a IgcStackedSeriesBaseComponent base series.
*/
export var IgcStackedSeriesBaseComponent = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgcStackedSeriesBaseComponent, _super);
function IgcStackedSeriesBaseComponent() {
var _this = _super.call(this) || this;
_this._seriesAdapter = null;
/**
* The series actually present in the chart. Do not directly modify this array.
* This array's contents can be modified by causing Angular 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._seriesCreated = null;
_this._seriesCreated_wrapped = null;
_this._seriesAdapter = new CollectionAdapter(_this.contentSeries, _this.i.series, _this.actualSeries, function (c) { return c.i; }, function (i) {
i.owner = _this;
}, function (i) {
});
var mut = new MutationObserver(function (list) {
var e_1, _b;
try {
for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
var mutation = list_1_1.value;
if (mutation.type == 'childList') {
_this.updateContentChildren();
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (list_1_1 && !list_1_1.done && (_b = list_1.return))
_b.call(list_1);
}
finally {
if (e_1)
throw e_1.error;
}
}
});
mut.observe(_this, {
childList: true
});
return _this;
}
IgcStackedSeriesBaseComponent.prototype.createImplementation = function () {
return null;
};
Object.defineProperty(IgcStackedSeriesBaseComponent.prototype, "i", {
//protected _implementation: any;
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
IgcStackedSeriesBaseComponent.prototype.updateContentChildren = function () {
this.contentSeries.length = 0;
for (var i = 0; i < this.children.length; i++) {
if (this.children[i] instanceof IgcStackedFragmentSeriesComponent) {
this.contentSeries.push(this.children[i]);
}
}
if (this._seriesAdapter != null) {
this._seriesAdapter.notifyContentChanged();
}
};
Object.defineProperty(IgcStackedSeriesBaseComponent.prototype, "series", {
/**
* A collection or manually added series for the chart.
*/
get: function () {
var _this = this;
if (this._series === null) {
var coll = new IgcStackedSeriesCollection();
var inner = coll._innerColl;
inner.addListener(function (sender, e) {
switch (e.action) {
case NotifyCollectionChangedAction.Add:
_this._seriesAdapter.addManualItem(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
});
IgcStackedSeriesBaseComponent._createFromInternal = function (internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
var name = internal.$type.name;
var externalName = "Igc" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
};
IgcStackedSeriesBaseComponent.prototype.connectedCallback = function () {
this.updateContentChildren();
};
Object.defineProperty(IgcStackedSeriesBaseComponent, "observedAttributes", {
get: function () {
if (IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent == null) {
var names = getAllPropertyNames(IgcStackedSeriesBaseComponent);
for (var i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent = names;
}
return IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcStackedSeriesBaseComponent.prototype, "autoGenerateSeries", {
/**
* Gets or sets whether series should be automatically generated. Reqiures the use of GroupBy as the ItemsSource.
*/
get: function () {
return this.i.abq;
},
set: function (v) {
this.i.abq = ensureBool(v);
this._a("autoGenerateSeries", this.i.abq);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcStackedSeriesBaseComponent.prototype, "reverseLegendOrder", {
/**
* Gets or sets whether the order of the fragment series should be reversed in the legend.
*/
get: function () {
return this.i.abs;
},
set: function (v) {
this.i.abs = ensureBool(v);
this._a("reverseLegendOrder", this.i.abs);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcStackedSeriesBaseComponent.prototype, "isStacked", {
/**
* Checks if this series is a stacked series
*/
get: function () {
return this.i.isStacked;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcStackedSeriesBaseComponent.prototype, "isPercentBased", {
get: function () {
return this.i.abr;
},
enumerable: false,
configurable: true
});
IgcStackedSeriesBaseComponent.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
*/
IgcStackedSeriesBaseComponent.prototype.notifyIndexedPropertiesChanged = function () {
this.i.qv();
};
/**
* Simulates a pointer hover over the series surface.
* @param point * The pointer position relative to the series viewport over which to hover.
*/
IgcStackedSeriesBaseComponent.prototype.simulateHover = function (point) {
this.i.so(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.
*/
IgcStackedSeriesBaseComponent.prototype.scrollIntoView = function (item) {
var iv = this.i.gj(item);
return (iv);
};
IgcStackedSeriesBaseComponent.prototype.replayTransitionIn = function () {
this.i.sd();
};
Object.defineProperty(IgcStackedSeriesBaseComponent.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 IgcStackedSeriesCreatedEventArgs();
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
});
IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent = null;
return IgcStackedSeriesBaseComponent;
}(IgcCategorySeriesComponent));