Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

take into account the size of the container when rendering a PNG of the image #199

Open
chriddyp opened this issue May 8, 2018 · 7 comments
Labels
dash-type-bug Something isn't working as intended help wanted

Comments

@chriddyp
Copy link
Member

chriddyp commented May 8, 2018

plotly.js won't take into the size of the container when rendering an image (plotly/plotly.js#1576) and almost all dash app's graphs are going to be in responsive containers with dynamic sizes.

so, we should add a workaround to dcc.Graph to override the download png behaviour so that the graph is properly sized.

originally reported in https://community.plot.ly/t/save-plot-as-png-sizing-and-positioning/10166

@chriddyp chriddyp added dash-type-bug Something isn't working as intended help wanted labels May 8, 2018
@ijustmadethisforplotly
Copy link

Is there any progress on this?

@nicolaskruchten
Copy link
Contributor

@etpinard could we add a flag to downloadImage that implements this behaviour, and then Dash could set that flag via toImageButtonOptions by default ?

@dawehner
Copy link

I implemented my own download button, which gets the size of the dom element:

export default {
  name: 'toImage2',
  title: gd => {
    return 'Download plot as a png';
  },
  icon: Plotly.Icons.camera,
  click: gd => {
    gd.layout.width = gd.offsetWidth;
    gd.layout.height = gd.offsetHeight;

    Plotly.downloadImage(gd);
  },
};

@ijustmadethisforplotly
Copy link

Is it possible to implement this on py.plotly?
If so how?

@ijustmadethisforplotly
Copy link

@dawehner can this be applied in plotly.py

@dawehner
Copy link

dawehner commented Apr 1, 2019

@ijustmadethisforplotly I don't know, I'm not using py.plotly. We use using the plotly JS library directly.

@nicolaskruchten
Copy link
Contributor

This is now possible via configs: plotly/plotly.js#3746

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dash-type-bug Something isn't working as intended help wanted
Projects
None yet
Development

No branches or pull requests

4 participants