Echarts关于饼图data中数据如何动态填充?
展开全部
后台代码:
Map<String , Integer> map = new HashMap<String , Integer>();
map.put("一月标", 12);
map.put("六月标", 4);
map.put("三月标", 9);
List<String> nameList=new ArrayList<String>();
List<Integer> valueList=new ArrayList<Integer>();
Iterator it = map.keySet().iterator();
while(it.hasNext()){
String key=(String) it.next();
nameList.add(key);
valueList.add(map.get(key));
}
request.setAttribute("nameList", JSONArray.fromObject(nameList).toString());
request.setAttribute("valueList",JSONArray.fromObject(valueList).toString());
}
前台:
data:[
{
name:${nameList},
value:${valueList}
}
]
Map<String , Integer> map = new HashMap<String , Integer>();
map.put("一月标", 12);
map.put("六月标", 4);
map.put("三月标", 9);
List<String> nameList=new ArrayList<String>();
List<Integer> valueList=new ArrayList<Integer>();
Iterator it = map.keySet().iterator();
while(it.hasNext()){
String key=(String) it.next();
nameList.add(key);
valueList.add(map.get(key));
}
request.setAttribute("nameList", JSONArray.fromObject(nameList).toString());
request.setAttribute("valueList",JSONArray.fromObject(valueList).toString());
}
前台:
data:[
{
name:${nameList},
value:${valueList}
}
]
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询