Stop Highcharts Networkgraph from redrawing the ma

2019-08-27 17:13发布

问题:

I'm working on a network graph and somebody helped get me to the point where I can hide/show nodes when clicking on them. However, there seems to be default behaviour which redraws the nodes when you move the mouse at all.

Here is the fiddle: https://jsfiddle.net/oLbkpsag/. You'll see that clicking a node hides its children, however if you mouse the mouse after clicking then the node reappears.

I added in

addClass('hide-tree-element')

which has helped on the dataLabel, but the marker or "graphic" redraws every time.

It seems that there is default behaviour to "dim other series" when hovering https://github.com/highcharts/highcharts/issues/9899. Which I thought might be affecting it. I've tried disabling that but it doesn't seem to work.

Any help would be gratefully received!

回答1:

You're right, the inactive state redraws each point on mouseOut event.

To change this default behavior you can simply wrap Highcharts.Series.prototype.onMouseOut method and remove the piece of code responsible for removing inactive state functionality (added here: https://github.com/highcharts/highcharts/commit/f86f50f80160f078bd185e8e5db1251f317f9fff#diff-12c0e234e06f670ee77d64cce2a9205dL768):

// Reset all inactive states
chart.series.forEach(function (series) {
   series.setState('', true);
});

Demo:

  • https://jsfiddle.net/BlackLabel/zrL8w067/