Remove padding in google chart?
I'm wondering why google charts add a blank padding when not specifying the top/right/lef开发者_如何学运维t axises.
Select the image and you'll find a huge padding except the bottom which is already filled & that's why, how to remove that?
Specifically, Talking about the right and left paddings.
Thank you.
You can use the chartArea
option as follows:
options.chartArea = { left: '8%', top: '8%', width: "70%", height: "70%"};
More documentation can be viewed here:
https://developers.google.com/chart/interactive/docs/gallery/piechart#Configuration_Options
When using the Google Chart API you can eliminate the padding. I made an example Here.
The relevant parameter is chma.
According to the documentation:
You can specify the size of the chart's margins, in pixels. Margins are calculated inward from the specified chart size (chs); increasing the margin size does not increase the total chart size, but rather shrinks the chart area, if necessary.
You can try these parameters online in the Chart Playground HERE.
HTH!
Edit: Warning from Google
Important: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy.
Unfortunately, as said in Chart Margins documentation you can set only the minimum margin on each side of the chart.
Google adds some unnecessary margin (mostly on top) itself and there is no parameter which can stop this behavior.
精彩评论