Ng2-charts: Global chart dataoptions cannot be set

Created on 20 Apr 2017  路  4Comments  路  Source: valor-software/ng2-charts

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.

enhancement

Most helpful comment

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 :)

All 4 comments

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

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

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

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 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SteeledSlagle13 picture SteeledSlagle13  路  3Comments

alexcastillo picture alexcastillo  路  5Comments

martinpinto picture martinpinto  路  3Comments

vmironovs picture vmironovs  路  3Comments

tushartgsit picture tushartgsit  路  5Comments