for(var x in charts){
charts[x].options.scales.yAxes[0].ticks.fOntSize= 20;
charts[x].options.scales.xAxes[0].ticks.fOntSize= 20;
charts[x].update();
}
for (var x in charts) {
// set/change the actual font-size
charts[x].options.scales.xAxes[0].ticks.minor.fOntSize= 20;
charts[x].options.scales.yAxes[0].ticks.minor.fOntSize= 20;
// set proper spacing for resized font
charts[x].options.scales.xAxes[0].ticks.fOntSize= 20;
charts[x].options.scales.yAxes[0].ticks.fOntSize= 20;
// update chart to apply new font-size
charts[x].update();
}
ᴡᴏʀᴋɪɴɢᴡᴏʀᴋɪɴɢxᴀᴍᴘʟᴇ⧩
var myChart1 = new Chart(ctx1, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
datasets: [{
label: 'Profit',
data: [30, 10, 40, 20, 50],
backgroundColor: 'rgba(61, 208, 239, 0.2)',
borderColor: 'rgba(61, 208, 239, 0.6)'
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
var myChart2 = new Chart(ctx2, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
datasets: [{
label: 'Loss',
data: [50, 20, 40, 10, 30],
backgroundColor: 'rgba(239, 92, 61, 0.2)',
borderColor: 'rgba(239, 92, 61, 0.6)'
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
var charts = [myChart1, myChart2];
function changeFontSize() {
for (var x in charts) {
// set/change the font-size
charts[x].options.scales.xAxes[0].ticks.minor.fOntSize= 20;
charts[x].options.scales.yAxes[0].ticks.minor.fOntSize= 20;
// set proper spacing for resized font
charts[x].options.scales.xAxes[0].ticks.fOntSize= 20;
charts[x].options.scales.yAxes[0].ticks.fOntSize= 20;
// update chart to apply new font-size
charts[x].update();
}
}