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.

Legend strikethrough not appearing when using generateLabels

See original GitHub issue

Expected Behavior

When I click on a dataset label in the legend, the corresponding dataset hides and the label has a strikethrough.

Current Behavior

The dataset hides but there is no strikethrough.

Steps to Reproduce

https://codepen.io/roxennnn/pen/yLgqRvv

Context

My goal is to change the dataset legend color, removing the opacity present in the dataset’s backgroundColor. I could do this using the generateLabels property in options.plugins.legend.labels. However, there is no strikethrough anymore when hiding a dataset.

Environment

  • Chart.js version: 3.1.1
  • Browser name and version: Firefox (v87.0b2) and Chrome (v89.0.4389.114)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
roxennnncommented, Apr 17, 2021

getDatasetMeta is perfect for me! Thank you again!

0reactions
kurklecommented, Apr 18, 2021

@kurkle any objections to making that method public and dropping the _?

No objections

Read more comments on GitHub >

github_iconTop Results From Across the Web

Legend strikethrough not appearing when using ...
1. var ctx = document.getElementById('myChart'); ; 2. var myChart = new Chart(ctx, { ; 3. type: 'bar', ; 4. data: { ; 5....
Read more >
chart.js - Chartjs legend onclick doesn't strikethrough
1 Answer 1 ... This is because you never set the hidden property in your generateLabels so chart.js does not know which labels...
Read more >
How to Change Legend Effect to Shade Unshade Instead of ...
To do this we need to use the generateLabels () function. ... how to draw charts in Chart JS by showing you in...
Read more >
Legend
When using the 'chartArea' option the legend position is at the moment not configurable, it will always be on the left side of...
Read more >
Hidden one of the labels by default · Issue #2794 · chartjs ...
Assume I have 5 labels in the legend, when I click one of them, Label will be rendered with a strike-through effect, and...
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