在jQuery里面愿险,實現一個折線圖节榜,【前端統(tǒng)計圖】echarts實現單條折線圖
http://www.reibang.com/p/0354a4f8c563孝鹊。
現在要實現,Vue+Echarts實現一個折線圖,打開之前的mint項目:
1:在項目里面安裝echarts
cnpm install echarts --s
2:在需要用圖表的地方引入
import echarts from 'echarts'
3:打開my.vue
繼續(xù)寫代碼坪圾,代碼如下:
<template>
<!--為echarts準備一個具備大小的容器dom-->
<div id="main" style="width: 600px;height: 400px;"></div>
</template>
<script>
import echarts from 'echarts'
export default {
name: '',
data() {
return {
charts: '',
/* opinion: ["1", "3", "3", "4", "5"],*/
opinionData: ["3", "2", "4", "4", "5"]
}
},
methods: {
drawLine(id) {
this.charts = echarts.init(document.getElementById(id))
this.charts.setOption({
tooltip: {
trigger: 'axis'
},
legend: {
data: ['近七日收益']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ["1","2","3","4","5"]
},
yAxis: {
type: 'value'
},
series: [{
name: '近七日收益',
type: 'line',
stack: '總量',
data: this.opinionData
}]
})
}
},
//調用
mounted() {
this.$nextTick(function() {
this.drawLine('main')
})
}
}
</script>
<style scoped>
* {
margin: 0;
padding: 0;
list-style: none;
}
</style>
這個時候讼油,可以看到杰赛,加載出的折線圖了,后面可以繼續(xù)進行完善矮台。
原文作者:祈澈姑娘 技術博客:http://www.reibang.com/u/05f416aefbe1
90后前端妹子乏屯,愛編程,愛運營瘦赫,文藝與代碼齊飛辰晕,魅力與智慧共存的程序媛一枚。
堅持總結工作中遇到的技術問題确虱,堅持記錄工作中所所思所見含友,對于博客上面有不會的問題,歡迎加入編程微刊主頁qq群校辩。