vue中使用echarts制作圓環(huán)圖的實例代碼
更新時間:2018年07月27日 11:47:51 作者:Eternal-memory
這篇文章主要介紹了vue中使用echarts制作圓環(huán)圖的實例代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
vue使用echarts制作圓環(huán)圖,代碼如下所示:
<div id="main"></div>
<script type="text/ecmascript-6">
export default {
//從父組件中接收到的數(shù)據(jù)
props:{
chartT:{
type:Object,
required:true
}
},
data () {
return {
charts: '',
totalIncome:'',
opinionData: [
{value: Math.abs(this.chartT.imp_rate)},//取絕對值
{value: 100}
]
}
},
methods: {
drawPie (id) {
this.charts = this.$echarts.init(document.getElementById(id));
this.charts.setOption({
tooltip: {
trigger: 'item',
formatter: '{a}<br/>:{c} (bo7e8sn%)'
},
legend: {
orient: 'vertical',
x: 'left',
data: this.opinion
},
color:['#2872ef','#d6d6d6','#fc6e51'],
series: [
{
name: '訪問來源',
type: 'pie',
radius: ['90%', '65%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
testStyle: {
fontSize: '30',
fontWeight: 'bold'
}
}
},
//根據(jù)數(shù)值判斷顏色
// itemStyle:{
// normal:{
// color:function(params){
// console.log(params)
// console.log(params.dataIndex)
// console.log(params.data.value)
// console.log(params.value)
// if(params.value > 0){
// return "#2872ef";
// }else if(params.value[0] < 0 ){
// return "#fc6e51";
// }
// return "#d6d6d6";
// }
// }
// },
labelLine: {
normal: {
show: false
}
},
data: this.opinionData
}
]
})
}
},
mounted () {
this.$nextTick(function () {
this.drawPie('main')
})
},
}
</script>
父組件傳值給子組件
<template>
<div class="index-wrapper">
<tittle :chartT="chart_tit"></tittle>
</div>
</template>
<script type="text/ecmascript-6">
import axios from 'axios'
import Tittle from './applicationDetail/appTittle'
export default {
data(){
return{
chart_tit:{}
}
}
}
</script>
總結(jié)
以上所述是小編給大家介紹的vue中使用echarts制作圓環(huán)圖的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
vue.js如何處理數(shù)組對象中某個字段是否變?yōu)閮蓚€字段
這篇文章主要介紹了vue.js如何處理數(shù)組對象中某個字段是否變?yōu)閮蓚€字段方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2025-03-03
vuex 第三方包實現(xiàn)數(shù)據(jù)持久化的方法
本文主要介紹了vuex 第三方包實現(xiàn)數(shù)據(jù)持久化的方法,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-09-09

