Menu

[Solved]Javascript Trying Figure Add Button Called Reset Set Chart Values Zero Button Clicked Ever Q37148224

Javascript — I am trying to figure out how to add a buttoncalled reset that will set all the chart values to zero when thebutton is clicked, everything I have tried thus far has notworked.

In my HTML I have :

<div class=”container”>
<canvas id=”myChart” width=”300″height=”150″></canvas>

and in my .js file:

window.onload = function() {
  
var ctx =document.getElementById(“myChart”).getContext(‘2d’);
var myChart = new Chart(ctx, {
type: ‘bar’,
data: {
labels: [“January”, “February”, “March”, “April”, “May”,”June”,”July”, “August”, “September”, “October”, “November”,”December”],
datasets: [{
label: ‘ # of Subscribers’,
data: [40, 10, 100, 65, 75, 120, 121, 175, 220, 275, 300,15],
backgroundColor: [
‘rgba(255, 99, 132)’,
‘rgba(54, 162, 235)’,
‘rgba(255, 206, 86)’,
‘rgba(75, 192, 192)’,
‘rgba(153, 102, 255)’,
‘rgba(255, 159, 64)’,
‘rgba(55, 99, 132)’,
‘rgba(154, 162, 235)’,
‘rgba(255, 206, 186)’,
‘rgba(75, 192, 92)’,
‘rgba(253, 102, 255)’,
‘rgba(255, 159, 175)’
]
  
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
},
});
  
}
  

Any suggestions or ideas are appreciated. Thanks!

Expert Answer


Answer to Javascript — I am trying to figure out how to add a button called reset that will set all the chart values to zero when… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *