Google Bar Chart Time Label Interval

Posted by Alex Angelini on Stack Overflow See other posts from Stack Overflow or by Alex Angelini
Published on 2010-12-26T18:49:32Z Indexed on 2010/12/26 18:53 UTC
Read the original article Hit count: 223

Hi I am using Google Bar Chart through the visualization API on my site:

http://code.google.com/apis/visualization/documentation/gallery/imagebarchart.html

And my x-axis is time, and every time interval is a time of day in the format (HH:MM)

Here is my code for the graph:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
    %s
    google.load("visualization", "1", {packages:["imagebarchart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Date');
        data.addColumn('number', 'Amount');
        data.addRows({{Rows}});
        %s
        var chart = new google.visualization.ImageBarChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 900, height: 340, min: 0, isVertical:true, legend:'none'});
    }
</script>

The rows of data are added later using a templating engine, but that is the jist of my chart. Because I have added my time variable as 'string' I cannot use the valueLabelsInterval option to only show every 4 labels. Because I can't do that the labels overlap and look ugly. Is there any other way to only show every other time label or every 4th one, I read through the docs but could not see how to do it.

Any help would be greatly appreciated thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about google-charts