echarts-柱状图--vue

柱状图效果: 

<div class="echart">
    <div id="chartmainbar"></div>
</div>
optionbar:{
          color: ['#0079FE'],
          tooltip: {
              trigger: 'axis',
              axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                  type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
              }
          },
          grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
          },
          xAxis: [
              {
                  type: 'category',
                  data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
                  axisTick: {
                      alignWithLabel: true
                  },
                  axisTick: {           //去掉坐标轴刻线
                    show: false
                  },
                  axisLabel:{                 //---坐标轴 标签
                    show:true,                  //---是否显示
                    inside:false,               //---是否朝内
                    rotate:0,                   //---旋转角度  
                    margin: 5,                  //---刻度标签与轴线之间的距离
                    color:'#6B6B6B',              //---默认取轴线的颜色
                  },
                  axisLine:{                  //---坐标轴 轴线
                    show:true,                  //---是否显示
                    lineStyle:{
                        color:'#F6F6F6',
                        width:1,
                        type:'solid',
                    },
                  },
              }
          ],
          yAxis: [
              {
                  type: 'value',
                  axisTick: {           //去掉坐标轴刻线
                    show: false
                  },
                  splitLine: {
                      show: true,
                      lineStyle:{
                        color: ['#F6F6F6'],
                        width: 1,
                        type: 'solid'
                    }
                },
                  axisLabel:{                 //---坐标轴 标签
                    show:true,                  //---是否显示
                    inside:false,               //---是否朝内
                    rotate:0,                   //---旋转角度  
                    margin: 5,                  //---刻度标签与轴线之间的距离
                    color:'#6B6B6B',              //---默认取轴线的颜色
                  },
                  axisLine:{                  //---坐标轴 轴线
                    show:false,                  //---是否显示
                  },

              }
          ],
          series: [
              {
                  name: '直接访问',
                  type: 'bar',
                  barWidth: '60%',
                  data: [10, 52, 200, 334, 390, 330, 220]
              }
          ]
        }

适配: 

methods:{
   drawLine: function(){
        //基于准本好的DOM,初始化echarts实例
        let chartmainbar = this.$echarts.init(document.getElementById("chartmainbar"));

        //绘制图表
        chartmainbar.setOption(this.optionbar);

    },
  },
  mounted(){
    this.drawLine()
        this.resizeEcharts = () => {
          this.$echarts.init(document.getElementById("chartmainbar")).resize();
        }
        window.addEventListener("resize", this.resizeEcharts);
  },
.echart{
      margin: 0 auto;
       #chartmainbar{
        width: 90%!important;
        height:230px!important;
        margin: 0 auto;
        margin-bottom: 10px;
      }
    }

 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

suoh's Blog

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

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

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

打赏作者

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

抵扣说明:

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

余额充值