dimanche 7 août 2022

How Can I Create Data in Bar Chart in Response to Checkboxes?

This is my first time creating a bar chart which I just watched from a tutorial on youtube. (It was pretty much me typing-along.) I'd like to know how I can make it responsive when a user clicks on a checkbox, which will then increase the values of [x], [y], and/or [z] by 25.(There are box 4 checkboxes for each.) I read that I need to create an event listener, but I'm not sure how to access the data. I really appreciate the help!

let myChart = document.getElementById('myChart').getContext('2d');

let barChart = new Chart(myChart, {
    type: 'bar',
    data: {
        labels:['x', 'y', 'z'],
        datasets:[{
        label: "numbers",
        data:[
            [x],
            [y],
            [z]
        ]
    }]
    },
    options: {},
});



Aucun commentaire:

Enregistrer un commentaire