在jQuery里面,實(shí)現(xiàn)一個(gè)折線圖,【前端統(tǒng)計(jì)圖】echarts實(shí)現(xiàn)單條折線圖
http://m.itdecent.cn/p/0354a4f8c563。
現(xiàn)在要實(shí)現(xiàn),Vue+Echarts實(shí)現(xiàn)一個(gè)折線圖,打開之前的mint項(xiàng)目:
1:在項(xiàng)目里面安裝echarts
cnpm install echarts --s

2:在需要用圖表的地方引入
import echarts from 'echarts'

3:打開my.vue
繼續(xù)寫代碼,代碼如下:
<template>
<!--為echarts準(zhǔn)備一個(gè)具備大小的容器dom-->
<div id="main" style="width: 600px;height: 400px;"></div>
</template>
<script>
import echarts from 'echarts'
export default {
name: '',
data () {
return {
charts: '',
opinion:['男','女'],
opinionData:[
{value:335, name:'男'},
{value:310, name:'女'},
]
}
},
methods:{
drawPie(id){
this.charts = echarts.init(document.getElementById(id))
this.charts.setOption({
tooltip: {
trigger: 'item',
},
legend: {
orient: 'vertical',
x: 'left',
data:this.opinion
},
series: [
{
name:'性別',
type:'pie',
radius:['50%','70%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
textStyle: {
fontSize: '30',
fontWeight: 'blod'
}
}
},
labelLine: {
normal: {
show: false
}
},
data:this.opinionData
}
]
})
}
},
//調(diào)用
mounted(){
this.$nextTick(function() {
this.drawPie('main')
})
}
}
</script>
<style scoped>
* {
margin: 0;
padding: 0;
list-style: none;
}
</style>
這個(gè)時(shí)候,可以看到,加載出的餅狀圖了,后面可以繼續(xù)進(jìn)行完善。

原文作者:祈澈姑娘 技術(shù)博客:http://m.itdecent.cn/u/05f416aefbe1
90后前端妹子,愛編程,愛運(yùn)營(yíng),文藝與代碼齊飛,魅力與智慧共存的程序媛一枚。
堅(jiān)持總結(jié)工作中遇到的技術(shù)問題,堅(jiān)持記錄工作中所所思所見,對(duì)于博客上面有不會(huì)的問題,歡迎加入編程微刊主頁qq群。