chartjs / chartjs/chartjs-plugin-zoom

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

Open
#828 3 comments 0 reactions 0 assignees View on GitHub
needs test case
Dominant language
JavaScript
Stars
623
Forks
331
Avg merge
7h 5m
Merged PRs (30d)
7

Description

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:
```typescript
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):
```text

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 { : {…}, : {…} }

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

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.