简体   繁体   English

Google图表向图表添加选项

[英]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? 我在哪里添加选项?

The options are the second param of the draw method. 选项是draw方法的第二个参数。

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

chart.draw(data, options);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM