我的后台数据能取到,就是传不到插件里,总是把空,求大神给个相关实际
http://www.52codes.net/article/730.html
http://blog.csdn.net/zhrubin/article/details/46123771
首先,检查的你的Controller层数据是否响应给了前台,浏览器的开发者模式下看看响应结果是什么。
其次,检查的你的js,你是否正确应用了响应结果。通常来说echarts主要就是数据相关的属性需要传递参数:
参考:
//此处用ajax发送请求给后台,获取数据data,然后调用echart绘图方法,把数据传入
ajaxFun(){
success (result){
fillVisitTrendChart('user_group_line_charts','业务用户'+ip+'的流量趋势',result.data);
}
function fillVisitTrendChart(id,title,sumupDatas){
var chartData = formatBarData(sumupDatas,false);
if(!isFirstPage){
console.log("not firstPage now.");
return;
}
//真正的绘图:传入绘图数据
var homeGroupOption = $.extend(true, {}, {
title: {
text: title,
textStyle: {
fontSize: 14,
fontWeight: 'bolder',
color: '#7a94a7' // 主标题文字颜色
}
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
orient: 'horizontal',
itemWidth: 8, // 图例图形宽度
itemHeight: 5,
textStyle: {color: '#ffffff'},
data: chartData.lengend,
y: 25
},
grid: {
top: '28%',
left: '3%',
right: '4%',
bottom: '10%',
containLabel: true
},
xAxis: [
{
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
},
type: 'category',
data: chartData.time
}
],
yAxis: [
{
name: '流量总数(条)',
nameTextStyle:{
color:'#ffffff'
},
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
},
type: 'value'
}
],
series:chartData.series//数据来源
});
var homeGroupOption_Charts = echarts.init(document.getElementById(id));
homeGroupOption_Charts.setOption(homeGroupOption);
}
ajax使用错了吧,或者是你ECharts的js引用和jQuery的引用问题,过过没问题是不是你引用的顺序错了,ajax+json前台再赋值给ECharts
我最近也在做类似的项目,Ajax可以解决这个问题