mardi 18 novembre 2014

how to draw multiple line into flot chart?


Vote count:

0




i'm trying to draw multiple line into flot chart, my chart data is dynamic from database mysql, and the chart get data every 2 seconds, i'm successfull draw 1 line chart, but i'm trying to get multiple line in chart, how to draw multiple chart in flot chart with json ?


chart.php



$(document).ready(function () {

setInterval(function(){
$.ajax({
dataType:'json', /*to avoid calling JSON.parse(data) in your callback function*/
url: 'chart-data.php',
success: function (data) {
console.log(data);//as mentioned in comments
//1.either call plot again
/*calling plot as seen in your code - start*/
var d1 = data;/* JSON.parse(data) */
$.plot($("#placeholder"), [{
label: "Number of items",
data: d1,
color: "#FB0026"
}], {
xaxis: {
show: true,
axisLabel: "1hr",
ticks: 6
},
yaxis: {
show: true,
axisLabel: "",
ticks: 12,
min: 0,
tickDecimals: 0,
position: 1
}
});

plot.setData(newData);
plot.setupGrid(); //only necessary if your new data will change the axes or grid
plot.draw();
*/
}//ajax props
});//ajax
},2000);//interval
});//document ready


chart-data.php



$query = "SELECT MONTH,days FROM high";
$result = mysql_query($query);


while($row = mysql_fetch_assoc($result))
{
$int = $row['days'];
$join = intval($int);
$int2 = $row['MONTH'];
$join2 = intval($int2);
$dataset1[] = array($join2,$join);

}

$final = json_encode($dataset1);
echo $final;


output chart enter image description here


i'm trying draw 2 line like this enter image description here



asked 42 secs ago







how to draw multiple line into flot chart?

Aucun commentaire:

Enregistrer un commentaire