Vue3使用ECharts的自定义堆叠条形图(纵向)

先上效果图

 

展示区域 

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

 配置信息

每个种类的data数组是number数组,这里我使用的变量是从接口返回的数据,为了方便理解,年度考核的绿色种类,里面的data数组我写死了,可以对照图上顺序自行理解

dataZoom:的配置是能够动态的显示条数据

 var chartDom = document.getElementById('main')
    var myChart = echarts.init(chartDom)
    var option
    option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      legend: {},
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: {
        type: 'value',
        min: 0
      },
      yAxis: {
        type: 'category',
        data: orgNameArr.value
      },
      series: [
        {
          name: '基本资料',
          type: 'bar',
          stack: 'total',
          label: {
            show: true
          },
          emphasis: {
            focus: 'series'
          },
          itemStyle: {
            color: '#165DFF'
          },
          data: basicArr.value
        },
        {
          name: '供热质量',
          type: 'bar',
          stack: 'total',
          label: {
            show: true
          },
          emphasis: {
            focus: 'series'
          },
          itemStyle: {
            color: '#14C9C9'
          },
          data: heatArr.value
        },
        {
          name: '设备维护',
          type: 'bar',
          stack: 'total',
          label: {
            show: true
          },
          emphasis: {
            focus: 'series'
          },
          itemStyle: {
            color: '#F7BA1E'
          },
          data: enqiudArr.value
        },
        {
          name: '应急响应',
          type: 'bar',
          stack: 'total',
          label: {
            show: true
          },
          emphasis: {
            focus: 'series'
          },
          itemStyle: {
            color: '#2817EA'
          },
          data: emrresArr.value
        },
        {
          name: '年终考核',
          type: 'bar',
          stack: 'total',
          label: {
            show: true
          },
          itemStyle: {
            color: '#5DC47F'
          },
          emphasis: {
            focus: 'series'
          },
          // data: yearArr.value
          data: [10, 20, 30, 40]
        }
      ],
      dataZoom: [
        {
          type: 'slider',
          show: true,
          yAxisIndex: [0]
        },
        {
          type: 'inside',
          yAxisIndex: [0]
        }
      ]
    }
    option && myChart.setOption(option)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值