在使用echarts制作饼形图,获取数据插入到每个value中时,如何才能插入进去

2024-12-29 00:00:11
推荐回答(1个)
回答1:

后台代码:
Map map = new HashMap();
map.put("一月标", 12);
map.put("六月标", 4);
map.put("三月标", 9);

List nameList=new ArrayList();
List valueList=new ArrayList();

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}
}
]