Note that there are some explanatory texts on larger screens.

plurals
  1. POfrom Google Visualization Datatable to Highcharts data format
    primarykey
    data
    text
    <p>I have a program that get sensors data from a Como database and put in a html page a graph. Now the graph is implemented with Google Graph API, but i have to switch to Highcharts.</p> <p>I have a function that converts json data in Google format</p> <pre><code> function json2gdt(data) { // Build a google.DataTable var gdt = new google.visualization.DataTable(); gdt.addColumn('datetime', 'Time'); gdt.addColumn('number', 'value'); gdt.addRows(data.length*2); var prev = data[0][1]; for (var i=0; i&lt;data.length; i++) { ts = data[i][0] * 1000 gdt.setValue(i*2, 0, new Date(ts)); gdt.setValue(i*2, 1, prev); gdt.setValue(i*2+1, 0, new Date(ts)); gdt.setValue(i*2+1, 1, data[i][1]); prev = data[i][1]; } return gdt; } </code></pre> <p>Then I have a function that visualize in the html page the graph:</p> <pre><code>function visualize(json_response) { var err = json_response['error']; if (err) { $("#chart_div").html("&lt;div class='alert'&gt;" + err + "&lt;/div&gt;"); return; } var data = json_response['data']; if (data.length == 0) { $("#chart_div").html("&lt;div class='info'&gt;No data received from this sensor!&lt;/div&gt;"); return; } // Convert Data to a step function //var step_data = json2step(data); var gdt = json2gdt(data); var start; if (data &amp;&amp; data.length != 0) // TODO: fix this to actually compute the half of the time period start = new Date(data[Math.floor(data.length / 2)][0] * 1000); // draw our data in the widget if (chart == null) { chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div')); } // TODO: compute tickness as a function of the time interval chart.draw(gdt, {displayAnnotations: false, displayZoomButtons: true, thickness: 2, fill: 10, {% if net.ntype == "ztc" and sens.type == 2 %} colors: ['#F00000'], scaleType: 'fixed', min: 0, max: 1, {% else %} scaleType: 'maximized', {% end %} allowRedraw: true, displayExactValues: true, zoomStartTime: start}); </code></pre> <p>}</p> <p>Finally this is a bit of json data file..</p> <pre><code>#master: sender-64bit-addr receiver-timestamp *;OPCODE;sender-timestamp;sender-seq-num;payload-length;payload# #master: input file (re)opened at 4f708e9d #master: child [pid=6884] started at 4f708eb1 0000000000000000 4f708eb2 *ZTCR;00000004;00000002;16;9755080000010000000000# 0000000000000000 4f708eb2 *ZTCR;00000004;00000003;10;9634050010000003# 0000000000000000 4f708eb2 *ZTCR;00000005;00000004;0A;97410200EA# 0000000000000000 4f708eb3 *ZTCR;00000005;00000005;10;9634050010000003# </code></pre> <p>Can anyone help me? i have to change the data format for highcharts or it's the same for google graph?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload