{"version":3,"file":"primeng-chart.umd.js","sources":["../../src/app/components/chart/chart.ts","../../src/app/components/chart/primeng-chart.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,EventEmitter,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport * as Chart from 'chart.js';\n\n@Component({\n selector: 'p-chart',\n template: `\n
\n \n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\n})\nexport class UIChart implements AfterViewInit, OnDestroy {\n\n @Input() type: string;\n\n @Input() plugins: any[] = [];\n \n @Input() width: string;\n \n @Input() height: string;\n\n @Input() responsive: boolean = true;\n \n @Output() onDataSelect: EventEmitter = new EventEmitter();\n\n initialized: boolean;\n \n _data: any;\n\n _options: any = {};\n\n chart: any;\n\n constructor(public el: ElementRef) {}\n \n @Input() get data(): any {\n return this._data;\n }\n\n set data(val:any) {\n this._data = val;\n this.reinit();\n }\n\n @Input() get options(): any {\n return this._options;\n }\n\n set options(val:any) {\n this._options = val;\n this.reinit();\n }\n\n ngAfterViewInit() {\n this.initChart();\n this.initialized = true;\n }\n\n onCanvasClick(event) {\n if (this.chart) {\n let element = this.chart.getElementAtEvent(event);\n let dataset = this.chart.getDatasetAtEvent(event);\n if (element && element[0] && dataset) {\n this.onDataSelect.emit({originalEvent: event, element: element[0], dataset: dataset});\n }\n }\n }\n\n initChart() {\n let opts = this.options||{};\n opts.responsive = this.responsive;\n\n // allows chart to resize in responsive mode\n if (opts.responsive&&(this.height||this.width)) {\n opts.maintainAspectRatio = false;\n }\n\n this.chart = new Chart(this.el.nativeElement.children[0].children[0], {\n type: this.type,\n data: this.data,\n options: this.options,\n plugins: this.plugins\n });\n }\n \n getCanvas() {\n return this.el.nativeElement.children[0].children[0];\n }\n \n getBase64Image() {\n return this.chart.toBase64Image();\n }\n \n generateLegend() {\n if (this.chart) {\n return this.chart.generateLegend();\n }\n }\n \n refresh() {\n if (this.chart) {\n this.chart.update();\n }\n }\n \n reinit() {\n if (this.chart) {\n this.chart.destroy();\n this.initChart();\n }\n }\n \n ngOnDestroy() {\n if (this.chart) {\n this.chart.destroy();\n this.initialized = false;\n this.chart = null;\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [UIChart],\n declarations: [UIChart]\n})\nexport class ChartModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","Chart","Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","Input","Output","NgModule","CommonModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoCI,iBAAmB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAlBxB,YAAO,GAAU,EAAE,CAAC;YAMpB,eAAU,GAAY,IAAI,CAAC;YAE1B,iBAAY,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAM/D,aAAQ,GAAQ,EAAE,CAAC;SAIkB;QAErC,sBAAa,yBAAI;iBAAjB;gBACI,OAAO,IAAI,CAAC,KAAK,CAAC;aACrB;iBAED,UAAS,GAAO;gBACZ,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;gBACjB,IAAI,CAAC,MAAM,EAAE,CAAC;aACjB;;;WALA;QAOD,sBAAa,4BAAO;iBAApB;gBACI,OAAO,IAAI,CAAC,QAAQ,CAAC;aACxB;iBAED,UAAY,GAAO;gBACf,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;gBACpB,IAAI,CAAC,MAAM,EAAE,CAAC;aACjB;;;WALA;QAOD,iCAAe,GAAf;YACI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAC3B;QAED,+BAAa,GAAb,UAAc,KAAK;YACf,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,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