Skip to content

Zoom reset for scales built with suggestedMin and suggestedMax #801

Open

Description

@apirvane

Hello,

Trying to summarize as much as possible, we have the following use case:

  1. A chart with two 'y' scales - both scales are created using the 'suggestedMin' and 'suggestedMax' properties
  2. Starts to zoom in
  3. Hides the scale and datasets of one of the 'y' scales - this is done via the native legend plugin of chartjs
  4. Resets zoom (this.chart.resetZoom()) - zoom is reset
  5. Observing the onZoomComplete callback, the previously hidden scale now has a 'min'=0 and 'max'=1
    - The expectation would be that the scale would have the initial values

If the chart scales are build using the 'min' and 'max' properties instead of the 'suggestedMin' and 'suggestedMax' (point 1), then the expectation is correctly met.

Thank you.

Activity

  1. kurkle commented on Nov 17, 2024

    @kurkle
    Member

    Might be the same root cause with #798

  2. jwedel commented on Feb 13, 2025

    @jwedel

    We have the exact same scenario as described.

    After resetZoom() is called, the visible chart zoom is correctly reset. Then, we onZoomComplete is called. In that callback, we get the zoomLevel by calling chart.getZoomLevel() to update our app state.

    Instead of the expected 1, we get e.g. 25.

  3. kurkle commented on Nov 21, 2026

    @kurkle
    Member

    I tried to reproduce this with v3.0.0 and could not: two y scales with suggestedMin / suggestedMax, zoom in, hide the dataset of one scale (and the scale), resetZoom(). In onZoomComplete the hidden scale had its suggested range again and getZoomLevel() returned 1, both with mode: 'x' and mode: 'xy'.

    Two changes that are on their way may also bear on this: #1008 keeps the range a reset refers to in step with the data, including datasets being hidden, and #1010 makes getZoomLevel() count only the scales that are zoomed.

    If it still happens for you with 3.0.0, a reproduction (CodePen or similar) would help a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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