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

yAxis zoom in Highstock #979

Closed
pawelfus opened this issue May 25, 2012 · 25 comments
Closed

yAxis zoom in Highstock #979

pawelfus opened this issue May 25, 2012 · 25 comments

Comments

@pawelfus
Copy link
Contributor

Is possible to zoom in, but not to zoom out - ResetZoom button doesn't show up. Example from docs: http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/stock/chart/zoomtype-y/

Workaround is to create separate button for that: http://jsfiddle.net/Fusher/GyurF/

@VladyslavGoloshchapov
Copy link

The is issue is fully described in thread - http://highslide.com/forum/viewtopic.php?f=9&t=11345&p=73175

The fix is also discussed there. Appears that option for ResetZoom button is hardcoded in the library.
So the fix would be to comment out or remove that code as described in this message http://highslide.com/forum/viewtopic.php?f=9&t=11345&p=73175#p63306http://highslide.com/forum/viewtopic.php?f=9&t=11345&p=73175#p63306

@wjgilmore
Copy link

FWIW I'm running the very latest Highstock release (pulled from GH this morning), and it appears that this bug does indeed still exist. Setting resetZoomEnabled to true while setting zoomType to 'y' (or 'xy' for that matter) does not result in the reset zoom button being displayed on the chart. I can zoom in just fine, but cannot zoom out.

@resnyanskiy
Copy link

Is there a way to vote for this issue?
fusher, did you create pull request?

@TorsteinHonsi
Copy link
Collaborator

Just removing the chart.resetZoomEnabled fixes the case for Y axis zooming, but for X axis zooming the zoom button now results in the axis being zoomed out to "All" view. Also, you can continue to navigate the X axis and the zoom button still shows. This is probably not what you want in a stock chart. How would you expect the Reset zoom button to work?

Should we just enable it for Y axis and ignore everything that has to do with the X axis as long as there is a navigator attached to it?

@resnyanskiy
Copy link

I think Reset zoom button should be displayed only if chart had zoomed by Y axis.

Just removing the chart.resetZoomEnabled fixes the case for Y axis zooming

Removing this from Scroller class and RangeSelector class constructors do exactly what i want.
Is there a need to create pull request?

@TorsteinHonsi
Copy link
Collaborator

No, we need to do more than just remove resetZoomEnabled, since we need to separate the behaviour of X and Y axis. I'll have a look at it.

TorsteinHonsi added a commit that referenced this issue Aug 27, 2012
@TorsteinHonsi
Copy link
Collaborator

All right, I refactored this logic so that only the X axis is ignored when it comes to the reset zoom button whenever there is a navigator attached to the X axis. See http://jsfiddle.net/highcharts/GyurF/9/.

This is what it behaves like now:

  • When zoomType = 'x', no button is shown because the navigator allows zooming out.
  • When zoomType = 'y', the button is shown
  • When zoomType = 'xy', the button is shonw, but clicking it only affects the Y axis zoom, not the X axis.

Please review the demo and report back. If you agree this is a useful fix, I'll close the issue.

@resnyanskiy
Copy link

zoomType = 'xy', the button is shonw, but clicking it only affects the Y axis zoom, not the X axis

For me it's not quite natural. Typical use case for this mode (zoomType = 'xy') - selecting chart area (rectangle) which you want to zoom. It would be more natural for user, if reset zoom button in this mode will reset zoom (zoom out) both for X and Y axises (just like it was, when delete chart.resetZoomEnabled).

@VladyslavGoloshchapov
Copy link

I agree with last comment

@TorsteinHonsi
Copy link
Collaborator

It would be more natural for user, if reset zoom button in this mode will reset zoom (zoom out) both for X and Y axises (just like it was, when delete chart.resetZoomEnabled).

But that wasn't what it did when we just deleted chart.resetZoomEnabled. What it did was that the X axis zoomed all the way out, equivalent to clicking the "All" button in the range selector. And I think that was more confusing than anything. So I propose two options:

  • When clicking Reset zoom, release the zoom on the Y axis, and leave the X axis untouched, because the user has the Navigor to help zoom out.
  • When clicking Reset zoom, release the zoom on the Y axis, and reset the X axis zoom to the extremes it had prior to the selection zoom.

@resnyanskiy
Copy link

I agree.

