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

When zoom quickly, found the scales.x.max < scales.x.min #828

Open
dabeibao opened this issue Aug 23, 2024 · 3 comments
Open

When zoom quickly, found the scales.x.max < scales.x.min #828

dabeibao opened this issue Aug 23, 2024 · 3 comments

Comments

@dabeibao
Copy link

See the onZoomComplete function. When the message is shown in console, the zoom range still has valid data, but the chart is empty.
I am using version '"chartjs-plugin-zoom": "^2.0.1",'

My zoom config is:

    zoom: {
      zoom: {
        mode: 'xy',
        drag: {
          enabled: true,
        },
        pinch: {
          enabled: true,
        },
        scaleMode: 'xy',
        onZoomComplete: (context) => {
          const chart = context.chart;
          const xScale = chart.scales.x;
          if (xScale.max < xScale.min) {
            console.log(xScale);
          }
          chart.update();
        },
      },
    }

The console output is (min 969, max 257):


active: false
​
axis: "x"
​
bottom: 802.8
​
chart: Object { id: 4, width: 1012, height: 805, … }
​
ctx: CanvasRenderingContext2D { globalAlpha: 1, globalCompositeOperation: "source-over", strokeStyle: "#000000", … }
​
fullSize: false
​
height: 8
​
id: "x"
​
labelRotation: 0
​
left: 44
​
max: 257
​
maxHeight: 402.5
​
maxWidth: 967.25
​
min: 969
​
options: Proxy { <target>: {…}, <handler>: {…} }
​
paddingBottom: 0
​
paddingLeft: 0
​
paddingRight: 0
​
paddingTop: 0
​
position: "bottom"
​
right: 1011.25
​
ticks: Array []
​
top: 794.8
​
type: "category"
​
weight: 0
​
width: 967.25
​
x: undefined
​
y: undefined
​

@kurkle
Copy link
Member

kurkle commented Nov 14, 2024

I'm curious why do you have chart.update() in the onZoomComplete? Does removing that change anything?

@dabeibao
Copy link
Author

No. I tried to swap the max/min and call chart.update(), but nothing changed. Forgot to remove this debug code.

@kurkle
Copy link
Member

kurkle commented Nov 17, 2024

I was not able to reproduce this with samples. Can you create a reproduction?

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

No branches or pull requests

2 participants