echarts-柱状图–vue

有时候,不是因为你没有能力,也不是因为你缺少勇气,只是因为你付出的努力还太少,所以,成功便不会走向你。而你所需要做的,就是坚定你的梦想,你的目标,你的未来,然后以不达目的誓不罢休的那股劲,去付出你的努力,成功就会慢慢向你靠近。

导读:本篇文章讲解 echarts-柱状图–vue,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

柱状图效果: 

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;
      }
    }

 

 

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之家整理,本文链接:https://www.bmabk.com/index.php/post/149799.html

(0)
飞熊的头像飞熊bm

相关推荐

发表回复

登录后才能评论
极客之家——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!