flot.js ajax,javascript - Flot Chart From Database - Stack Overflow

I'm trying to implement a FLOT chart from database, but I'm having a few problems...

I have a database with 2 rows: Data, Pcr

My files .php:

Datas.php

$dates=array();

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

$date=$row['Date'];

$pcrs=(float)$row['Pcr'];

$dates[] = array(strtotime($date)*1000,$pcrs);

}

echo json_encode($dates);

I get the array:

[[1434240000000,7.2],[1434758400000,4.83],[1443052800000,4.85],[1445817600000,4.56],[1446163200000,4.5]]

I would like to get a chart from this array, but I don't know how to do that...

I have this file, and I know that it is incomplete...

Flot.php

$(document).ready(function(){

$.ajax({

type:’post’,

dataType:'json',

url:'datas.php',

success:function(data){

var datasets = {

"pcr": {

label: "Pcr",

data: dates

}

};

Could someone help me to do this chart?

Thank you very much

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值