plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.94k stars 1.86k forks source link

Plots are initially displayed with a wrong margin in Chrome #5312

Open lothas opened 3 years ago

lothas commented 3 years ago

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

archmoj commented 3 years ago

Thanks for the report. Seems like a Chrome bug to me. Here is a codepen. Should refresh few times to see the problem with the right margin. It might be related to loading the fonts & computing bounding boxes for the text.

lothas commented 3 years ago

Thanks @archmoj. I tried the codepen but it doesn't work for me (the plot is displayed but it's not responsive). I tried it both in Chrome and Firefox on Windows 10.