用不同的x轴数据绘制谷歌折线图

时间:2015-02-23 23:41:14

标签: javascript charts google-api nonetype

您好我从sqlite数据库中获得以下数据,以使用谷歌折线图进行绘图。要清楚,有2组数据,我正在尝试绘制2行。 “无”的价值似乎搞砸了这个希望,任何想法?我是javascript的新手,只有基本的python技能。谢谢!

<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([
          ['Time', 'Temperature', 'Temperature 2'],
['2015-02-23 05:27:16', 'None', '22.88'],
['2015-02-23 05:30:02', '28.937', 'None'],
['2015-02-23 05:42:16', 'None', '23.06'],
['2015-02-23 05:45:02', '28.875', 'None'],
['2015-02-23 05:57:16', 'None', '22.94'],
['2015-02-23 06:00:02', '28.75', 'None'],
['2015-02-23 06:12:17', 'None', '22.44'],
['2015-02-23 06:15:02', '28.562', 'None'],
['2015-02-23 06:27:17', 'None', '22.19'],
['2015-02-23 06:30:03', '28.437', 'None'],
['2015-02-23 06:42:17', 'None', '21.63'],
['2015-02-23 06:45:02', '28.375', 'None'],
['2015-02-23 06:57:17', 'None', '21.13'],
['2015-02-23 07:00:02', '28.5', 'None'],
['2015-02-23 07:12:17', 'None', '21.06']


        ]);

        var options = {
          interpolateNulls: true
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    

1 个答案:

答案 0 :(得分:0)

将“无”字符串替换为“空”,谷歌折线图将正确显示图表。

在python中,通过以下方式打印php代码时,可以将None替换为null: replaced_rowstring = rowstring.replace( “无”, “空”)

亲切的问候,  尼科