source: trip-planner-front/node_modules/primeng/fesm2020/primeng-chart.mjs@ 76712b2

Last change on this file since 76712b2 was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

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