[59329aa] | 1 | import { NgModule, Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
|
---|
| 2 | import { CommonModule } from '@angular/common';
|
---|
| 3 | import Chart from 'chart.js/auto';
|
---|
| 4 | import * as i0 from "@angular/core";
|
---|
| 5 | export class UIChart {
|
---|
| 6 | constructor(el) {
|
---|
| 7 | this.el = el;
|
---|
| 8 | this.plugins = [];
|
---|
| 9 | this.responsive = true;
|
---|
| 10 | this.onDataSelect = new EventEmitter();
|
---|
| 11 | this._options = {};
|
---|
| 12 | }
|
---|
| 13 | get data() {
|
---|
| 14 | return this._data;
|
---|
| 15 | }
|
---|
| 16 | set data(val) {
|
---|
| 17 | this._data = val;
|
---|
| 18 | this.reinit();
|
---|
| 19 | }
|
---|
| 20 | get options() {
|
---|
| 21 | return this._options;
|
---|
| 22 | }
|
---|
| 23 | set options(val) {
|
---|
| 24 | this._options = val;
|
---|
| 25 | this.reinit();
|
---|
| 26 | }
|
---|
| 27 | ngAfterViewInit() {
|
---|
| 28 | this.initChart();
|
---|
| 29 | this.initialized = true;
|
---|
| 30 | }
|
---|
| 31 | onCanvasClick(event) {
|
---|
| 32 | if (this.chart) {
|
---|
| 33 | const element = this.chart.getElementsAtEventForMode(event, 'nearest', { intersect: true }, false);
|
---|
| 34 | const dataset = this.chart.getElementsAtEventForMode(event, 'dataset', { intersect: true }, false);
|
---|
| 35 | if (element && element[0] && dataset) {
|
---|
| 36 | this.onDataSelect.emit({ originalEvent: event, element: element[0], dataset: dataset });
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | initChart() {
|
---|
| 41 | let opts = this.options || {};
|
---|
| 42 | opts.responsive = this.responsive;
|
---|
| 43 | // allows chart to resize in responsive mode
|
---|
| 44 | if (opts.responsive && (this.height || this.width)) {
|
---|
| 45 | opts.maintainAspectRatio = false;
|
---|
| 46 | }
|
---|
| 47 | this.chart = new Chart(this.el.nativeElement.children[0].children[0], {
|
---|
| 48 | type: this.type,
|
---|
| 49 | data: this.data,
|
---|
| 50 | options: this.options,
|
---|
| 51 | plugins: this.plugins
|
---|
| 52 | });
|
---|
| 53 | }
|
---|
| 54 | getCanvas() {
|
---|
| 55 | return this.el.nativeElement.children[0].children[0];
|
---|
| 56 | }
|
---|
| 57 | getBase64Image() {
|
---|
| 58 | return this.chart.toBase64Image();
|
---|
| 59 | }
|
---|
| 60 | generateLegend() {
|
---|
| 61 | if (this.chart) {
|
---|
| 62 | return this.chart.generateLegend();
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | refresh() {
|
---|
| 66 | if (this.chart) {
|
---|
| 67 | this.chart.update();
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | reinit() {
|
---|
| 71 | if (this.chart) {
|
---|
| 72 | this.chart.destroy();
|
---|
| 73 | this.initChart();
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | ngOnDestroy() {
|
---|
| 77 | if (this.chart) {
|
---|
| 78 | this.chart.destroy();
|
---|
| 79 | this.initialized = false;
|
---|
| 80 | this.chart = null;
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | UIChart.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: UIChart, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 85 | UIChart.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: UIChart, selector: "p-chart", inputs: { type: "type", plugins: "plugins", width: "width", height: "height", responsive: "responsive", data: "data", options: "options" }, outputs: { onDataSelect: "onDataSelect" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
|
---|
| 86 | <div style="position:relative" [style.width]="responsive && !width ? null : width" [style.height]="responsive && !height ? null : height">
|
---|
| 87 | <canvas [attr.width]="responsive && !width ? null : width" [attr.height]="responsive && !height ? null : height" (click)="onCanvasClick($event)"></canvas>
|
---|
| 88 | </div>
|
---|
| 89 | `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 90 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: UIChart, decorators: [{
|
---|
| 91 | type: Component,
|
---|
| 92 | args: [{
|
---|
| 93 | selector: 'p-chart',
|
---|
| 94 | template: `
|
---|
| 95 | <div style="position:relative" [style.width]="responsive && !width ? null : width" [style.height]="responsive && !height ? null : height">
|
---|
| 96 | <canvas [attr.width]="responsive && !width ? null : width" [attr.height]="responsive && !height ? null : height" (click)="onCanvasClick($event)"></canvas>
|
---|
| 97 | </div>
|
---|
| 98 | `,
|
---|
| 99 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 100 | encapsulation: ViewEncapsulation.None,
|
---|
| 101 | host: {
|
---|
| 102 | 'class': 'p-element'
|
---|
| 103 | }
|
---|
| 104 | }]
|
---|
| 105 | }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { type: [{
|
---|
| 106 | type: Input
|
---|
| 107 | }], plugins: [{
|
---|
| 108 | type: Input
|
---|
| 109 | }], width: [{
|
---|
| 110 | type: Input
|
---|
| 111 | }], height: [{
|
---|
| 112 | type: Input
|
---|
| 113 | }], responsive: [{
|
---|
| 114 | type: Input
|
---|
| 115 | }], onDataSelect: [{
|
---|
| 116 | type: Output
|
---|
| 117 | }], data: [{
|
---|
| 118 | type: Input
|
---|
| 119 | }], options: [{
|
---|
| 120 | type: Input
|
---|
| 121 | }] } });
|
---|
| 122 | export class ChartModule {
|
---|
| 123 | }
|
---|
| 124 | ChartModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ChartModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
| 125 | ChartModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ChartModule, declarations: [UIChart], imports: [CommonModule], exports: [UIChart] });
|
---|
| 126 | ChartModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ChartModule, imports: [[CommonModule]] });
|
---|
| 127 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ChartModule, decorators: [{
|
---|
| 128 | type: NgModule,
|
---|
| 129 | args: [{
|
---|
| 130 | imports: [CommonModule],
|
---|
| 131 | exports: [UIChart],
|
---|
| 132 | declarations: [UIChart]
|
---|
| 133 | }]
|
---|
| 134 | }] });
|
---|
| 135 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhcnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2NvbXBvbmVudHMvY2hhcnQvY2hhcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLFFBQVEsRUFBQyxTQUFTLEVBQW9DLEtBQUssRUFBQyxNQUFNLEVBQUMsWUFBWSxFQUFDLHVCQUF1QixFQUFFLGlCQUFpQixFQUFDLE1BQU0sZUFBZSxDQUFDO0FBQ3pKLE9BQU8sRUFBQyxZQUFZLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUM3QyxPQUFPLEtBQUssTUFBTSxlQUFlLENBQUM7O0FBZWxDLE1BQU0sT0FBTyxPQUFPO0lBc0JoQixZQUFtQixFQUFjO1FBQWQsT0FBRSxHQUFGLEVBQUUsQ0FBWTtRQWxCeEIsWUFBTyxHQUFVLEVBQUUsQ0FBQztRQU1wQixlQUFVLEdBQVksSUFBSSxDQUFDO1FBRTFCLGlCQUFZLEdBQXNCLElBQUksWUFBWSxFQUFFLENBQUM7UUFNL0QsYUFBUSxHQUFRLEVBQUUsQ0FBQztJQUlpQixDQUFDO0lBRXJDLElBQWEsSUFBSTtRQUNiLE9BQU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