笔记,前后台数据交互(echart图表)

 前端:

$(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;
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值