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.

Hide/Show the corresponding data from the chart on legend click

See original GitHub issue

I’m submitting a … (check one with “x”)

  • bug report - search github for a similar issue or PR before submitting
  • feature request
  • support request - use StackOverflow (add the ngx-charts tag) or the gitter chat for support questions

Current behavior

A legend item on clicking does not hide/show the corresponding data from the chart

Expected behavior

On clicking the legend item, the corresponding data from the chart should show/hide

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Required for projects

Please tell us about your environment:

Windows 10, Angular 7, ngxcharts 10, Chrome

  • ngx-charts version: 10.0.0
  • Angular version: 7.0.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

All

  • Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
medmanscommented, Aug 29, 2019

@KingDarBoja i think that the goal of this bug is to implement show/hide serie method, if we have two series in the same chart, we can hide one and have still one is showing. isn’t it ?

2reactions
sebastiangugcommented, May 9, 2019

Use Redux and when you click on legend have a function that does something like this: I have this function in my reducer:

function setActiveOffice(
  state: Reporting,
  action: ReportingActions.SetActiveOffice
) {
  if (
    state.activeOfficeSelection.some(
      (office: { name: string }) => office.name === action.office
    )
  ) {
    _.remove(state.activeOfficeSelection, function(el: { name: string }) {
      if (el.name === action.office) {
        return true;
      } else {
        return;
      }
    });
    return tassign(state);
  } else {
    state.activeOfficeSelection.push({ name: action.office });
    return tassign(state);
  }
}

Then use as with | async across all your relevant charts which display the data about the same top-level entities. This is using @ngrx/store

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hide/Show the corresponding data from the ... - Stack Overflow
I am working with angular 6 and ngx-chart and I need on clicking the legend item, the corresponding data from the chart should...
Read more >
Show or hide a chart legend or data table - Microsoft Support
Select a chart and then select the plus sign to the top right. Point to Legend and select the arrow next to it....
Read more >
Ngx Multi Bar Chart Click Legend Hide Show Value (forked)
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Hide Unhide Data Series in Chart on Legend Click | CanvasJS
By combining this with the legend events we can create charts that toggle data series visibility on click of corresponding legend items.
Read more >
Chart js show/hide legend - Javascript - Java2s.com
<html lang="en"> <head> <title>Chart.js - Hide/Show Legend From Button Click</title> </head> <body translate="no"> <div style="width:45%;"> <canvas ...
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