1

我想使用 google graph 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>

谢谢

4

0 回答 0