Echarts 饼图后台封装数据

@GetMapping(value="getClassiFication")
public Object getClassiFication() {
//获取当前年份
int year;
Calendar now = Calendar.getInstance();  
        year = now.get(Calendar.YEAR);
//获取数据
         Map<String, Object> params = new HashMap<>();
        params.put("year", year);
        List<PowerAndRespDTO> list = power.getClassFica(params);
        //封装数据
Map<String, Object> obj = new HashMap<>();
List<Object> data = new ArrayList<>();
List<String> legend = new ArrayList<>();
for(PowerAndRespDTO str : list) {
Map<String,Object> map = new HashMap<>();

map.put("name", str.getEnumDesc());
map.put("value", str.getCount());
legend.add(str.getEnumDesc());
data.add(map);
}

obj.put("data", data);
obj.put("legned", legend);
return obj;
}

猜你喜欢

转载自blog.csdn.net/qq_36956154/article/details/79086236