Map<String,Object> map = new HashMap<String, Object>(); //图例的千人、双百 HashMap<String, String> para3 = new HashMap<String, String>(); para3.put("parentDictCode", DatabaseConstants.PZT_RCLX); List<CmDict> cmDictList = cmDictService.getDictAllByTypeName(para3); List<String> legend = new ArrayList<String>(); for(CmDict cmDict:cmDictList){ legend.add(cmDict.getDictName()); } //y轴的数据 List<String> yEntScale = new ArrayList<String>(); List<String> yEntScaleCd = new ArrayList<String>(); List<HgPztParkInfo> parkInfoList = hgPztParkInfoService.getValidParkInfoList(); for(HgPztParkInfo pztParkInfo:parkInfoList){ yEntScale.add(pztParkInfo.getParkName()); } //查人才表里的人数 Map<String,Object> para = new HashMap<String, Object>(); List<TalentInfoVo> talentInduSeriesVoList = hgPztTalentInfoService.getTalentParkList(para); Map<String,List<TalentInfoVo>> talentMap = new HashMap<String,List<TalentInfoVo>>(); List<InduDevelopVo> seriesVoSBList = new ArrayList<InduDevelopVo>(); for(TalentInfoVo vo : talentInduSeriesVoList){ if(talentMap.containsKey(vo.getDictName())){//去重复 List<TalentInfoVo> tempList = talentMap.get(vo.getDictName()); tempList.add(vo); }else{ List<TalentInfoVo> tempList = new ArrayList<TalentInfoVo>(); tempList.add(vo); talentMap.put(vo.getDictName(),tempList); } } for (Map.Entry<String, List<TalentInfoVo>> entry : talentMap.entrySet()) { Map<String, String> map1 = new HashMap<String, String>(); for (TalentInfoVo vo : entry.getValue()) { map1.put(vo.getParkName(), vo.getCount().toString());//园区对应数据 } List<String> valueList = new ArrayList<String>(); for (String vo : yEntScale) {//人数的值 if (map1.containsKey(vo)) { valueList.add(map1.get(vo)); } else { valueList.add("0"); } } seriesVoSBList.add(new InduDevelopVo(entry.getKey(), valueList));//软件园对应值 } map.put("yEntScale", yEntScale);//软件园名字 map.put("talentParkLegendJson", legend); map.put("talentParkSeriesSBJson", seriesVoSBList);
$.getJSON('/pzt/personView/talentPark.html', function (data) { if (data.success4) { talentParkChar.showLoading({text: '正在努力的读取数据中...'}); talentParkChar.setOption({ legend: {data: data.talentParkLegendJson}, yAxis: {data: data.yEntScale}, series:convertBarDate(data.talentParkSeriesSBJson) }); talentParkChar.hideLoading(); } else { alert('提示', data.msg); } });
function convertBarDate(lineDataList) { var lineList = []; for (var i = 0; i < lineDataList.length; i++) { var item = lineDataList[i]; var value = {}; value.name = item.name; value.type = 'bar'; //value.xAxisIndex = 1; value.label = {normal: {show: true, position: 'top'}}, value.barWidth = '30'; value.stack = 'group1', value.data = item.value; lineList.push(value); } return lineList; }