import { NgModule, Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ViewEncapsulation, Inject, PLATFORM_ID, booleanAttribute } from '@angular/core'; import { CommonModule, isPlatformBrowser } from '@angular/common'; import Chart from 'chart.js/auto'; import * as i0 from "@angular/core"; /** * Chart groups a collection of contents in tabs. * @group Components */ export class UIChart { platformId; el; zone; /** * Type of the chart. * @group Props */ type; /** * Array of per-chart plugins to customize the chart behaviour. * @group Props */ plugins = []; /** * Width of the chart. * @group Props */ width; /** * Height of the chart. * @group Props */ height; /** * Whether the chart is redrawn on screen size change. * @group Props */ responsive = true; /** * Used to define a string that autocomplete attribute the current element. * @group Props */ ariaLabel; /** * Establishes relationships between the component and label(s) where its value should be one or more element IDs. * @group Props */ ariaLabelledBy; /** * Data to display. * @group Props */ get data() { return this._data; } set data(val) { this._data = val; this.reinit(); } /** * Options to customize the chart. * @group Props */ get options() { return this._options; } set options(val) { this._options = val; this.reinit(); } /** * Callback to execute when an element on chart is clicked. * @group Emits */ onDataSelect = new EventEmitter(); isBrowser = false; initialized; _data; _options = {}; chart; constructor(platformId, el, zone) { this.platformId = platformId; this.el = el; this.zone = zone; } ngAfterViewInit() { this.initChart(); this.initialized = true; } onCanvasClick(event) { if (this.chart) { const element = this.chart.getElementsAtEventForMode(event, 'nearest', { intersect: true }, false); const dataset = this.chart.getElementsAtEventForMode(event, 'dataset', { intersect: true }, false); if (element && element[0] && dataset) { this.onDataSelect.emit({ originalEvent: event, element: element[0], dataset: dataset }); } } } initChart() { if (isPlatformBrowser(this.platformId)) { let opts = this.options || {}; opts.responsive = this.responsive; // allows chart to resize in responsive mode if (opts.responsive && (this.height || this.width)) { opts.maintainAspectRatio = false; } this.zone.runOutsideAngular(() => { this.chart = new Chart(this.el.nativeElement.children[0].children[0], { type: this.type, data: this.data, options: this.options, plugins: this.plugins }); }); } } getCanvas() { return this.el.nativeElement.children[0].children[0]; } getBase64Image() { return this.chart.toBase64Image(); } generateLegend() { if (this.chart) { return this.chart.generateLegend(); } } refresh() { if (this.chart) { this.chart.update(); } } reinit() { if (this.chart) { this.chart.destroy(); this.initChart(); } } ngOnDestroy() { if (this.chart) { this.chart.destroy(); this.initialized = false; this.chart = null; } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: UIChart, deps: [{ token: PLATFORM_ID }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: UIChart, selector: "p-chart", inputs: { type: "type", plugins: "plugins", width: "width", height: "height", responsive: ["responsive", "responsive", booleanAttribute], ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", data: "data", options: "options" }, outputs: { onDataSelect: "onDataSelect" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: UIChart, decorators: [{ type: Component, args: [{ selector: 'p-chart', template: `
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { class: 'p-element' } }] }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID] }] }, { type: i0.ElementRef }, { type: i0.NgZone }], propDecorators: { type: [{ type: Input }], plugins: [{ type: Input }], width: [{ type: Input }], height: [{ type: Input }], responsive: [{ type: Input, args: [{ transform: booleanAttribute }] }], ariaLabel: [{ type: Input }], ariaLabelledBy: [{ type: Input }], data: [{ type: Input }], options: [{ type: Input }], onDataSelect: [{ type: Output }] } }); export class ChartModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ChartModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: ChartModule, declarations: [UIChart], imports: [CommonModule], exports: [UIChart] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ChartModule, imports: [CommonModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ChartModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], exports: [UIChart], declarations: [UIChart] }] }] }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhcnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2NvbXBvbmVudHMvY2hhcnQvY2hhcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQXdDLEtBQUssRUFBRSxNQUFNLEVBQUUsWUFBWSxFQUFFLHVCQUF1QixFQUFFLGlCQUFpQixFQUFFLE1BQU0sRUFBRSxXQUFXLEVBQVUsZ0JBQWdCLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDbE4sT0FBTyxFQUFFLFlBQVksRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ2xFLE9BQU8sS0FBSyxNQUFNLGVBQWUsQ0FBQzs7QUFDbEM7OztHQUdHO0FBY0gsTUFBTSxPQUFPLE9BQU87SUEwRXlCO0lBQXdCO0lBQXdCO0lBekV6Rjs7O09BR0c7SUFDTSxJQUFJLENBQXFCO0lBQ2xDOzs7T0FHRztJQUNNLE9BQU8sR0FBVSxFQUFFLENBQUM7SUFDN0I7OztPQUdHO0lBQ00sS0FBSyxDQUFxQjtJQUNuQzs7O09BR0c7SUFDTSxNQUFNLENBQXFCO0lBQ3BDOzs7T0FHRztJQUNxQyxVQUFVLEdBQVksSUFBSSxDQUFDO0lBQ25FOzs7T0FHRztJQUNNLFNBQVMsQ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uICAgICAgICAgICAgdGhpcy56b25lLnJ1bk91dHNpZGVBbmd1bGFyKCgpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLmNoYXJ0ID0gbmV3IENoYXJ0KHRoaXMuZWwubmF0aXZlRWxlbWVudC5jaGlsZHJlblswXS5jaGlsZHJlblswXSwge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLnR5cGUsXG4gICAgICAgICAgICAgICAgICAgIGRhdGE6IHRoaXMuZGF0YSxcbiAgICAgICAgICAgICAgICAgICAgb3B0aW9uczogdGhpcy5vcHRpb25zLFxuICAgICAgICAgICAgICAgICAgICBwbHVnaW5zOiB0aGlzLnBsdWdpbnNcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0Q2FudmFzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5lbC5uYXRpdmVFbGVtZW50LmNoaWxkcmVuWzBdLmNoaWxkcmVuWzBdO1xuICAgIH1cblxuICAgIGdldEJhc2U2NEltYWdlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jaGFydC50b0Jhc2U2NEltYWdlKCk7XG4gICAgfVxuXG4gICAgZ2VuZXJhdGVMZWdlbmQoKSB7XG4gICAgICAgIGlmICh0aGlzLmNoYXJ0KSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5jaGFydC5nZW5lcmF0ZUxlZ2VuZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmVmcmVzaCgpIHtcbiAgICAgICAgaWYgKHRoaXMuY2hhcnQpIHtcbiAgICAgICAgICAgIHRoaXMuY2hhcnQudXBkYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZWluaXQoKSB7XG4gICAgICAgIGlmICh0aGlzLmNoYXJ0KSB7XG4gICAgICAgICAgICB0aGlzLmNoYXJ0LmRlc3Ryb3koKTtcbiAgICAgICAgICAgIHRoaXMuaW5pdENoYXJ0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