Skip to content

"Download plot as png" exports with wrong size #2478

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
mlaily opened this issue Mar 18, 2018 · 1 comment
Closed

"Download plot as png" exports with wrong size #2478

mlaily opened this issue Mar 18, 2018 · 1 comment

Comments

@mlaily
Copy link

mlaily commented Mar 18, 2018

Hi,

The toolbar button "Export plot as png" does not always work properly on my plot.

If the browser is maximized when the page loads, the button exports an image with the default size (700x450) instead of the actual size of the rendered plot.

As soon as I resize my browser, the button works as expected, even if I maximize the window afterwards.

This may be related to the auto-scaling of the plot implemented as follows:

        var resizeDebounce = null;
        var graph = document.getElementById("graph");

        function resizePlot() {
            var bb = graph.getBoundingClientRect();
            Plotly.relayout(graph, {
                width: bb.width,
                height: bb.height
            });
        }

        window.addEventListener("resize", function () {
            if (resizeDebounce) {
                window.clearTimeout(resizeDebounce);
            }
            resizeDebounce = window.setTimeout(resizePlot, 100);
        });

(I don't remember where I found this code, probably the plotly forum or stackoverflow)

Calling resizePlot() after Plotly.plot(...) fixes the problem, but I don't understand why it's required.

You can reproduce the issue here: https://lastfm-stats.200d.net/?color=artist&timezone=Europe%2FParis&startDate=2018-01-01&endDate=2018-03-18&username=Yaurthek

@etpinard
Copy link
Contributor

Duplicate of #1576

@etpinard etpinard marked this as a duplicate of #1576 Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants