echart 柱状图渐变小demo

效果图:两跟状态图公用一个提示信息,在代码块中渐变效果被注释了

  1. 定义一个可以供option 渲染的div
 <div ref="myChart_production_efficient" :style="'width:100%;height:'+templateHeight+'px;'" id="myChart_production_efficient"></div>

2.定义 option  ,将修改默认柱状图的样式、将setEchart放入method中,页面加载时执行, color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0,
                  [
                    { offset: 0, color: '#01516E' },
                    { offset: 0.5, color: '#188df0' },
                    { offset: 1, color: '#008CEB' }
                  ]
                )这一行代码如果单独执行会报错,要放在特点环境中,用于柱状图渐变效果

  SetEchart () {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("myChart_production"), 'chalk');
      // 绘制图表
      var option = {
        title: {
          text: '品牌当天生产效率',      //主标题
          textStyle: {
            color: '#01FCDE',        //颜色
            fontWeight: 'bold',    //粗细
            fontSize: 13,     //大小
            align: 'center'   //水平对齐
          },
          left: '0',
          top: 'auto',
          right: 'auto',
          bottom: '0',
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        }, grid: {
          left: '3%',
          right: '3%',
          bottom: '15%',
          top: '10%',
          containLabel: true
        },
        xAxis: [
          {
            axisTick: {
              alignWithLabel: true
            },
            splitLine: { show: false },//去除网格线
            type: 'category',
            data: ['早', '中', '晚']
          }
        ],
        yAxis: [
          {
            splitLine: { show: false },//去除网格线
            type: 'value'
          }
        ],
        series: [
          {
            type: 'bar',
            barWidth: 15,//柱图宽度
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0,
                  [
                    { offset: 0, color: '#01516E' },
                    { offset: 0.5, color: '#00A4A3' },
                    { offset: 1, color: '#01FCDE' }
                  ]
                )
              }
            },
            data: [320, 332, 301]
          },
          {
            type: 'bar', barWidth: 15,//柱图宽度
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0,
                  [
                    { offset: 0, color: '#01516E' },
                    { offset: 0.5, color: '#188df0' },
                    { offset: 1, color: '#008CEB' }
                  ]
                )
              }
            },
            data: [220, 182, 191]
          }
        ]
      };
      myChart.setOption(option);
    },

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值