Echarts--不同颜色的柱状图

1.安装

npm install echarts --save

2.引用

const Echarts = require('echarts')

3.使用

<div class="bar-echarts" ref="barChart"></div>

getBarCharts() {
      let barChart = ECharts.init(this.$refs.barChart);
      let barOption = {
        color: ["#89A7F8", "#595EE4", "#4576E9", "#FC9C62", "#7BC071"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow"
          }
        },
        legend: {
          icon: "rect",
          fontSize: 12,
          color: "#333",
          itemWidth: 9,
          itemHeight: 9,
          itemGap: 20,
          data: this.legend,
          textStyle: {
            padding: [15, 0, 0, 0]
          },
          x: "9%",
          y: "bottom"
        },
        grid: {
          left: "0%",
          right: "6%",
          bottom: "10%",
          containLabel: true
        },
        xAxis: {
          type: "category",
          axisTick: {
            show: false
          },
          axisLabel: {
            show: true,
            textStyle: {
              color: "#545454",
              fontSize: 12
            }
          },
          axisLine: {
            lineStyle: {
              color: "#BEBEBE",
              width: 1
            }
          },
          data: this.barMonth
        },
        yAxis: {
          type: "value",
          splitLine: {
            show: true,
            lineStyle: {
              color: "#E9E9E9",
              type: "dashed"
            }
          },
          axisLabel: {
            formatter: "¥{value}",
            textStyle: {
              fontSize: 12,
              color: "#545454"
            }
          }
        },
        series: this.barSeries
        //  [
        //     {
        //         name: '分润小精灵',
        //         type: 'bar',
        //         stack: 'total',
        //         label: {
        //             show: true
        //         },
        //         emphasis: {
        //             focus: 'series'
        //         },
        //         data: [320, 302, 301, 334, 390, 330, 320]
        //     },
        //     {
        //         name: '电子合同签约',
        //         type: 'bar',
        //         stack: 'total',
        //         label: {
        //             show: true
        //         },
        //         emphasis: {
        //             focus: 'series'
        //         },
        //         data: [120, 132, 101, 134, 90, 230, 210]
        //     },
        //     {
        //         name: '实名认证',
        //         type: 'bar',
        //         stack: 'total',
        //         label: {
        //             show: true
        //         },
        //         emphasis: {
        //             focus: 'series'
        //         },
        //         data: [220, 182, 191, 234, 290, 330, 310]
        //     },
        //     {
        //         name: '基础短信服务',
        //         type: 'bar',
        //         stack: 'total',
        //         label: {
        //             show: true
        //         },
        //         emphasis: {
        //             focus: 'series'
        //         },
        //         data: [150, 212, 201, 154, 190, 330, 410]
        //     },
        //     {
        //         name: '客服坐席',
        //         type: 'bar',
        //         stack: 'total',
        //         label: {
        //             show: true
        //         },
        //         emphasis: {
        //             focus: 'series'
        //         },
        //         data: [820, 832, 901, 934, 1290, 1330, 1320]
        //     }
        // ]
      };
      barChart.setOption(barOption);
    }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值