前端:
$(function() {
var myChart = echarts.init(document.getElementById('container9'));
//向后台发出请求,园区为park01
$.get('../../index/info/parkTax?parkCode=park01').done(function (data) {
myChart.setOption({
tooltip: {
trigger: 'axis'
},
grid: {
x: 46,
y: 30,
x2: 32,
y2: 40,
borderWidth: 0
},
calculable: true,
xAxis: [{
type: 'category',
boundaryGap: false,
//设置数据为查询出来的结果eval(data.year)
data: eval(data.year),
splitLine: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: '#a4a7ab'
}
}
}],
yAxis: [{
type: 'value',
splitLine: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: '#a4a7ab'
}
}
}],
series: [{
name: '增值税',
type: 'line',
stack: '万元',
data: eval(data.tax),
itemStyle: {
normal: {
color: "#e15828"
}
}
},
{
name: '个人所得税',
type: 'line',
stack: '万元',
data: eval(data.tax2),
itemStyle: {
normal: {
color: "#2e7cff"
}
}
},
{
name: '其他税收',
type: 'line',
stack: '万元',
data: eval(data.tax3),
itemStyle: {
normal: {
color: "#2e7cff"
}
}
}]
});
});
}
后台:
public Map<String, Object> parkTax(String parkCode) {
List<ComInfoEntity> comInfoEntity =parkAreaMapper.getTex(parkCode);
System.out.println(comInfoEntity.toArray());
Map<String, Object> map = new HashMap<>();
List<String>year = new ArrayList();
List<String>tax = new ArrayList<>();
List<String>tax2 = new ArrayList<>();
List<String>tax3 = new ArrayList<>();
for (ComInfoEntity y: comInfoEntity
) {
year.add(y.getYear());
tax.add(y.getSum());
tax2.add(y.getSumCorporate());
tax3.add(y.getSumOther());
}
map.put("year",year);
map.put("tax",tax);
map.put("tax2",tax2);
map.put("tax3",tax3);
return map;
}