Echarts 折柱混合图

数据开发平台使用echarts做数据可视化

<div id="main" style="width: 100%;height:400px;"></div>


 var dx = new Array();
 var dy_mobile_investment =  new Array();
 var dy_investamount =  new Array();
 var dy_mobile_percent =  new Array();
        

<#list mobileBondSaledList as file>

dx.push("${file.mounth}");

dy_mobile_investment.push("${file.mobile_investment}");

dy_investamount.push("${file.investamount}");

dy_mobile_percent.push("${file.mobile_percent}");

</#list>


// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('tryecharts'));

// 指定图表的配置项和数据
        var option = {
            title: {
                text: '移动端月销售占比'
            },
            tooltip: {
       trigger: 'axis',
   },
            toolbox: {
                orient:'vertical',
                iconStyle:{
                  normal:{
                   textPosition:'left',
                   textAlign:'left',
                  },
                   emphasis:{
                   textPosition:'left',
                   textAlign:'right',
                  }
                },
       feature: {
           saveAsImage: {},
           magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
           dataZoom:{},
           restore:{},
       }
   },
            legend: {
                data:['移动端月销售额(单位:百万)','月总销售额(单位:百万)','移动端月销售占比(%)','移动端月销售占比(折线)']
            },
            xAxis: {
                data: dx,
                name:'月份',
                nameLocation:'middle',
                nameGap: 25,
                nameTextStyle: {
fontWeight: 'bold',
fontSize: 13,
},
            },
            yAxis:[
                {
              type: 'value',
      name: '金额(百万)',
      nameTextStyle: {
fontWeight: 'bold',
fontSize: 13,
},
           },
           {
              type: 'value',
      name: '占比(%)',
      nameTextStyle: {
fontWeight: 'bold',
fontSize: 13,
},
      splitLine:{
        show:false,
      }
           },
           ],
            series: [
           {
               name: '移动端月销售额(单位:百万)',
               type: 'bar',
               itemStyle:{
               normal:{
                   barBorderRadius: 3,
                   color:'rgba(11,205,221,0.8)'
               },
               emphasis:{
                   barBorderRadius: 3,
                   color:'rgba(11,205,221,1)'
               }
           },
               data: []
           },
            {
               name: '月总销售额(单位:百万)',
               type: 'bar',
               itemStyle:{
               normal:{
                   barBorderRadius: 3,
                   color:'rgba(191,115,187,0.8)'
               },
               emphasis:{
                   barBorderRadius: 3,
                   color:'rgba(191,115,187,1)'
               }
           },
               data: []
           },
            {
               name: '移动端月销售占比(%)',
               type: 'bar',
               itemStyle:{
               normal:{
                   barBorderRadius: 3,
                   color:'rgba(255,104,180,0.8)'
               },
               emphasis:{
                   barBorderRadius: 3,
                   color:'rgba(255,104,180,1)'
               }
           },
               yAxisIndex: 1,
               data: []
           },
           {
               name: '移动端月销售占比(折线)',
               type: 'line',
               itemStyle:{
               normal:{
                   barBorderRadius: 3,
                   color:'rgba(255,104,180,0.8)'
               },
               emphasis:{
                   barBorderRadius: 3,
                   color:'rgba(255,104,180,1)'
               }
           },
               yAxisIndex: 1,
               data: []
           }
            
            ]
        };


        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        function fetchData(cb) {
   setTimeout(function () {
       cb({
           categories: dx,
           dy_mobile_investment: dy_mobile_investment,
           dy_investamount:dy_investamount,
           dy_mobile_percent:dy_mobile_percent,
           dy_mobile_percent_line:dy_mobile_percent
       });
   }, 1000);
}
        // 异步加载数据
fetchData(function (data) {
   myChart.setOption({
       xAxis: {
           data: data.categories
       },
       series: [
       {
           // 根据名字对应到相应的系列
           name: '移动端月销售额(单位:百万)',
           data: data.dy_mobile_investment,
           label: {
               normal: {
                   show: false,
               }
           },
       },
       {
           // 根据名字对应到相应的系列
           name: '月总销售额(单位:百万)',
           data: data.dy_investamount,
           label: {
               normal: {
                   show: false,
               }
           },
       },
       {
           // 根据名字对应到相应的系列
           name: '移动端月销售占比(%)',
           data: data.dy_mobile_percent,
           label: {
               normal: {
                   show: false,
               }
           },
       },
       {
           // 根据名字对应到相应的系列
           name: '移动端月销售占比(折线)',
           data: data.dy_mobile_percent_line,
       }
       ]
   });
});

   

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值