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 { //從父組件中接收到的數據 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} (ublnpf9mb%)' }, 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' } } }, //根據數值判斷顏色 // 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>
總結
以上所述是小編給大家介紹的vue中使用echarts制作圓環(huán)圖的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
相關文章
Vuerouter的beforeEach與afterEach鉤子函數的區(qū)別
本文詳細的介紹了Vuerouter的beforeEach與afterEach鉤子函數的區(qū)別和使用,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12使用Electron打包vue文件變成exe應用程序的全過程
這篇文章主要給大家介紹了使用Electron打包vue文件變成exe應用程序的全過程,文中通過代碼示例和圖文結合的方式給大家講解的非常詳細,具有一定的參考價值,需要的朋友可以參考下2024-01-01詳解element-ui表格中勾選checkbox,高亮當前行
這篇文章主要介紹了詳解element-ui表格中勾選checkbox,高亮當前行,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-09-09