2015-02-23 132 views
0

嗨,我從一個sqlite數據庫中使用谷歌折線圖來繪製以下數據。要清楚,有2組數據,我想繪製2行。 '沒有'的價值觀似乎混淆了這個希望,任何想法?我是JavaScript新手,只有基本的Python技能。謝謝!用不同組的x軸數據繪製谷歌折線圖

<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); 
 
     }

回答

0

替換由「空」和谷歌線圖表「無」串將顯示圖表正確。

在Python中,您可以通過打印PHP代碼時,通過更換空的無: replaced_rowstring = rowstring.replace( 「無」, 「空」)

親切的問候, 尼科

+0

大聲笑,謝謝尼科。我沒有想過None沒有被接受爲null,並且已經添加了一些代碼,正如你所建議的那樣,所有代碼都完美無缺。謝謝 – 359 2015-03-17 20:06:48