I need to add point from data which I get from mysql database. At this time, i get data by json but i don't know why in the output array, data have double quote(" ") like this:
["{name:'Chip 3',data:[[moment('2015-05-14 13:26:21','HH:mm:ss').valueOf(),29],[moment('2015-05-14 13
:26:51','HH:mm:ss').valueOf(),29],[moment('2015-05-14 13:27:21','HH:mm:ss').valueOf(),29],[moment('2015-05-14
13:27:51','HH:mm:ss').valueOf(),29],[moment('2015-05-14 13:28:21','HH:mm:ss').valueOf(),29],[moment('2015-05-14
14:42:54','HH:mm:ss').valueOf(),32],]}"]
So Highcharts can not access to the data and show data on chart. Now I need to remove double quote from array or do something else to make Highcharts can regconize data.
This is my code in data.php file which i use to get and update series data.
<?php
header("Content-type: text/json");
include_once 'include/connection.php';
$db = new DB_Class();
$query = "select distinct idchip from datatable ";
$result = mysql_query( $query );
$rows = array();
$count = 0;
$getall = array();
while( $row = mysql_fetch_array( $result ) ) {
$table = array();
$query2 = "select datetime,temperature from datatable where idchip=".$row['idchip'].' group by datetime ';
$dataresult = mysql_query($query2);
while($datarow = mysql_fetch_array($dataresult))
{
$data = '';
$datatimes .= $datarow['0'].',';
$data .= "[moment('".$datarow['0']."','HH:mm:ss').valueOf(),".(integer)$datarow['1']."],";
$stringdata .= $data;
}
$newstring = $stringdata ;
$stringdata = '';
$stringtime = '';
$namedata = "{name:'Chip ".$row["idchip"]."',data:[$newstring]}";
$getall[] = $namedata;
}
echo json_encode($getall);
?>
This is code which i use to get ajax return data.
function getData() {
jQuery.ajax({
url: 'data.php',
type: 'GET',
dataType: 'json',
mimeType: 'multipart/form-data',
contentType: false,
cache: false,
processData: false,
success: function( data, jqXHR ) {
if( data == "null" ) {
} else {
$.getJSON("data.php", function(json) {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'spline',
events: {
// load: requestData
}
},
series: json
});
});
}
},
error: function( textStatus ) {
console.log(" error. damm. ");
//console.log(error);
}
});
}