Plots are initially displayed with a wrong margin in Chrome
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 28
Description
I'm working on a web-app that should run in desktop and mobile. I've tested the app in Firefox and Chrome and noticed that the width (or right margin) of the plot is wrongly initialized.
The problem: The plot is too big when the page is initially loaded. After resizing the browser (responsive layout), the plot is updated and suddenly fits the screen properly.
I've added a restyle call to my script and that improves things a bit, but not completely.
<div id="progress-plot"></div>
<script>
var graph = {{progress_plot | safe}};
var config = {responsive: true, displayModeBar: false, showTips: true}
Plotly.newPlot('progress-plot', graph.data, graph.layout, config);
Plotly.restyle('progress-plot', graph.layout);
</script>
The app is a Flask app (the snippet is from a jinja2 page) and I'm using Bootstrap for the front-end.
I've attached a file with the contents of graph.
graph.txt
Here are some screenshots:

After slightly resizing the page:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided Plotly.newPlot snippet in Chrome using the attached graph.txt and the responsive Bootstrap layout. Inspect the initial sizing path before and after browser resize; done when the plot has the correct width and right margin on its first render without requiring resize or restyle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bootstrap, flask, javascript
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100