Skip to content

Panning Broken with Chart.js 2.9.0 #279

Closed
chartjs/Chart.js
#6608
@exwm

Description

@exwm

With the latest chart.js v2.9.0 the scale.getValueForPixel method has been changed and its use in chartjs-plugin-zoom (tested with v0.7.4) causes misbehavior of pan with numerical scales and possibly others. Specifically, panning causes the chart to zoom. Exactly one of either the start or end of the scale remains fixed while the other stretches outwards.

The panNumericalScale function in chartjs-plugin-zoom uses scale.getValueForPixel to get the new minimum and maximum values for the scale (see

var newMin = scale.getValueForPixel(scale.getPixelForValue(prevStart) - delta);
).

I believe the changes that are causing this issue were made in this commit of chart.js: chartjs/Chart.js@cbace1c#diff-f0d8f86fecab28f396793911b0e9f36dR746.

A demonstration of the bug can be found here: https://codepen.io/exwm/pen/vYYZREw. Simply pan the chart by dragging with the mouse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions