Completely hide dataset when data is empty or null #8859
-
Feature ProposalI think it would make a lot of sense for a dataset to not even show an empty box in the legend when the data is empty or null. Now, I'm really not how many people experience this as an issue, it is very possible that this is just another example of me not being particularly great at programming and doing something dumb as a result Feature Use CaseSo, I'm building a little web app to help me analyze ECU logs for tuning purposes. My code has to read and "map" each sensor name for each log as there's no guarantee that the data will be in the same format between logs. I basically just have a bunch of empty datasets that get populated, but when not all of them are needed I'm left with a bunch of empty boxes for data that doesn't exist. The more data I want to be able to support, the worse it gets. So I'm not really sure if it would be possible to dynamically create each dataset as I need rather than having a ton of empty dataset that I just fill in, or if it would be possible to simply automatically hide the empty datasets. Now, this is a "feature request" in the manner of where I think hiding an empty dataset makes sense, but it's also me wondering if there's a better way for me to go about this. I appreciate any input, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you pre-create the datasets for having some predefined styles, then you should just define the styles beforehand as an array and map that to the datasets you create when reading the log. And only create as many datasets as there are. Or, if you prefer less work, you could just do something like const datasets = createMyDatasets(); // your existing creation code, did not take a look
const chart = new Chart('id', {
data: {
datasets: datasets.filter(ds => ds.label !== '')
},
...
}); |
Beta Was this translation helpful? Give feedback.
If you pre-create the datasets for having some predefined styles, then you should just define the styles beforehand as an array and map that to the datasets you create when reading the log. And only create as many datasets as there are.
Or, if you prefer less work, you could just do something like