Skip to content

Zoom edge cases #690

@AsturaPhoenix

Description

@AsturaPhoenix

I ran into a couple edge cases zooming with dynamic data and limits:

The first issue seems related to, and can be fixed by fixing, getInitialScaleBounds() not updating the scale limits (relying on a previous zoom or pan operation to have done so). An easy fix that covers the resetZoom case is to call storeOriginalScaleLimits at the beginning of getInitialScaleBounds, though this does still return stale bounds until resetZoom is actually called; a full fix would be more involved, and it's not clear to me that the functionality is exposed on scales that would make for something correct in all cases (e.g. "original" limits as data change while zoomed for scales with unset min/max, especially if they pad).

The second and third issues can be fixed by simplifying the arithmetic in updateRange(...) to always respect the zoom range, though this does also affect zooming out from category scales in a potentially unintuitive way. Since category zooming tended to round the vanishing case up to 1, preserving the range in the limit case may now zoom out by two categories on the side opposite the limit in the case where the focal point falls between categories, as illustrated in the changed test spec. It may be worth evaluating what the actual desired behavior is here.

Another possible issue it might not be my place to bring up is the definition of zoom amount/level. These don't seem to be spelled out in the documentation as far as I can tell, but the behavior doesn't seem as one might intend:

chart.getZoomLevel() = 1
chart.zoom(1.99);
chart.getZoomLevel() = 100
chart.zoom(-98);
chart.getZoomLevel() = 1

where chart.zoom(2) is a zoom to infinity (min = max). (https://codepen.io/AsturaPhoenix/pen/zYaBqRp)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions