-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #10452 - Update Chart.js to 3.3.2
- Loading branch information
1 parent
96fc1ce
commit c07677f
Showing
16 changed files
with
1,432 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,25 +17,25 @@ export class UIChart implements AfterViewInit, OnDestroy { | |
@Input() type: string; | ||
|
||
@Input() plugins: any[] = []; | ||
|
||
@Input() width: string; | ||
|
||
@Input() height: string; | ||
|
||
@Input() responsive: boolean = true; | ||
|
||
@Output() onDataSelect: EventEmitter<any> = new EventEmitter(); | ||
|
||
initialized: boolean; | ||
|
||
_data: any; | ||
|
||
_options: any = {}; | ||
|
||
chart: any; | ||
|
||
constructor(public el: ElementRef) {} | ||
|
||
@Input() get data(): any { | ||
return this._data; | ||
} | ||
|
@@ -61,8 +61,9 @@ export class UIChart implements AfterViewInit, OnDestroy { | |
|
||
onCanvasClick(event) { | ||
if (this.chart) { | ||
let element = this.chart.getElementAtEvent(event); | ||
let dataset = this.chart.getDatasetAtEvent(event); | ||
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}); | ||
} | ||
|
@@ -78,41 +79,44 @@ export class UIChart implements AfterViewInit, OnDestroy { | |
opts.maintainAspectRatio = false; | ||
} | ||
|
||
this.chart = new Chart(this.el.nativeElement.children[0].children[0], { | ||
type: this.type, | ||
data: this.data, | ||
options: this.options, | ||
plugins: this.plugins | ||
import('chart.js/auto').then((module) => { | ||
if (module && module.default) { | ||
this.chart = new module.default(this.el.nativeElement.children[0].children[0], { | ||
type: this.type, | ||
data: this.data, | ||
options: this.options | ||
}); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yigitfindikli
Author
Contributor
|
||
} | ||
}); | ||
} | ||
|
||
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(); | ||
|
Oops, something went wrong.
Did you forget to implement the plugin databinding here? Old constructor takes the
plugins
Input, and constructor in chart.js 3.3.2 hasn't changed. https://www.chartjs.org/docs/3.3.2/developers/plugins.html#using-pluginsEffectively this means that
<p-chart [plugins]='somePlugins'></p-chart>
is broken.Please fix 🥺👉👈