Skip to content

staticPlot: inconsistent behaviour with bar and pie #3887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lingtalfi opened this issue May 22, 2019 · 2 comments
Closed

staticPlot: inconsistent behaviour with bar and pie #3887

lingtalfi opened this issue May 22, 2019 · 2 comments
Labels
bug something broken

Comments

@lingtalfi
Copy link

lingtalfi commented May 22, 2019

I basically have the same problem as #15: I just want to display plots without the user interaction.
I found the staticPlot option, but the problem is that it also disable the tips for the bar plot I'm working on (see code and screenshot below). However, when I apply the staticPlot: true to a pie bar, I still have those popup tips.
So is there a way to have staticPlot: true AND the hover tips for bar plot?

The screenshot below shows the project I'm working on, with the bar plot on the left, and the pie plot on the right.
We can see the tips I'm talking about on the left plot (where it says male 26, and female 42).
Those are important things to show, even with staticPlot: true, because otherwise there is no way to get the precise value foreach bar of the plot.

My js code for those bars is below:

<img width="1072" alt="Screenshot 2019-05-22 at 13 35 16" src="https://user-images.githubusercontent.com/223667/58172081-dbbccc00-7c97-11e9-8b31-0bc8c7784bff.png">

    //----------------------------------------
    // WEEK DAY MALE FEMALE DISTRIBUTION
    //----------------------------------------
    var trace1 = {
        x: [20, 14, 23, 26, 13, 61, 51],
        y: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', "Sunday"],
        name: 'Male',
        orientation: 'h',
        marker: {
            color: '#36acec',
            width: 1
        },
        type: 'bar'
    };

    var trace2 = {
        x: [12, 18, 29, 42, 20, 75, 64],
        y: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', "Sunday"],
        name: 'Female',
        orientation: 'h',
        type: 'bar',
        marker: {
            color: '#d74747',
            width: 1
        }
    };

    var data2 = [trace1, trace2];

    var layout2 = {
        title: 'Daily Traffic',
        showlegend: true
    };

    var config2 = {
        responsive: true,
        displayModeBar: false,
        // staticPlot: true,
    };
    Plotly.newPlot('plot-2', data2, layout2, config2);


    //----------------------------------------
    // MOBILE DISTRIBUTION
    //----------------------------------------
    var data3 = [{
        values: [34.2, 20, 15, 14, 16.8],
        labels: ['IOS', 'Android', 'Blackberry', 'Symbian', "Others"],
        type: 'pie'
    }];

    var layout3 = {
        title: "Mobile Traffic"
    };

    var config3 = {
        responsive: true,
        displayModeBar: false,
        staticPlot: true,
    };
    Plotly.newPlot('plot-mobile-traffic', data3, layout3, config3);

Screenshot 2019-05-22 at 13 35 16

@etpinard
Copy link
Contributor

Hi @lingtalfi - thanks for writing in.

I just want to display plots without the user interaction.
So is there a way to have staticPlot: true AND the hover tips for bar plot?

By use interaction, I suspect you're referring to zoom/pan on drag motion. It sounds like you still want hover to be enable. If so, try setting fixedrange: true in the axes, see -> https://codepen.io/etpinard/pen/qGpXLj

However, when I apply the staticPlot: true to a pie bar, I still have those popup tips.

Thanks for spotting that. That's a bug staticPlot: true should disable hover. Codepen: https://codepen.io/etpinard/pen/PvEKLx

@etpinard etpinard added the bug something broken label May 22, 2019
@lingtalfi
Copy link
Author

Yes, fixedrange: true did it for me, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants