简体   繁体   中英

Graphing google line chart with different set of x-axis data

Hi I have the following data from an sqlite database to plot using a google line chart. To be clear, there are 2 sets of data, I am trying for 2 lines plotted. The 'none' values appear to be messing up this hope, any thoughts? I am new to javascript, only basic python skills. Thank you!

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

Replace the "None" string by "null" and google line charts will display the chart correct.

In python you can replace the None by null when printing the php code via: replaced_rowstring=rowstring.replace("None","null")

Kind regards, Nico

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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