5👍
✅
Since it works for you, I’m setting it as an answer
The _meta
property in your datasets is very useful, especially when searching for specific properties such as hidden
.
However it is quite difficult to handle it when there are several charts on the same page.
When doing the following :
var isHiddenMeta = scatterChart.data.datasets[j]._meta[0].hidden;
The 0
index is actually the first chart called in your code (index 1
is the second, etc..)
So you’ll get the information of the first chart, and not the one you just clicked on.
To fix this, you need to use the Object.keys()
method coupled with your dataset information, as follows :
var isHiddenMeta = scatterChart.data.datasets[j]._meta[Object.keys(scatterChart.data.datasets[j]._meta)[0]].hidden;
This will get you the hidden
property of the dataset of the real chart.
Source:stackexchange.com