ag-charts-angular
Version:
<picture><source media="(prefers-color-scheme: dark)" srcset="./.github/banner-dark.png"><source media="(prefers-color-scheme: light)" srcset="./.github/banner-light.png"><img alt="AG Charts canvas-based charting trusted by the community, built for enterp
182 lines (174 loc) • 8.6 kB
JavaScript
import * as i0 from '@angular/core';
import { Component, EventEmitter, ViewEncapsulation, Input, Output, NgModule } from '@angular/core';
import { AgCharts as AgCharts$1 } from 'ag-charts-community';
class AgChartsBase {
chart;
_nativeElement;
_initialised = false;
ngZone;
ngAfterViewInit() {
const options = this.patchChartOptions(this.options);
this.chart = this.runOutsideAngular(() => this.createChart(options));
this._initialised = true;
this.chart.chart.waitForUpdate().then(() => {
this.onChartReady.emit(this.chart);
});
}
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
ngOnChanges(_changes) {
this.runOutsideAngular(() => {
if (!this._initialised || !this.chart) {
return;
}
this.chart.update(this.patchChartOptions(this.options));
});
}
ngOnDestroy() {
if (this._initialised && this.chart) {
this.chart.destroy();
this.chart = undefined;
this._initialised = false;
}
}
patchChartOptions(propsOptions) {
const patchListeners = (listenerConfig) => {
const config = listenerConfig ?? {};
for (const listenerName of Object.keys(config)) {
const listener = config[listenerName];
if (typeof listener !== 'function')
continue;
config[listenerName] = (...args) => {
this.runInsideAngular(() => listener(...args));
};
}
};
patchListeners(propsOptions?.legend?.listeners);
patchListeners(propsOptions?.listeners);
propsOptions.series?.forEach((series) => {
patchListeners(series.listeners);
});
if (propsOptions.container) {
return propsOptions;
}
return { ...propsOptions, container: this._nativeElement };
}
runOutsideAngular(callback) {
return this.ngZone ? this.ngZone.runOutsideAngular(callback) : callback();
}
runInsideAngular(callback) {
return this.ngZone ? this.ngZone.run(callback) : callback();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgChartsBase, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AgChartsBase, selector: "ng-component", usesOnChanges: true, ngImport: i0, template: '', isInline: true });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgChartsBase, decorators: [{
type: Component,
args: [{
template: '',
}]
}] });
// noinspection AngularIncorrectTemplateDefinition
class AgCharts extends AgChartsBase {
ngZone;
options = {};
onChartReady = new EventEmitter();
constructor(elementDef, ngZone) {
super();
this.ngZone = ngZone;
this._nativeElement = elementDef.nativeElement;
}
createChart(options) {
return AgCharts$1.create(options);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgCharts, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AgCharts, isStandalone: true, selector: "ag-charts", inputs: { options: "options" }, outputs: { onChartReady: "onChartReady" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgCharts, decorators: [{
type: Component,
args: [{
selector: 'ag-charts',
standalone: true,
template: '',
encapsulation: ViewEncapsulation.None,
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }], propDecorators: { options: [{
type: Input
}], onChartReady: [{
type: Output
}] } });
// noinspection AngularIncorrectTemplateDefinition
class AgFinancialCharts extends AgChartsBase {
ngZone;
options = {};
onChartReady = new EventEmitter();
constructor(elementDef, ngZone) {
super();
this.ngZone = ngZone;
this._nativeElement = elementDef.nativeElement;
}
createChart(options) {
return AgCharts$1.createFinancialChart(options);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgFinancialCharts, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AgFinancialCharts, isStandalone: true, selector: "ag-financial-charts", inputs: { options: "options" }, outputs: { onChartReady: "onChartReady" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgFinancialCharts, decorators: [{
type: Component,
args: [{
selector: 'ag-financial-charts',
standalone: true,
template: '',
encapsulation: ViewEncapsulation.None,
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }], propDecorators: { options: [{
type: Input
}], onChartReady: [{
type: Output
}] } });
// noinspection AngularIncorrectTemplateDefinition
class AgGauge extends AgChartsBase {
ngZone;
options = { type: 'radial-gauge', value: 0 };
onChartReady = new EventEmitter();
constructor(elementDef, ngZone) {
super();
this.ngZone = ngZone;
this._nativeElement = elementDef.nativeElement;
}
createChart(options) {
return AgCharts$1.createGauge(options);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgGauge, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AgGauge, isStandalone: true, selector: "ag-gauge", inputs: { options: "options" }, outputs: { onChartReady: "onChartReady" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgGauge, decorators: [{
type: Component,
args: [{
selector: 'ag-gauge',
standalone: true,
template: '',
encapsulation: ViewEncapsulation.None,
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }], propDecorators: { options: [{
type: Input
}], onChartReady: [{
type: Output
}] } });
class AgChartsModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgChartsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: AgChartsModule, imports: [AgCharts, AgFinancialCharts, AgGauge], exports: [AgCharts, AgFinancialCharts, AgGauge] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgChartsModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AgChartsModule, decorators: [{
type: NgModule,
args: [{
declarations: [],
imports: [AgCharts, AgFinancialCharts, AgGauge],
exports: [AgCharts, AgFinancialCharts, AgGauge],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { AgCharts, AgChartsModule, AgFinancialCharts, AgGauge };
//# sourceMappingURL=ag-charts-angular.mjs.map