我看到了reference。 他们说,
plot函数也可以用作jQuery可链接属性。
可以将flot图表定义为这样吗?
var pid = '';
var kid = '';
var chartasset;
$(document).ready(function() {
var optionchart = {
series: {
pie: {
show: true,
label: {
show:true,
radius: 0.8,
formatter: function (label, series) {
return '<div style="border:1px solid grey;font-size:8pt;text-align:center;padding:5px;color:white;">' + label + ' : ' + Math.round(series.percent) + '%</div>';
},
background: {
opacity: 0.8,
color: '#000'
}
}
}
}
};
chartasset = $('#chartasset').plot({
"ajax" : {
"url": "<?php echo site_url('Asset/chart_asset')?>?pid="+pid+"&kid="+kid,
"type": "POST",
"cache": false,
"dataType": "json"
}, optionchart}).data('plot');
});
我需要让url在另一个函数中动态更改,所以我可以使用:
chartasset.ajax.url("<?php echo site_url('Asset/chart_asset')?>?pid="+pid+"&kid="+kid).load();
在定义flot之后,如何使用flot chainable属性获取数据?抱歉我的英文不好
答案 0 :(得分:0)
不,你不能像那样定义Flot图表。如果您想使用AJAX,请这样做(result
必须在右侧format):
$.ajax({
"url": "<?php echo site_url('Asset/chart_asset')?>?pid="+pid+"&kid="+kid,
"type": "POST",
"cache": false,
"dataType": "json",
success: function(result) {
chartasset = $('#chartasset').plot(result, optionchart).data('plot');
}
}