[英]jQuery Flot with PHP
我今天正在處理Flot,當我嘗試從PHP(使用json_encode()
)獲取數據時,我無法使其正常運行。
我可以顯示標簽,但沒有創建圖表。
$newData = array();
$newData[0] = array();
$newData[1] = array();
$newData[2] = array();
$newData[0]['label'] = 'Slice 1';
$newData[1]['label'] = 'Slice 2';
$newData[2]['label'] = 'Slice 3';
$newData[0]['color'] = '#122b45';
$newData[1]['color'] = '#064792';
$newData[2]['color'] = '#9e253b';
$newData[0]['data'] = array();
$newData[0]['data'][0] = 1;
$newData[0]['data'][1] = 1000;
$newData[1]['data'] = array();
$newData[1]['data'][0] = 1;
$newData[1]['data'][1] = 500;
$newData[2]['data'] = array();
$newData[2]['data'][0] = 1;
$newData[2]['data'][1] = 100;
echo json_encode($newData);
$.ajax({
url: "get-stats.php",
type: "POST",
async: false,
dataType : 'JSON',
data: {section: section, endDate: endDate, startDate: startDate},
success: function(data){
$.plot($("#flot"), data,{
series: {
pie: {
show: true
},
grid: {
hoverable: true,
clickable: true
}
}
}
});
誰能告訴我我在哪里做錯了? 標簽和顏色都可以,但似乎無法獲取數據。
謝謝您的時間和事先的關心。
我找到了問題和解決方案。 我必須跟蹤數據。
$newData[0]['data'] = array(array(1,100));
這節省了我的時間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.