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:
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:
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.
- How could we perfectly fit the chart in the space allocated, no whitespace anywhere, without playing with margins?
- 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?