UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![Build Status](https://travis-ci.org/primefaces/primeng.

2 lines 3.21 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("chart.js")):"function"==typeof define&&define.amd?define("primeng/chart",["exports","@angular/core","@angular/common","chart.js"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.chart={}),t.ng.core,t.ng.common,t.Chart)}(this,(function(t,e,i,n){"use strict";var o=this&&this.__decorate||function(t,e,i,n){var o,r=arguments.length,a=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a},r=function(){function t(t){this.el=t,this.options={},this.plugins=[],this.responsive=!0,this.onDataSelect=new e.EventEmitter}return Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(t){this._data=t,this.reinit()},enumerable:!0,configurable:!0}),t.prototype.ngAfterViewInit=function(){this.initChart(),this.initialized=!0},t.prototype.onCanvasClick=function(t){if(this.chart){var e=this.chart.getElementAtEvent(t),i=this.chart.getDatasetAtEvent(t);e&&e[0]&&i&&this.onDataSelect.emit({originalEvent:t,element:e[0],dataset:i})}},t.prototype.initChart=function(){var t=this.options||{};t.responsive=this.responsive,t.responsive&&(this.height||this.width)&&(t.maintainAspectRatio=!1),this.chart=new n(this.el.nativeElement.children[0].children[0],{type:this.type,data:this.data,options:this.options,plugins:this.plugins})},t.prototype.getCanvas=function(){return this.el.nativeElement.children[0].children[0]},t.prototype.getBase64Image=function(){return this.chart.toBase64Image()},t.prototype.generateLegend=function(){if(this.chart)return this.chart.generateLegend()},t.prototype.refresh=function(){this.chart&&this.chart.update()},t.prototype.reinit=function(){this.chart&&(this.chart.destroy(),this.initChart())},t.prototype.ngOnDestroy=function(){this.chart&&(this.chart.destroy(),this.initialized=!1,this.chart=null)},t.ctorParameters=function(){return[{type:e.ElementRef}]},o([e.Input()],t.prototype,"type",void 0),o([e.Input()],t.prototype,"options",void 0),o([e.Input()],t.prototype,"plugins",void 0),o([e.Input()],t.prototype,"width",void 0),o([e.Input()],t.prototype,"height",void 0),o([e.Input()],t.prototype,"responsive",void 0),o([e.Output()],t.prototype,"onDataSelect",void 0),o([e.Input()],t.prototype,"data",null),t=o([e.Component({selector:"p-chart",template:'\n <div style="position:relative" [style.width]="responsive && !width ? null : width" [style.height]="responsive && !height ? null : height">\n <canvas [attr.width]="responsive && !width ? null : width" [attr.height]="responsive && !height ? null : height" (click)="onCanvasClick($event)"></canvas>\n </div>\n ',changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),a=function(){function t(){}return t=o([e.NgModule({imports:[i.CommonModule],exports:[r],declarations:[r]})],t)}();t.ChartModule=a,t.UIChart=r,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-chart.umd.min.js.map