Skip to content

Completely hide dataset when data is empty or null #8859

Answered by kurkle
BelleNottelling asked this question in Q&A
Discussion options

You must be logged in to vote

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 !== '')
  },
  ...
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BelleNottelling
Comment options

Answer selected by BelleNottelling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #8857 on April 09, 2021 09:12.