1👍
Because QuickChart renders the chart on the server side, it doesn’t have access to your local variable. You can think of everything in setConfig
as though it’s passed as a string rather than a function.
The most straightforward thing to do here is just pass the config as a string, and interpolate the language
value:
myChart.setConfig(`{
type: 'bar',
data: { // etc... },
options: {
scales: {
yAxes: [{
id: 'Left',
ticks: {
fontSize: 10,
callback: (value) => value.toLocaleString('${language}')
},
}]
}
}
}`)
There are some alternative approaches in the QuickChart docs.
- Chartjs-How to format the left legend on chartjs
- Chartjs-How to add data to chart.js with a for loop
Source:stackexchange.com