var ctx = document.getElementById('myChart').getContext('2d');
let i = 0,
j = 0,
k = 0;
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
}]
},
options: {
animation: false, // this reduces it by half as for all animations it's renders twice
elements: { // this reduces it by number of options, as this is applied after the default options are run.
line: {
borderWidth: 1,
borderColor: function() {
++i;
console.log('why this bordercolor running this many times : ', i)
return 'green'
}
},
},
responsive: function() {
k++;
console.log('why this option running this many times : ', k)
return false
},
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: function() {
j++;
console.log('why this scale running this many times : ', j)
return true
}
}
}
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.