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.

Enhancement Request - Hide Legend Per-Dataset

See original GitHub issue

Current it is easy to remove the legend from charts via the global or chart level config options. However, it would be very useful for me to be able to remove the legend on a per-dataset level.

Currently:

options: {
    legend: {
          display: false
    }
}

Requested API:

var lineChartData = {
    labels: [],
    datasets: [{
        label: '',
        data: [],
    }, {
        data: []
        legend: false,
    }]
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

17reactions
megharajdeepakcommented, Sep 26, 2017

v2.7.0

Under options, add the following:

options: {
  legend: {
    labels: {
      filter: function(legendItem, chartData) {
      
        // return true or false based on legendItem's datasetIndex (legendItem.datasetIndex)
      }
    }
  }
}

Angular\Typescript:

options: {
  legend: {
    labels: {
      filter: (legendItem, chartData) => {
      
        // return true or false based on legendItem's datasetIndex (legendItem.datasetIndex)
      }
    }
  }
}
4reactions
veavvaricommented, Aug 14, 2019

I tried this, but it is not working. Can anyone tell me how can I achieve this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Create Custom Legend for Doughnut Chart ... - YouTube
How to Create Custom Legend for Doughnut Chart that Show Hide Datasets in Chart JSIn this video we will explore how to create...
Read more >
Show or hide a chart legend or data table - Microsoft Support
Show or hide a legend · To hide the legend, click None. Tip: To quickly remove a legend or a legend entry from...
Read more >
Hide Series from the Legend when NOT null - Domo Dojo
I just fiddled around with another dataset, try setting one of the color rules to "contains any" - this will get rid of...
Read more >
Query Legends—ArcGIS REST APIs
Request parameters ; returnVisibleOnly. (Return Visible Only). If set to true, as by default, a legend item class will only appear in the...
Read more >
Chart.js legend took up too much spaces - Stack Overflow
First off, set canvas's width and height using it's native attributes (do not use style attribute), like so :
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