Echarts 双侧 双表头 柱状图 折线图

Echarts 双侧 双表头 柱状图 折线图 带箭头 区分颜色

成品图片(如需折线图自行更改)

在这里插入图片描述

废话不多say 上代码

👍记得点赞哦 😄

👇大佬请看👇

earchs() {
      var myChart = echarts.init(document.getElementById('asd'));
      var s = ['▲', '▼', ]
      var data = {
        title: ['表面', '组装', '机加设备', '表面设备', '组装设备',
          '技术制工', '生产管制', 'FAE', '周边'],

        currentNum: [85, 48, 83, 61, 42, 79, 41, 44, 35, 14, 17,],

        dept: ['部门1', '部门2', '部门3', '部门4', '部门5', '部门6', '部门7', '部门8', '部门9',],

        attRate: [40, 91, 9, 95, 12, 96, 92, 95, 94,],
      };
      function getTableLine(num) {
        var list = [];
        var bottom = 0;
        var height = 30;
        for (var i = 0; i < num; i++) {
          list.push({
            type: 'line',
            bottom: bottom - i * height,
            left: 0,
            style: {
              fill: '#333',
              stroke: 'transparent',
            },
            shape: {
              x1: 0,
              y1: 0,
              x2: 1087,
              y2: 0
            }

          });
        }
        return list;
      }
      var lineList = getTableLine(5);


      let option = {
        title: [{
          text: '部门名称',
          left: '1%',
          top: '4%',
          textStyle: {
            fontSize: 16,
            color: '#c0c0c0',
          }
        },
        {
          text: '占比',
          left: '8.5%',
          top: '4%',
          textStyle: {
            fontSize: 16,
            color: '#c0c0c0',
          }
        }, {
          text: '次数',
          right: 200,
          top: '4%',
          textStyle: {
            fontSize: 16,
            color: '#c0c0c0',
          }
        }, {
          text: '次数',
          right: 200,
          top: '4%',
          textStyle: {
            fontSize: 16,
            color: '#c0c0c0',
          }
        }, {
          text: '环比',
          right: 150,
          top: '4%',
          textStyle: {
            fontSize: 16,
            color: '#c0c0c0',
          }
        }, {
          text: '环比',
          right: 70,
          top: '4%',
          textStyle: {
            fontSize: 16,
            color: '#c0c0c0',
          }
        }],
        legend: {
          show: false,
        },
        grid: {
          left: '12%',
          right: '20%'
        },
        yAxis: [{
          type: 'category',
          boundaryGap: true,
          data: data.title,
          axisLine: {//y轴线的颜色以及宽度
                show: false,
                lineStyle: {
                    color: "rgba(219,225,255,1)",
                    width: 1,
                    type: "solid"
                },
            },
          axisLine: {
            lineStyle: {
              color: '#c0c0c0', // 更改坐标轴颜色
            }
          },
          axisTick: {
            length: 160, // 竖线的长度
          },
          axisLabel: {
            interval: 0,
            textStyle: {
              color: '#333',
            },
            formatter: function (value, index) {
              var indexNum = 0;
              for (var i = 0; i < data.title.length; i++) {
                if (value == data.title[i]) {
                  indexNum = i;
                }
              }
              return '{table|' + data.dept[index] + '}' + '{table|' + '  ' + '}' + '{div|' + data.currentNum[indexNum] + '%}';
            },
            rich: {
              table: {
                width: 30,
                lineHeight: 14,
                align: 'left',
                fontSize: 14, // table里文字字体大小
              },
              div:{
                width: 50,
                lineHeight: 14,
                align: 'right',
                fontSize: 14, // table里文字字体大小
              }
            }
          }
        }, {
          type: 'category',
          boundaryGap: true,
          data: data.title,
          axisLine: {
            lineStyle: {
              color: '#d5d5d5', // 更改坐标轴颜色
            }
          },
          axisTick: {
            length: 180, // 竖线的长度
          },
          splitLine:{
            show:true,
            color:'d5d5d5',
          },
          axisLabel: {
            interval: 0,

           
            formatter: function (value, index) {
              var indexNum = 0;
              for (var i = 0; i < data.title.length; i++) {
                if (value == data.title[i]) {
                  indexNum = i;
                }
              }
               var a = '{table|' + data.currentNum[indexNum] + '}'
               var b ='', c =''
               if(data.attRate[indexNum]<95){
                b = '{div|' + data.attRate[indexNum] + '%'+s[0]+'}' 
               }else{
                b = '{span|' + data.attRate[indexNum] + '%'+s[1]+'}' 
               }
               if(data.attRate[indexNum]>92){
                c = '{div|' + data.attRate[indexNum] + '%'+s[0]+'}' 
               }else{
                c = '{span|' + data.attRate[indexNum] + '%'+s[1]+'}' 
               }

              return   a+b+c;
            },
         
            rich: {
              table: {
                width: 50,
                lineHeight: 14,
                align: 'left',
                fontSize: 14, // table里文字字体大小
                color:'#000000'
              },
              div:{
                width: 80,
                lineHeight: 14,
                align: 'left',
                fontSize: 14, // table里文字字体大
                color:'blue'
              },
              span:{
                width: 80,
                lineHeight: 14,
                align: 'left',
                fontSize: 14, // table里文字字体大
                color:'red'
              },
             
            }
          }
        }],
        xAxis: { show: false },
        series: [
          {
            show:false,
            name: '实际',
            type: 'bar',
            barWidth: 36,
            itemStyle: {
              normal: {
                color: '#1ec6a3'
              },
            },
            label: {
              show: false,
              position: 'top',
              formatter: '{c} %',
              textStyle: {  //数值样式
                color: '#1ec6a3',
                fontSize: 14,
              }
            },
            yAxisIndex: 0,
            data: [80,70,10,15,20,60,35,99,60]
          }],
        graphic: lineList
      };


      // 绘制图表
      myChart.setOption(option);

    },

数字以及图标颜色 或使用其他svg、img等根据文档调一下吧

都看👓完了,就👍1️⃣👇吧

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值