igniteui-webcomponents-charts
Version:
Ignite UI Web Components charting components for building rich data visualizations using TypeScript APIs.
212 lines (208 loc) • 8.67 kB
JavaScript
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';
let IgcStackedSeriesBaseComponent = /*@__PURE__*/ (() => {
class IgcStackedSeriesBaseComponent extends IgcCategorySeriesComponent {
createImplementation() {
return null;
}
//protected _implementation: any;
get i() {
return this._implementation;
}
constructor() {
super();
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, (c) => c.i, (i) => {
i.owner = this;
}, (i) => {
});
let mut = new MutationObserver((list) => {
for (var mutation of list) {
if (mutation.type == 'childList') {
this.updateContentChildren();
}
}
});
mut.observe(this, {
childList: true
});
}
updateContentChildren() {
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();
}
}
/**
* A collection or manually added series for the chart.
*/
get series() {
if (this._series === null) {
let coll = new IgcStackedSeriesCollection();
let inner = coll._innerColl;
inner.addListener((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;
}
static _createFromInternal(internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
let name = internal.$type.name;
let externalName = "Igc" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
}
connectedCallback() {
this.updateContentChildren();
}
static get observedAttributes() {
if (IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent == null) {
let names = getAllPropertyNames(IgcStackedSeriesBaseComponent);
for (let i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent = names;
}
return IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent;
}
/**
* Gets or sets whether series should be automatically generated. Reqiures the use of GroupBy as the ItemsSource.
*/
get autoGenerateSeries() {
return this.i.abq;
}
set autoGenerateSeries(v) {
this.i.abq = ensureBool(v);
this._a("autoGenerateSeries", this.i.abq);
}
/**
* Gets or sets whether the order of the fragment series should be reversed in the legend.
*/
get reverseLegendOrder() {
return this.i.abs;
}
set reverseLegendOrder(v) {
this.i.abs = ensureBool(v);
this._a("reverseLegendOrder", this.i.abs);
}
/**
* Checks if this series is a stacked series
*/
get isStacked() {
return this.i.isStacked;
}
get isPercentBased() {
return this.i.abr;
}
findByName(name) {
var baseResult = super.findByName(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
*/
notifyIndexedPropertiesChanged() {
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.
*/
simulateHover(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.
*/
scrollIntoView(item) {
let iv = this.i.gj(item);
return (iv);
}
replayTransitionIn() {
this.i.sd();
}
/**
* Event raised when a new fragment series is automatically generated.
*/
get seriesCreated() {
return this._seriesCreated;
}
set seriesCreated(ev) {
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 = (o, e) => {
let 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);
;
}
}
IgcStackedSeriesBaseComponent._observedAttributesIgcStackedSeriesBaseComponent = null;
return IgcStackedSeriesBaseComponent;
})();
export { IgcStackedSeriesBaseComponent };