Center Aligning the Google charts

SherCoder picture SherCoder · Jun 13, 2012 · Viewed 42.7k times · Source

I am trying to center align my google chart but have been unsuccessful in doing so. I have played with padding to move it to the center but I don't want to sit there and play with firebug for long time and figure out the correct position. Is there any simpler such as aligning text text-align: center. Obviously it doesn't work with google charts. (I am new to all of this)

var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));

...some code ...

    <div id='chart_div' style='width: 900px; height: 400px;'></div>             

although I did this padding-left: 140px but is there any better way like align: center

Answer

Robert Niestroj picture Robert Niestroj · Jun 13, 2012

Give the chart_div: display: block and margin: 0 auto;