I am building a chart that needs to change values depending on two checkboxes. I have 2 datasets, so I created 4 values for each. This is what I have so far:
HMTL / Checkboxes:
<input id="toggle-1" type="checkbox"/>
<input id="toggle-2" type="checkbox"/>
jQuery condition:
$("input#toggle-1[type='checkbox']").click(function (event) {
var data = chart2.config.data;
if ($(this).is(':checked')) {
data.datasets[0].data = x;
data.datasets[1].data = x;
} else {
data.datasets[0].data = x;
data.datasets[1].data = x;
}
chart2.update();
});
This would be the set up for only one checkbox toggle-1 assuming I would replace the "x"s with each variable accordingly.
So how do I implement the condition for second checkbox?
Aucun commentaire:
Enregistrer un commentaire