Adding a new option to make the y-axis fixed. #888
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While I do realize this is unlikely to be accepted, I'd like to bring up this discussion and maybe someone proposes a better solution.
On Dygraphs 1.x, when you zoomed out the graph with a double click, the y-axis was preserved. On Dygraphs 2.x, the y-axis automatically set based on the data. There's an example about this here:
https://github.com/danvk/dygraphs/blob/aa0b189f8cb22d64ce65cc9b205c90f6e4fd1257/tests/old-yrange-behavior.html
The same example also shows how you can get around the new behavior using a plugin for the double-click event. However, when using the
rangeSelector
plugin, there doesn't seem to be an easy way around this.It should be possible to restore the
valueRange
property on the predraw event, however, since usingupdateOptions
triggers a redraw, it has to be done without it, thus becoming error-prone. However, after further investigation, I couldn't find a way to do this withanimatedZooms: true
, since the animation is calculated usingnewValueRanges = this.yAxisExtremes();
.Finally. I also think this behavior is undesired if a
valueRange
was explicitly set. Dygraphs doesn't offer a way to change the y-axis by default, so it's impossible to restore the initial graph state without resorting to custom code. which I find very counter-intuitive.I did not write an auto_test for this, but am willing to if this PR is to be accepted in its current form, or any form that leads to a solution to the problem.
Feedback is appreciated. Thanks for your hard work.