46 lines
5.9 KiB
JavaScript
46 lines
5.9 KiB
JavaScript
|
import { Injectable, NgModule, Optional, } from '@angular/core';
|
||
|
import { BaseChartDirective } from './base-chart.directive';
|
||
|
import { Chart, registerables, defaults, } from 'chart.js';
|
||
|
import { merge } from 'lodash-es';
|
||
|
import { builtInDefaults } from './get-colors';
|
||
|
import * as i0 from "@angular/core";
|
||
|
export class NgChartsConfiguration {
|
||
|
constructor() {
|
||
|
this.generateColors = true;
|
||
|
}
|
||
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: NgChartsConfiguration, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
||
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: NgChartsConfiguration, providedIn: 'root' }); }
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: NgChartsConfiguration, decorators: [{
|
||
|
type: Injectable,
|
||
|
args: [{ providedIn: 'root' }]
|
||
|
}] });
|
||
|
Chart.register(...registerables);
|
||
|
export class NgChartsModule {
|
||
|
constructor(config) {
|
||
|
if (config?.plugins)
|
||
|
Chart.register(...config.plugins);
|
||
|
const ngChartsDefaults = merge(config?.generateColors ? builtInDefaults : {}, config?.defaults || {});
|
||
|
defaults.set(ngChartsDefaults);
|
||
|
}
|
||
|
static forRoot(config) {
|
||
|
return {
|
||
|
ngModule: NgChartsModule,
|
||
|
providers: [{ provide: NgChartsConfiguration, useValue: config }],
|
||
|
};
|
||
|
}
|
||
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: NgChartsModule, deps: [{ token: NgChartsConfiguration, optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
||
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.3", ngImport: i0, type: NgChartsModule, declarations: [BaseChartDirective], exports: [BaseChartDirective] }); }
|
||
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: NgChartsModule }); }
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: NgChartsModule, decorators: [{
|
||
|
type: NgModule,
|
||
|
args: [{
|
||
|
imports: [],
|
||
|
declarations: [BaseChartDirective],
|
||
|
exports: [BaseChartDirective],
|
||
|
}]
|
||
|
}], ctorParameters: function () { return [{ type: NgChartsConfiguration, decorators: [{
|
||
|
type: Optional
|
||
|
}] }]; } });
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctY2hhcnRzLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvbmcyLWNoYXJ0cy9zcmMvbGliL25nLWNoYXJ0cy5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLFVBQVUsRUFFVixRQUFRLEVBQ1IsUUFBUSxHQUNULE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzVELE9BQU8sRUFDTCxLQUFLLEVBQ0wsYUFBYSxFQUdiLFFBQVEsR0FDVCxNQUFNLFVBQVUsQ0FBQztBQUNsQixPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBQ2xDLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxjQUFjLENBQUM7O0FBRy9DLE1BQU0sT0FBTyxxQkFBcUI7SUFEbEM7UUFJUyxtQkFBYyxHQUFHLElBQUksQ0FBQztLQUM5Qjs4R0FKWSxxQkFBcUI7a0hBQXJCLHFCQUFxQ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