plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
17.02k stars 1.86k forks source link

Wheel event registered on the canvas even though `scrollZoom` is disabled #6458

Closed zfei closed 3 months ago

zfei commented 1 year ago

I'm plotting a 3d surface graph with scrollZoom disabled.

When scrolling the web page with the mouse on the canvas, the scrolling gets stuck, as the scene element is stilling capturing the wheel event somehow.

After some debugging, it looks like the culprit is we are registering a wheel event on the canvas regardless of whether the scrollZoom flag is true or not.

Can we not add the listener at all if scrollzoom is disabled?

const newData = {};
const dates = new Set();

timeseriesList.map((row) => {
    newData[row.symbol] = row.data;
    Object.keys(row.data).map(d => dates.add(d))
})

const dateArray = Array.from(dates);

var data = [{
    x: dateArray,
    y: symbols,
    z: symbols.map(symbol => dateArray.map(date => newData[symbol][date])),
    type: 'surface',
    colorscale: 'Portland',
}];
var layout = {
    title: title,
    autosize: true,
    height: 500,
    margin: {
        l: 65,
        r: 50,
        b: 65,
        t: 90,
    },
    scene: {
        xaxis: {
            calendar: 'chinese',
            autorange: 'reversed',
        },
        yaxis: {
            autorange: 'reversed',
        },
        aspectratio: { x: 4, y: 1, z: 1.5 },
        camera: {
            eye: { x: 0, y: 2, z: 0 },
            projection: {type: 'orthographic'},
        },
    },
};
Plotly.newPlot(
    container,
    data,
    layout,
    {
        // TODO: Need to unregister scroll event. Currently page scroll doesn't work.
        scrollZoom: false,
    },
);
gvwilson commented 3 months ago

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson