Rank: Newbie
Groups: Registered
Joined: 3/31/2012(UTC) Posts: 4
Thanks: 0 times Was thanked: 0 time(s) in 0 post(s)
|
Hi, thanks for your very quick answer! In the database there is e.g. some temperature data which is measured e.g. every 2 seconds. Now I want to plot something like the last 1000 values in a line-chart. The servercode is: Code: $sql="SELECT (5.625*value-52.5) as value, unix_timestamp(timestamp) as timestamp FROM rohWerte order by timestamp desc limit 0,1000"; $result=mysql_query($sql) or die($sql."\n".mysql_error()); $i=0; while($line=mysql_fetch_array($result,MYSQL_ASSOC)){ $output[$i]['timestamp']=$line['timestamp']*1000; $output[$i]['value']=$line['value']; $i++; } print json_encode($output);
On client side, I try to do something like this: Code: $.getJSON("server.php",{func: "getOnlineData"},function(j){ var background = { type: 'linearGradient', x0: 0, y0: 0, x1: 0, y1: 1, colorStops: [{ offset: 0, color: '#d2e6c9' }, { offset: 1, color: 'white'}] }; var data = new Array(); for(i=0;i<j.length;i++){ data[i]=new Array( new Date(j[i].timestamp), parseInt(j[i].value) ) }
$('#jqChart').jqChart({ title: 'jqChart - Teststation', legend: { title: 'Legend' }, border: { strokeStyle: '#6ba851' }, background: background, axes: [{ type: 'linear', location: 'left' }, { type: 'dateTime', location: 'bottom', labels: { stringFormat: 'dd-mm-yyyy' } } ], series: [ { type: 'line', lineWidth: 1, title: 'Random Data', markers: { size: 0 }, data: data } ] }); }); setTimeout("testchart()",10000);
I hope this is the Information you asked for? Best Regards, C. Groschopf
|