ng2-charts icon indicating copy to clipboard operation
ng2-charts copied to clipboard

Global chart dataoptions cannot be set

Open grahammutter opened this issue 7 years ago • 4 comments

The global/default chart dataoption configuration feature of chart.js cannot be set currently.

http://www.chartjs.org/docs/#chart-configuration-global-configuration

I will begin work on this ~April 26th.

grahammutter avatar Apr 20 '17 21:04 grahammutter

Is there any workaround for this right now? I would like to set some global font settings.

chinaowl avatar May 16 '17 21:05 chinaowl

yes, i'd love to see a workaround for this

the-catalin avatar Jul 25 '17 13:07 the-catalin

for (let i = 0; i < this.chart.data.datasets.length; i++) {
     this.chart.data.datasets[i].borderWidth = 2;
}

evandrogrm avatar Oct 16 '18 13:10 evandrogrm

Came across this issue and it made me look at .ts source code. Here is how you can set default for the charts.

// Import
import Chart from "chart.js";

// ngOnInit() method
ngOnInit() {
	// Set default font size to 10 pixel
	Chart.defaults.global.defaultFontSize = 10;
}

I use ng2-charts version ^2.3.0.

Hope this helps :)

s-patompong avatar Aug 03 '19 07:08 s-patompong

Fixed in v3+

santam85 avatar Mar 01 '24 16:03 santam85