plotly / plotly/plotly.js

Plots are initially displayed with a wrong margin in Chrome

Open
#5,312 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
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:
image
After slightly resizing the page:
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.