如何使用google图表API绘制每列多个值的折线图

时间:2012-09-04 12:00:20

标签: ruby-on-rails google-groups google-groups-api

我想使用谷歌图形API以类似

的方式绘制折线图
 I have 24 values mean (1 day = 24 hours) in x-axis from 0 to 23
 And i have 3 column in y-axis today , yesterday and week.

所以我想在今天,昨天和每周的一小时显示12个值的值。

例如我有6个小时,然后最多36个值应该在y轴上显示.12每个今天,每周和昨天。

如何使用以下代码执行此操作。

 <html>
  <head>
   <script type="text/javascript" src="https://www.google.com/jsapi"></script>
   <script type="text/javascript">
  google.load("visualization", "1", {packages:["corechart"]});
  google.setOnLoadCallback(drawChart);
  function drawChart() {
      var data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2004',  1011,      420],
          ['2004',  1004,      430],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
      ]);

      var options = {
          title: 'Company Performance' ,
          hAxis: { minValue: 0, maxValue: 15},
          vAxis: { minValue: 0, maxValue: 15},
          legend: 'none'

      };

      var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
      chart.draw(data, options);
  }
 </script>
</head>
 <body>
     <div id="chart_div" style="width: 680px; height: 285px;margin-top: 10px;margin-left: 10px;"></div>
  </body>
 </html>

由于

0 个答案:

没有答案