Skip to content

Add support for responsive charts #2969

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
antoinerg opened this issue Sep 4, 2018 · 8 comments
Closed

Add support for responsive charts #2969

antoinerg opened this issue Sep 4, 2018 · 8 comments
Labels
feature something new

Comments

@antoinerg
Copy link
Contributor

antoinerg commented Sep 4, 2018

In order for charts to look great on any devices/orientation, I suggest that we add the option to resize charts whenever the window's size changes.

For example, it is common for a user to switch his phone from landscape to portrait mode which results in the following unaesthetic/broken result:

before

@etpinard
Copy link
Contributor

etpinard commented Sep 4, 2018

Good call!

This would probably work best as new config option (i.e. I don't think this should be a layout attribute).

@bpostlethwaite
Copy link
Member

This could have interesting implications (I think positively so!) for Plotly's own embed and react-plotly.js

cc @nicolaskruchten

@nicolaskruchten
Copy link
Contributor

This would be basically baking in https://plot.ly/javascript/responsive-fluid-layout/ via a config option? Seems helpful, indeed, but also kind of incomplete... Lots of people in the react-plotly.js world are hitting issues where even though the window doesn't change size, the containing element does (via a resize operation or a CSS reflow due to new elements appearing alongside or whatnot) and so they need to fire that resize call themselves anyway.

@etpinard
Copy link
Contributor

etpinard commented Sep 5, 2018

basically baking in https://plot.ly/javascript/responsive-fluid-layout/ via a config option?

We could even shoot for moving all the embedplot logic in plotly.js.

@antoinerg
Copy link
Contributor Author

even though the window doesn't change size, the containing element does (via a resize operation or a CSS reflow

ResizeObserver is a proposal to react to any events that resize a element. However, only Chrome implements it thus far (caniuse#ResizeOberserver) so we would need to resorts to a polyfill.

In the meantime, I will submit a PR doing what most (if not all) other plotting libraries claiming to be responsive do: simply react to window resize events.

@antoinerg
Copy link
Contributor Author

Closed by PR #2974

@nicolaskruchten
Copy link
Contributor

Let's make sure we get this in the documentation as well! :) /cc @cldougl what's the process for doing this?

@cldougl
Copy link
Member

cldougl commented Sep 10, 2018

Yep- you can open an issue in the documentation repo: https://github.com/plotly/documentation/issues
If you have a link to a test or codepen example that exhibits the new feature that would be super helpful to include in the issue.

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

No branches or pull requests

5 participants