jqplot json_编码数据不呈现线图
我从codeigniter中的控制器返回这2个字符串,使用json_encode for jqplot line Graph 我在这里获取数据jqplot json_编码数据不呈现线图,json,codeigniter,jqplot,Json,Codeigniter,Jqplot,我从codeigniter中的控制器返回这2个字符串,使用json_encode for jqplot line Graph 我在这里获取数据 $(document).ready(function(){ $(".stats").click(function(){ var site_id = $(this).attr("id"); $.ajax({ url: site_url+"statistics/fetch_stats
$(document).ready(function(){
$(".stats").click(function(){
var site_id = $(this).attr("id");
$.ajax({
url: site_url+"statistics/fetch_stats_data/"+site_id,
async: false,
type: "POST",
data: "type=article",
dataType: "json",
success: function(data) {
stat_events_plot_graph(data['activity_events'], data['activity_tricks']);
}
})
});
});
从上面的ajax以php字符串形式返回的绘图数据结构
[“10/21/2014 05:50”,1]]
plot ticks结构作为php字符串从上面的ajax返回
[[1,“今天”]]
当我将此数据发送到绘图时,图形不会呈现
function stat_events_plot_graph(activity_events_live, activity_tricks_live) {
var plot2 = $.jqplot('events', [activity_events_live], {
title: 'Events',
seriesDefaults: {
rendererOptions: {
smooth: false,
animation: {
show: true
}
}
},
legend: { show: false },
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickOptions: { formatString: '%b %#d, %#I %p',angle: -90 }
},
yaxis: {
ticks : activity_tricks_live,
}
},
series: [{ lineWidth: 4,
markerOptions: { style: 'square' }
}],
series: [
{ label: 'Toronto' },
{ label: 'New York' }
],
});
}
如何转换这两个字符串以使用折线图?如果返回的数据是这种形式的
[[“10/21/2014 05:50”,1]]
,然后去掉第一个和最后一个结束括号,并以这种方式获取它[“10/21/2014 05:50”,1]
,因为在定义此时无论如何都要添加一个括号:[activity\u events\u live]
希望对您有所帮助