Replace overScaleMode with more flexible scaleMode #658
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.
As described at #612, I'd like to allow both regular zooming (to zoom both axes via mouse wheel or pinch on the main chart area) and zooming a specific scale (to zoom only one axis via mouse wheel or pinch over the scale axis), but it seems that
overScaleMode
prevents regular zooming from working.I would have expected that
mode
control regular zooming, whileoverScaleMode
controls scale zooming in particular. For example ("scenario A"):{mode: 'xy', overScaleMode: 'y'}
would mean that zooming over the regular chart scales X and Y, and zooming over the Y axis scales Y.{mode: 'x', overScaleMode: 'y'}
would mean that zooming over the regular chart scales X, and zooming over the Y axis scales Y.{mode: 'xy', overScaleMode: 'xy'}
would mean that zooming over the regular chart scales X and Y, and zooming over the X or Y axis scales X or Y, respectively.Instead, it appears that
overScaleMode
restricts and modifiesmode
("scenario B"):{mode: 'xy', overScaleMode: 'y'}
would mean that zooming over the regular chart scales only X, and zooming over the Y axis scales Y.{mode: 'x', overScaleMode: 'y'}
is an invalid configuration.{mode: 'xy', overScaleMode: 'xy'}
would mean that zooming over the regular chart does nothing, and zooming over the X or Y axis scales X or Y, respectively.This PR adds a new property,
scaleMode
, that behaves like scenario A. Since scenario A is strictly more flexible than scenario B, it deprecatesoverScaleMode
.There is a potential change in behavior with this PR: Previously, the
pan
function usedchart.scales
ifoverScaleMode
was undefined, and it evaluateddirectionEnabled
(which calledmode
ifmode
was a function). This meant that it could handle changes to themode
function's return value, and changes to what chart scales exist, even in the middle of a pan operation. Now, the list of scales to check is only evaluated when the pan operation starts.