echarts实例(持续更新)

initChart() {
      this.chart = this.$echarts.init(document.querySelector('.gender'));
      const myData = ['50以上', '40-49', '30-39', '20-29', '20以下'];
      const femaleValue = [1341, 24211, 46060, 41765, 61251];
      const maleValue = [4723, 45523, 80739, 65923, 91583];
      const option = {
        legend: {
          data: ['男', '女'],
          textStyle: {
            color: '#000',
            fontSize: 14
          },
          selectedMode: false,
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: [{
          show: false,
          left: '4%',
          top: 40,
          bottom: 10,
          containLabel: true,
          width: '49%'
        }, {
          show: false,
          left: '50.5%',
          top: 40,
          bottom: 10,
          width: '0%'
        }, {
          show: false,
          right: '5%',
          top: 40,
          bottom: 10,
          containLabel: true,
          width: '42%'
        }],
        xAxis: [{
          gridIndex: 0,
          splitNumber: 2,
          type: 'value',
          inverse: true,
          axisLine: {
            show: true,
            textStyle: {
              color: '#000'
            },
          },
          axisTick: {
            show: false,
          },
          position: 'bottom',
          axisLabel: {
            show: true,
            textStyle: {
              color: '#000',
              fontSize: 12
            }
          },
          splitLine: {
            show: false,
            lineStyle: {
              color: '#000',
              width: 1,
              type: 'solid'
            }
          }
        }, {
          gridIndex: 1,
          show: false,
        }, {
          gridIndex: 2,
          splitNumber: 2,
          type: 'value',
          axisLine: {
            show: true,
            textStyle: {
              color: '#000'
            },
          },
          axisTick: {
            show: false,
          },
          position: 'bottom',
          axisLabel: {
            show: true,
            textStyle: {
              color: '#000',
              fontSize: 12,
            },
          },
          splitLine: {
            show: false,
            lineStyle: {
              color: '#57617f',
              width: 1,
              type: 'solid',
            },
          },
        },],
        yAxis: [{
          type: 'category',
          inverse: true,
          position: 'left',
          axisLine: {
            show: true,
          },
          axisTick: {
            show: true
          },
          axisLabel: {
            show: true,
            color: '#000'
          },
          data: myData,

        }, {
          gridIndex: 1,
          type: 'category',
          inverse: true,
          position: 'left',
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLabel: {
            show: false,
            align: 'left'
          },
          data: myData,
        }, {
          gridIndex: 2,
          type: 'category',
          inverse: true,
          position: 'left',
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLabel: {
            show: false,
          },
          data: myData,
        },],
        series: [{
          name: '男',
          type: 'bar',
          barGap: 20,
          barWidth: 20,
          barCateGoryGap: 20,
          stack: '入',
          xAxisIndex: 0,
          yAxisIndex: 0,
          itemStyle: {
            normal: {
              color: 'rgba(42,141,239,0.65)',
              barBorderRadius: [30, 0, 0, 30]
            }
          },
          data: maleValue,
        }, {
          name: '女',
          type: 'bar',
          barGap: 20,
          barWidth: 20,
          barCateGoryGap: 20,
          stack: '出',
          itemStyle: {
            normal: {
              color: 'rgb(253,183,183)',
              barBorderRadius: [0, 30, 30, 0]
            }
          },
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: femaleValue,
        }]
      };
      this.chart.setOption(option);
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值