echarts横向柱状图详细解析

 <div id="main"></div>

js部分


<script>
移入echarts
let echarts = require('echarts/lib/echarts')
export default {
  mounted () {
     this.mein()
  },

  // 绘制柱状图
  methods: {
    mein () {
    var myChart = this.$echarts.init(document.getElementById('main'))
   var option = {
        // 设置标题内容样式
        title: {
          text: '2019年全省各行规上企业数(家)',
          标题位置
          x: 'center',
           标题字体样式
          textStyle: {
            fontSize: 12,
            textAlign: 'center',
            color: '#668ff2'
          }
        },
        // 设置柱状图子在页面的位置
        grid: {
          left: '5%',
          right: '10%',
          bottom: '5%',
          top: '10%',
          containLabel: true
        },
        xAxis: {
        // 影藏x轴
          show: false
        },
​        yAxis: [{
​          type: 'category',
​          show: true,
​          boundaryGap: true,
​          axisTick: {// 横轴方向刻度
​            length: 0
​          },
​          splitLine: { // 网格线
​            show: false
​          },
​          axisLine: {// 竖轴方向刻度
​            show: false
​          },
​          axisLabel: {
​            interval: 0,
​            fontSize: 15
​          },
​           y:轴信息
​          data: ['煤炭开采\n和洗选业', '非金属\n矿物制品业', '电力,热力\n生产力和供应业', '化学原料和\n化学制品制造业', '黑色金属\n冶炼和压延加工业']

​        }],
​        series: [
​          {
​            type: 'bar',
​            stack: '总量',
​            barGap: '50%',
​            label: {
​              normal: {
​                show: false,
​                position: 'right',
​                textStyle: {
​                  color: '#666666' // color of value
​                }
​              }
​            },
​            itemStyle: {
​              normal: {
​                // 柱状图渐变效果
​                color: new echarts.graphic.LinearGradient(0, 0, 1, 0,
​                  [
​                    { offset: 0, color: '#6D8FF7' },
​                    { offset: 1, color: '#80D1F3' }
​                  ]
​               )
​              }
​            },
​            data: [320, 302, 301, 255, 390, 330, 320, 444]
​          },
​          {
​            type: 'bar',
​            stack: '总量',
             barGap: '50%',
​            label: {
​              normal: {
​                show: false,
​                position: 'right',
​                textStyle: {
​                  color: '#666666' // color of value
​                }
​              }
​            },
​            itemStyle: {
​              normal: {
​                color: new echarts.graphic.LinearGradient(0, 0, 1, 0,
​                  [
​                    { offset: 0, color: '#f58c66' },

​                    { offset: 1, color: '#f4d295' }
​                  ]
​                )
​              }
​            },
​            data: [120, 132, 101, 134, 90, 230, 210, 555]
​          },
​          {
​            type: 'bar',
​            stack: '总量',
​            label: {
​              normal: {
​                show: false,
​                position: 'right',
​                textStyle: {
​                  color: '#666666' // color of value
​                }
​              }
​            },
​            itemStyle: {
​              normal: {
​                color: new echarts.graphic.LinearGradient(0, 0, 1, 0,
​                  [
​                    { offset: 0, color: '#c362d1' },

​                    { offset: 1, color: '#cdaad2' }
​                  ]
​                )
​              }
​            },
​            data: [220, 182, 191, 234, 90, 330, 310, 66]
​          }
​        ]
​      }
​      myChart.setOption(option)
​    }
  }
}
</script>

 data: [220, 182, 191, 234, 90, 330, 310, 66]

​ }
​ ]
​ }
​ myChart.setOption(option)
​ }
}
}

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小四是个处女座

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值