Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove padding in google chart?

I'm wondering why google charts add a blank padding when not specifying the top/right/left axises.

alt text

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.

like image 217
CodeOverload Avatar asked Nov 24 '10 20:11

CodeOverload


2 Answers

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

like image 196
CodeToad Avatar answered Oct 03 '22 14:10

CodeToad


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!

alt text

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.

like image 45
Dr. belisarius Avatar answered Oct 03 '22 15:10

Dr. belisarius