krispo / angular-nvd3

AngularJS directive for NVD3 reusable charting library (based on D3). Easily customize your charts via JSON API.
http://krispo.github.io/angular-nvd3
MIT License
1.29k stars 377 forks source link

turning off scatter chart line doesn't remove line #622

Open garretwilson opened 7 years ago

garretwilson commented 7 years ago

I have a scatterChart that is finally working reasonably well. I even found out how to hook into the legend events to update a list of selected groups based upon the legend checkboxes. I can also programmatically turn groups on or off using data[groupIndex].disabled. That's all working great, and I can turn groups on or off just by manipulating data.

Now I want to turn the line on or off. Turning the line on is easy: I simply set:

const dataGroup = data[groupIndex];
dataGroup.slope = someSlope;
dataGroup.intercept = someIntercept;

And that works like a charm! However, when I click the UI checkbox to turn off the line, I go back and update the same data:

const dataGroup = data[groupIndex];
delete dataGroup.slope;
delete dataGroup.intercept;

But the line stays on the screen!

Note that for groups I have turned off, if I turn off the line (i.e. delete the slope and intercept) and then show those other groups, they do not draw lines. But even if I turn a group off, its line stays. In other words, once a group has drawn a line, nothing I can do with the data can make the line disappear.

Note that if I manually call $scope.api.refresh() as indicated in #37 after removing the slope/intercept, the line disappears --- but the entire chart flashes, which is jarring and ugly.

This looks like a bug to me. Anybody know any workarounds for turning off a line once it has been painted, without manually refreshing the whole chart (or at least without the flashing)?