Search code examples
javascriptdygraphs

How to fix Uncaught TypeError: Cannot read property 'pageX' of undefined in Dygraphs?


When zooming on the Y-axis on Android in Chrome sometimes website scroll to the top. When attaching a debugger there is an error in 520 line of the code:

Uncaught TypeError: Cannot read property 'pageX' of undefined dygraphs

How to fix it?


Solution

  • To fix it find the code in dygraph.js:

    if (touches.length == 1) {
        xScale = 1.0;
        yScale = 1.0;
    

    And change it to:

    if (touches.length == 1 || initialTouches.length == 1) {
        xScale = 1.0;
        yScale = 1.0;