-
Notifications
You must be signed in to change notification settings - Fork 331
added allowZoom pre-condition to filter out unnecessary zoom events #329
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
added allowZoom pre-condition to filter out unnecessary zoom events #329
Conversation
…gnature of `(chart: Chart, scale: ChartElement, originalOptions: ScalesOptions, changes: ScalesOptionsPendingChanges) => boolean` option as zooming pre-condition evaluator.
* @param {Scale} scale - Scale/Axis being zoomed (x/y, method will be called for each axis) | ||
* @param {ChartOptions} options - Original chart options before any zoom values applied. | ||
* @param {PendingScaleChanges} changes - Changes that will be applied to chart options if method returns true. | ||
allowZoom: function(chart, scale, options, changes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most Chart.js options that take functions have those functions take a single object argument. Can you make these parameters properties on an object that is passed to the function instead?
* @property {MinMaxValue} time - new options.time values (may be undefined) | ||
*/ | ||
/** | ||
* This function may be used to filter unnessecary zoom events. Returns true to allow zooming, false to prevent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
Great adjustment, much in need of it. When do you expect this to be available in the official plugin? |
@nullifiedtsk this PR needs to be rebased |
Closing in favor of #487 |
Can we have this fix for version 0.7.7? Some users can't upgrade to later versions (IE issues) |
Extended zoom plugin options with parameter
options.plugins.zoom.allowZoom
. It is function with signature ofMay be used to prevent unnecessary zooming operations (e.g. chart is zoomed too near).
If function is defined and returns false, chart scale options will be restored as before calculating new time/ticks value (before calling chart.update).
p.s. Added example of usage to README