GOAL: Clicking on chart
legend
I want to show/hide corresponding line.
I am using Chart.legend.js to create legend
. I know How to add a dataset toggle to Chart.js? asked the same question but I cannot use jQuery.
Any idea?
Thank you
You can just replace the jQuery functions in the question you linked to by their Javascript equivalents.
1.
becomes
var ctx = document.getElementById("LineChart").getContext("2d");
2.
becomes
3.
becomes a javascript block before the end of the tag (there are other ways to do it, but this seemed the easiest to demonstrate)
4.
becomes
and
5.
becomes
Fiddle with no jQuery - http://jsfiddle.net/htc4gyu5/
Notice that I've moved everything to the HTML block - that's mainly for #3 in the above list.