vue引入echart的图表

得分图表

main.js文件

// 引入echarts-5.0
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts

Test.vue文件

// 重点 
// 1.div设置id/class/ref;设置画布width,height(css样式)
// 2.let chartDom = document.getElementById('lineDemo') 获取dom节点 
// 2.let myChart =this.$echarts.init(chartDom) 初始化echarts实例 
//3.myChart.setOption(this.option) 写入echarts配置项 详情见官网配置文档

<template>
  <div class="container">
    <h1>{{ title }}</h1>
    <div class="echart" id="lineDemo1" ref="chart"></div>
    <div class="echart" id="lineDemo2" ref="chart"></div>
  </div>
</template>

<script>
export default {
  name: 'index',
  data () {
    return {
      title: 'echarts-demo',
      option1 : {
  series: [
    {
      type: 'gauge',
      progress: {
        show: true,
        width: 18
      },
      axisLine: {
        lineStyle: {
          width: 18
        }
      },
      axisTick: {
        show: false,
        splitNumber: 100
      },
      splitLine: {
        length: 15,
        lineStyle: {
          width: 2,
          color: '#999'
        }
      },
      axisLabel: {
        distance: 20,
        color: '#999',
        fontSize: 20
      },
      anchor: {
        show: true,
        showAbove: true,
        size: 20,
        itemStyle: {
          borderWidth: 10
        }
      },
      title: {
        show: false
      },
      detail: {
        valueAnimation: true,
        fontSize: 80,
        show: false,
        offsetCenter: [0, '70%']
      },
      title: {
        show: true,
        fontSize: 40,
        offsetCenter: [0, '70%']
      },
      data: [
        {
          value: '80',
          name: '得分'
        }
      ],
      max: 120,
      splitNumber: 6,
      radius: '100%'
    }
  ]
}, 
option2 : {
  series: [
    {
      type: 'gauge',
      progress: {
        show: true,
        width: 18
      },
      axisLine: {
        lineStyle: {
          width: 18
        }
      },
      axisTick: {
        show: false,
        splitNumber: 100
      },
      splitLine: {
        length: 15,
        lineStyle: {
          width: 2,
          color: '#999'
        }
      },
      axisLabel: {
        distance: 20,
        color: '#999',
        fontSize: 20
      },
      anchor: {
        show: true,
        showAbove: true,
        size: 20,
        itemStyle: {
          borderWidth: 10
        }
      },
      title: {
        show: false
      },
      detail: {
        valueAnimation: true,
        fontSize: 40,
        show: false,
        offsetCenter: [0, '70%']
      },
      title: {
        show: true,
        fontSize: 40,
        offsetCenter: [0, '70%']
      },
      data: [
        {
          value: '60',
          name: '得分'
        }
      ],
      max: 100,
      splitNumber: 5,
      radius: '100%'
    }
  ]
}
    }
  },
  mounted () {
    let chartDom1 = document.getElementById('lineDemo1')
    let myChart1 = this.$echarts.init(chartDom1)
    myChart1.clear()
    myChart1.setOption(this.option1)
    let chartDom2 = document.getElementById('lineDemo2')
    let myChart2 = this.$echarts.init(chartDom2)
    myChart2.clear()
    myChart2.setOption(this.option2)
  },
  methods: {},
  watch: {},
  created () {
  }
}
</script>

<style scoped>
.echart {
  width: 360px;
  height: 360px;
}
</style>


图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值