question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Showing/Hiding Based on Visibility of Lines in Chart

See original GitHub issue

I have a line chart with a legend and 3 lines drawn. When you click the legend the lines show/hide and the graph adjusts accordingly. Out of the box the datalabels do not hide whenever a line is hidden. I am currently using this method of hiding the datalabels:

options: {
    plugins: {
        datalabels: {
            display: (context: any) => {
                return !context.dataset._meta[0].hidden;
            },
        },
    },
},

This works, but the _meta[0].hidden thing seems like a hack/not something we’re supposed to be using. Is there a different approach that is more stable?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
simonbrunelcommented, Jun 29, 2018

That’s a bug, will be fixed in next release (labels will always be hidden if the dataset is hidden).

As a workaround, you can use:

display: function (context) {
    return context.chart.isDatasetVisible(context.datasetIndex);
}

EDIT: remove TypeScript

1reaction
wjohnstocommented, Jun 29, 2018
display: function (context) {
    return context.chart.isDatasetVisible(context.datasetIndex);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Show Hidden Data in Excel Chart or Sparkline - Contextures
Instead of showing all the data, the chart only shows data from the visible rows. The same problem can occur with Excel sparklines...
Read more >
2 Methods to Hide or Show Specific Lines in a Line Chart in ...
Next, press the “Ctrl” again. And then click the line chart. After that, you can also release the button. After that, click the...
Read more >
Showing/Hiding lines with LineChart - Stack Overflow
I have the following code to display lines on my chart using ChartsRealm. How can I show/hide individual lines on the chart?
Read more >
Hide / show sheet on dashboard based on filter selection
I am new to Tableau (1st week) and I'm trying to find a solution to a problem I'm having in showing / hiding...
Read more >
Showing/hiding the legend - TIBCO Product Documentation
... provides information that helps the viewer identify what is represented in a visualization. You can decide whether or not the legend should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found