chrisb89123456789

Is there a way to rescale an axis after hiding a series?

Dear all,

I implemented a filter in my chart. It does not remove the series completely, but only hides them (visible=false).

Like this, I can use a slider as some kind of threshold filter and change the visibility without loading data for the entire series again.

However, I fail to rescale the axis, after hiding some of the series with my threshold filter. Do I really need to remove a series to rescale an axis?

At least in my case neither chart.redraw() nor chart.render() made the axis rescale...

Thanks,
Chris
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: Is there a way to rescale an axis after hiding a series?

Hi, Chris,

How do you hide your series? Are you using .hide() and .show() methods?

jsFiddle: https://jsfiddle.net/BlackLabel/wkzou7c5/

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead
chrisb89123456789

Re: Is there a way to rescale an axis after hiding a series?

Dear Rafal,

well, I was just setting the visibility but also your method did not have any effect in my case (parallel coordinates).

Please find attached a JS-Fiddle example:
https://jsfiddle.net/tpdyc3f6/6/

In my case the rescale would be more important than in the js fiddle, because I have lots of data points at the low end and only few at the top of each yAxis.

Thanks for your help,
Chris
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: Is there a way to rescale an axis after hiding a series?

Chris,

You are right, axes don't scale with Parallel Coordinates chart. I have reported it as a bug: https://github.com/highcharts/highcharts/issues/9248

For now, you can use this workaround:

Code: Select all

(function(H) {
  H.addEvent(H.Axis, 'getSeriesExtremes', function(e) {
    if (this.chart && this.chart.hasParallelCoordinates && !this.isXAxis) {
      var index = this.parallelPosition,
        currentPoints = [];
      H.each(this.series, function(series) {
        if (series.visible && H.defined(series.yData[index])) {
          // We need to use push() beacause of null points
          currentPoints.push(series.yData[index]);
        }
      });
      this.dataMin = H.arrayMin(currentPoints);
      this.dataMax = H.arrayMax(currentPoints);

      e.preventDefault();
    }
  });
})(Highcharts);
https://jsfiddle.net/BlackLabel/2sq7wmof/

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead

Return to “Highcharts Usage”