When clicking Reset zoom, release the zoom on the Y axis, and reset the X axis zoom to the extremes it had prior to the selection zoom.

My vote for this solution.

@VladyslavGoloshchapov
Copy link

+1

by the way sometimes we don`t need to have range selector and navigator.
in this case Zoom out is very useful

@TorsteinHonsi
Copy link
Collaborator

by the way sometimes we don`t need to have range selector and navigator.

Yes, this discussion only applies to when the navigator is enabled.

Anyway, we'll try out the option with X axis going back to previous zoom
level.

@TorsteinHonsi
Copy link
Collaborator

Okay, please try now. I pulled the whole thing out of the Chart prototype
and created an override for stock charts.

@resnyanskiy
Copy link

It's just works!
Quick response, interesting discussion, rapid development. @highslide-software, you are awesome!

@TorsteinHonsi
Copy link
Collaborator

Thanks and you're welcome!

@TorsteinHonsi
Copy link
Collaborator

A new problem case here: http://jsfiddle.net/highcharts/npGey/

Instead of checking for scrollbar and navigator, we should check for range selector and navigator. The scrollbar alone doesn't provide a way to zoom back out, like the range selector and navigator do.

TorsteinHonsi added a commit that referenced this issue Sep 6, 2012
… the navigator and rangeSelector were hidden, and the scrollbar was visible. Related to #979.
@kevin-coelho
Copy link

Still having this issue in highstock. Currently using:

zoomType: 'x'
navigator: disabled
rangeSelector: enabled

reset zoom button is disabled. What I would like:

  1. user drags across the chart to zoom in on specific section
  2. reset zoom button appears
  3. clicking it should reset to whatever the previous extremes were

This is different than using rangeSelector (inconvenient typing to get specific) or clicking a button which are fixed to whatever intervals are defined (1m, 3m, 6m etc.)

Ideally, reset zoom would keep track of a stack of extremes and clicking it twice would pop back until chart reaches the "All" zoom. Then as a user I can quickly zoom in and out of different sections.

@pawelfus
Copy link
Contributor Author

pawelfus commented Feb 1, 2018

Workaround:

To show/hide button under any circumstances, we can modify options in a simple wrapper, demo: http://jsfiddle.net/BlackLabel/npGey/25/

Snippet:

(function(H) {
  H.wrap(H.Axis.prototype, 'zoom', function(proceed, newMin, newMax) {
    var ret;

    // This will always cause the button to show up after zooming in:
    this.chart.options.rangeSelector.enabled = false;
    this.chart.options.navigator.enabled = false;

    ret = proceed.call(this, newMin, newMax);

    // Restore default options
    this.chart.options.rangeSelector.enabled = true;
    this.chart.options.navigator.enabled = false;

    return ret;
  });
})(Highcharts);

@kevin-coelho - regarding history of zooming events, I agree that would be cool feature. Maybe instead of double click I would prefer two small buttons (e.g. << and <) but it probably vary between implementations and designs.

@SirZdanius
Copy link

The button doesn't show up for me either with navigator enabled and zoomType: 'xy'.

As far as i can see in the fiddle posted by @TorsteinHonsi this is how the library behaves - if either rangeSelector or navigator is enabled, then the reset zoom button doesn't appear.
It doesn't match the described behavior of appearing but only resetting y-axes (which is precisely the behavior my use case needs) or resetting the y-axes and returning the x-axis to the previous state (which, while unintuitive to me, would also be okay).

Is there some proper way to zoom out on the y-axes on a StockChart with scrollbars and navigator enabled?

@sebastianbochan
Copy link
Contributor

Hi @SirZdanius,
The problem with "reset zoom button" is fixed in the master branch.

Demo:

Please test and let me know if all worked properly or you have any suggestions.

@SirZdanius
Copy link

Hi @sebastianbochan ,
Thanks for the quick reply.

Judging by the demo, the issue is indeed fixed! Any idea when we can expect this version on npm?

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Jun 14, 2018

Hi @SamHoulder,
We will release the next version by the end of this month.

@EloHailwidis
Copy link

EloHailwidis commented Jun 27, 2018

Hi @sebastianbochan ,
Any news about the date of the next version ?
Thanks :)

@sebastianbochan
Copy link
Contributor

Hi @EloHailwidis,
The release will be this week.
I advice you to subscribe our newsletter here and be notified about new version, by email.

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

9 participants