Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highcharts 5.0 - afterSetExtremes not triggered after Axis update #5773

Closed
qingweibinary opened this issue Oct 4, 2016 · 10 comments
Closed

Comments

@qingweibinary
Copy link

qingweibinary commented Oct 4, 2016

Expected behaviour

afterSetExtremes should be triggered everytime extremes changed

Actual behaviour

It is only trigger onload, and never trigger after that despite how I change extremes

Live demo with steps to reproduce

http://jsfiddle.net/uur9wr57/

  1. open console
  2. click the button
  3. No message is log

Affected browser(s)

Only tested in chrome

@pawelfus
Copy link
Contributor

pawelfus commented Oct 4, 2016

Hi @qingweibinary - it should be xAxis.events.afterSetExtremes, not xAxis.afterSetExtremes, see working demo: http://jsfiddle.net/e6psyt40/

@qingweibinary
Copy link
Author

qingweibinary commented Oct 5, 2016

Hi @pawelfus

Really sorry for wasted your time, the bug is still there, but my method to reproduce was wrong

Here's an updated fiddle that illustrate it correctly

http://jsfiddle.net/uur9wr57/2/

  1. click button
  2. try to move the extremes and now events is not triggered
  3. from the console output, it seems calling update method remove the events options

@pawelfus
Copy link
Contributor

pawelfus commented Oct 5, 2016

Oh, now I see, thank you!

Highcharts demo: http://jsfiddle.net/qyg3ee7b/

Steps to reproduce the issue:

  • drag&drop to zoom in: callback is executed
  • click Update xAxis
  • drag&drop to zoom in: callback is not executed anymore

@pawelfus pawelfus reopened this Oct 5, 2016
@pawelfus pawelfus changed the title Highcharts 5.0 - afterSetExtremes not triggered Highcharts 5.0 - afterSetExtremes not triggered after Axis update Oct 5, 2016
@jschuler
Copy link

jschuler commented Oct 6, 2016

Also affects setExtremes event

@NoahLerner
Copy link

Hi,

I believe this bug needs to be reopened. The latest version of Highstock (probably Highcharts as well) still has this bug. The original chart.options object is mutated so that the callback function is removed from the config. You can work around this by adding the {event: callbackfunction} to the update call, but this creates unclean code.

Here is a fiddle showing log prints that after update, the chart.options.xAxis[0].events is deleted:
http://jsfiddle.net/axbc7m5r/5/

best

@pawelfus
Copy link
Contributor

pawelfus commented May 6, 2019

Hi @thewholuver94

Thanks for reporting, but it looks right to me: http://jsfiddle.net/BlackLabel/yz4q5ts6/ - apart from missing options.xAxis[0].events.<name>, event is properly called.

@NoahLerner
Copy link

Hey @pawelfus , that's true, the event is properly called in the Fiddle.

In our implementation (legacy code that I can't really touch), we have decided to make dynamic changes to the chart.options object & when we want to redraw we destroy and construct a new chart each time using the options object. For users who do it this way, the event is not properly called because the event was erased from the options object. Another reason I can't just move to doing it the correct way using the Highcharts API is because we have to support Highstock 2.1.7 & Highstock 7.0.3 simultaneously & not all functionality is available in v2.1.7.

I've already given a workaround above (save the callback function & send it along with the update call), but I just thought I'd let you guys know in case mutating the original options object is unwanted behavior.

@slutske22
Copy link

@pawelfus I am experiencing this bug again with highcharts 9. Here is an example: https://codepen.io/slutske22/pen/MWrQdvQ?editors=1011

  navigator: {
    height: 80,
    xAxis: {
      events: {
        afterSetExtremes: e => {
          console.log(e);
        },
      },
    },
  },

The afterSetExtremes function, or even the setExtremes function is only firing once, not every time the user makes a changes with the navigator handles. Is this bug back? Am I doing something wrong? Is there a workaround I can use in the meantime? The above jsfiddle links keep crashing for me.

@pawellysy
Copy link
Member

Hello @slutske22!
You set the event to work on navigator axis, which has constant extremes so that the event only fires once. If you set the event to the main xAxis (which extremes are changed by navigator) everything works as expected.

Check the following demo: https://jsfiddle.net/BlackLabel/9b1p5vkn/156/

@slutske22
Copy link

@pawelfus , yes! That is exactly what I needed, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants