chartjs / chartjs/chartjs-plugin-zoom

Timeperiod not consistent whilst panning

Open
#824 1 comment 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

When using pan to move left/right on the x-axis of my chart I noticed that the time period does not stay consistent. This does not feel/look like normal behaviour.

I don't see this "stretching" behaviour, when using the official demo here: https://www.chartjs.org/chartjs-plugin-zoom/samples/pan-region.html

I'm using Chart.js version: 4.4.1

`zoom: {
limits: {
x: {
min: CHART_ZOOM_MIN.getTime(),
minRange: 60 * 60 * 24 * 1000, // 1 day
},
},
pan: {
enabled: true,
threshold: 0,
mode: 'x',
onPanStart({ chart, point }) {
const area = chart.chartArea;
const w25 = area.width * 0.25;
const h25 = area.height * 0.25;
if (
point.x < area.left + w25 ||
point.x > area.right - w25 ||
point.y < area.top + h25 ||
point.y > area.bottom - h25
) {
return false; // abort
}
},
onPanComplete: ({ chart }) => {
const { min, max } = chart.scales.x;

console.log(
'Pan: ',
format(new Date(min), 'dd-MM-yyyy HH:mm'),
format(new Date(max), 'dd-MM-yyyy HH:mm'),
);
console.log(
'Days between: ',
(max - min) / (1000 * 60 * 60 * 24),
);
},
}`

image

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.