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

Export zoomRect and make it more configurable #659

Merged
merged 6 commits into from
Sep 1, 2022

Conversation

joshkel
Copy link
Contributor

@joshkel joshkel commented May 20, 2022

As discussed in #608, normal zooming supports customizing zoom behavior using zoomFunctions, but the drag-to-zoom functionality that's implemented by zoomRect bypasses zoomFunctions and calls updateRange correctly.

I have a custom scale implementation that relies on zoomFunctions, so trying to enable drag-to-zoom causes problems. (Specifically, I'm breaking up the axis into viewports so that I can stack multiple series within this chart - somewhat like this example. The scales for the individual portions of the chart shouldn't be directly zoomed, because their layout is managed by a separate, controlling scale, so their zoomFunctions are no-ops.)

Zooming by rectangle appears to be a distinctly different interface than zooming by percentage and focal point, so this PR adds a zoomRectFunctions to let scales customize that behavior and cover this use case.

I'm also now exposing zoomRect as part of the public API, like zoom and zoomScale.

joshkel added 2 commits May 20, 2022 14:22
Normal zooming supports customizing zoom behavior using zoomFunctions, but the drag-to-zoom functionality that's implemented by zoomRect bypasses zoomFunctions and calls updateRange correctly.

I have a custom scale implementation that relies on zoomFunctions, so trying to enable drag-to-zoom causes problems. (Specifically, I'm breaking up the axis into viewports so that I can stack multiple series within this chart - somewhat like this example. The scales for the individual portions of the chart shouldn't be directly zoomed, because their layout is managed by a separate, controlling scale, so their zoomFunctions are no-ops.)

Zooming by rectangle appears to be a distinctly different interface than zooming by percentage and focal point, so it seems reasonable to add a zoomRectFunctions to let scales customize that behavior and cover this use case.
To go with adding stronger zoomRect functionality, it makes sense to expose the `zoomRect` function directly.

The TypeScript type definitions said that standalone functions like `zoom` were exported, but these don't actually exist.  Fix that.
types/index.d.ts Outdated Show resolved Hide resolved
types/index.d.ts Outdated Show resolved Hide resolved
@kurkle kurkle merged commit 0259d37 into chartjs:master Sep 1, 2022
@joshkel joshkel deleted the zoom-rect branch September 4, 2022 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants