Responsive doesn't fill the entire parent


#1

Hello,

I am trying to figure out if plot.ly will work for our organization, so I am looking at a few charting libraries. My objective is to let the chart fill up the region of the parent. No whitespace at all. If it can’t do that, the chart size could be smaller to respect its aspect ratio.

I have already searched for existing solutions on how to make the responsive charts. In this example, my parent could be 400px by 250px. Right now it adds lots of whitespace, and for some reason, the labels are not part of the graph structure.

CodePen Attempt 1

From what I have read in the documentation my initial attemp was using the responsive config option:

image

CodePen Attempt 2

Then I was trying autosize from the docs, same issue:

CodePen Attempt 3

Then I was reading more, and people started using the margin layout property, looks weird, all the labels are cut:

image

CodePen Attempt 4

If I know the margins exactly, then I can set it this way:

CodePen Attempt 5
Then there is automargin which sounds perfect, but that doesn’t work at all, doesn’t respect the parent size.


Some questions:

  1. How could we perfectly fit the chart in the space allocated, no whitespace anywhere, without playing with margins?
  2. Is there a way to figure out the width of the labels on the left, top, right, and bottom, so we could apply the margins programmatically?

Thanks!


#2

I am trying out highcharts as well, and for my attempt 1, it was working as expected.

CodePen Attempt 1 HighCharts
image

If there is a solution for above for plotly, I would give it a try again.


#3

Here’s the “right” way: https://codepen.io/etpinard/pen/gEKNeb

It’s a little cumbersome right now unfortunately; we’re planning on polishing that up in the v2 release.