vue使用echarts

14 篇文章 0 订阅

1.下载

 

2.在所需页面

引用----import echarts from 'echarts'

使用----<div id="ldChart" class="chart" :style="{width: '300px', height: '300px'}"

></div>

将option = {下面的内容复制到return中

export default {
  name: "ContentEchartsTwo",
  data() {
    return {
      ldPie: {
         title: {
           text: '堆叠区域图',
           textStyle:{
             fontSize:10
           },
           left:'20px'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            // boundaryGap: false,
            data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月','8月','9月','10月','11月','12月']
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: '邮件营销',
            type: 'line',
            stack: '总量',
            // areaStyle: {},
            areaStyle: {
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                  offset: 0, color: '#fce9f2' // 0% 处的颜色
                }, {
                  offset: 1, color: '#e896bd' // 100% 处的颜色
                }],
                global: false // 缺省为 false
              }
            },
            data: [120, 132, 101, 134, 90, 230, 210, 101, 134, 90, 230, 210]
          }
        ]
      }
    }
  },
  methods: {
    drawLine() {
      let ldChart = echarts.init(document.getElementById('ldChart')); // 基于准备好的dom,初始化echarts实例
      ldChart.setOption(this.ldPie); // 绘制图表
    },
  },
  mounted() { // 注意,必须mounted后绘制
    this.drawLine()
  }
}

 

 

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值