Satch3000
Satch3000

Reputation: 49384

Google Charts adding options to the charts

I am using this code for creating charts and it works but I need to add the options too just don't know where to add them.

<script type="text/javascript">
    function drawVisualizationHourlyChart() {

        var data = google.visualization.arrayToDataTable([ // Create and populate the data table.
            ['Date - Hour:Minute', 'Cares', 'Bikes', 'Both'],

            <?php
            while( $row = $result->fetch_assoc() ){
                extract($row);
                echo "['Date: ($dateandtime) - {$hour}:{$minute}', {$cars}, {$bikes}, {$both}],";
            }
            ?>
        ]);

            new google.visualization.LineChart(document.getElementById('mydiv')).   // Create and draw the visualization.
            draw(data, {legend: 'bottom', title:"titles here"});
    }

    google.setOnLoadCallback(drawVisualizationHourlyChart);
</script>

And what I want the do is add All the code below into the code above.

 var options = {  
   //options go here
});

Where do I add the options?

Upvotes: 1

Views: 55

Answers (1)

DavidDomain
DavidDomain

Reputation: 15293

The options are the second param of the draw method.

var options = {
  legend: 'bottom',
  title:"titles here"
  };

chart.draw(data, options);

Upvotes: 1

Related Questions