Vue Echarts簡(jiǎn)易實(shí)現(xiàn)儀表盤
前言
本篇來學(xué)習(xí)寫儀表盤圖
儀表盤的特點(diǎn)
可以更直觀的表現(xiàn)出某個(gè)指標(biāo)的進(jìn)度或?qū)嶋H情況
儀表盤的基本實(shí)現(xiàn)
- ECharts 最基本的代碼結(jié)構(gòu)
- 準(zhǔn)備數(shù)據(jù), 設(shè)置給 series 下的 data
- 在 series 下設(shè)置 type:gauge
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>儀表盤</title> <!-- cdn方式 引入echarts.js文件 --> <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1/dist/echarts.min.js"></script> </head> <body> <div id='app' style="width: 600px;height:400px"></div> <script> var mCharts = echarts.init(document.getElementById("app")) var option = { series: [ { type: 'gauge', data: [ { value: 95 } ] } ] } mCharts.setOption(option) </script> </body> </html>
效果
儀表盤的常見效果
- 數(shù)值范圍: max min
- 多個(gè)指針: 增加data中數(shù)組的元素
- 多個(gè)指針顏色的差異: itemStyle
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>儀表盤</title> <!-- cdn方式 引入echarts.js文件 --> <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1/dist/echarts.min.js"></script> </head> <body> <div id='app' style="width: 600px;height:400px"></div> <script> var mCharts = echarts.init(document.getElementById("app")) var option = { series: [ { type: 'gauge', data: [ // 每一個(gè)對(duì)象就代表一個(gè)指針 { name: 'mem', value: 70, itemStyle: { // 指針的樣式 color: 'purple' // 指針的顏色 }, title: { offsetCenter: ['-40%', '80%'] }, detail: { offsetCenter: ['-40%', '95%'] } }, { name: 'cpu', value: 80, itemStyle: { color: 'blue' }, title: { offsetCenter: ['40%', '80%'] }, detail: { offsetCenter: ['40%', '95%'] } }, ], detail: { // 數(shù)值文案樣式 width: 40, height: 14, fontSize: 14, color: '#fff', backgroundColor: 'auto', borderRadius: 3, formatter: '{value}%' }, title: { // name 文字大小 fontSize: 20 }, progress: { // 儀表盤數(shù)據(jù)樣式 show: true, overlap: true, roundCap: true }, max: 100, min: 20 // min max 控制儀表盤數(shù)值范圍 } ] } mCharts.setOption(option) </script> </body> </html>
效果
到此這篇關(guān)于Vue Echarts簡(jiǎn)易實(shí)現(xiàn)儀表盤的文章就介紹到這了,更多相關(guān)Vue Echarts儀表盤內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在vue項(xiàng)目中(本地)使用iconfont字體圖標(biāo)的三種方式總結(jié)
這篇文章主要介紹了在vue項(xiàng)目中(本地)使用iconfont字體圖標(biāo)的三種方式總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09一文詳解vue-router中的導(dǎo)航守衛(wèi)
vue-router提供的導(dǎo)航守衛(wèi)主要用來通過跳轉(zhuǎn)或取消的方式守衛(wèi)導(dǎo)航,在 vue-router 中,導(dǎo)航守衛(wèi)是一種非常重要的功能,所以本文將詳細(xì)講解一下vue-router中的導(dǎo)航守衛(wèi),感興趣的同學(xué)跟著小編一起來看看吧2023-07-07vue3.0使用mapState,mapGetters和mapActions的方式
這篇文章主要介紹了vue3.0使用mapState,mapGetters和mapActions的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06Vue.js + Nuxt.js 項(xiàng)目中使用 Vee-validate 表單校驗(yàn)
vee-validate 是為 Vue.js 量身打造的表單校驗(yàn)框架,允許您校驗(yàn)輸入的內(nèi)容并顯示對(duì)應(yīng)的錯(cuò)誤提示信息。這篇文章給大家?guī)砹薞ue.js 使用 Vee-validate 實(shí)現(xiàn)表單校驗(yàn)的相關(guān)知識(shí),感興趣的朋友一起看看吧2019-04-04VUE中如何優(yōu)雅實(shí)現(xiàn)爺孫組件的數(shù)據(jù)通信
所謂祖孫組件,也就是3層嵌套的組件,下面這篇文章主要給大家介紹了關(guān)于VUE中如何優(yōu)雅實(shí)現(xiàn)爺孫組件的數(shù)據(jù)通信的相關(guān)資料,需要的朋友可以參考下2022-04-04Vue實(shí)現(xiàn)當(dāng)前頁面刷新的七種方法總結(jié)
大家在vue項(xiàng)目中當(dāng)刪除或者增加一條記錄的時(shí)候希望當(dāng)前頁面可以重新刷新,但是vue框架自帶的router是不支持刷新當(dāng)前頁面功能,所以本文就給大家分享了七種vue實(shí)現(xiàn)當(dāng)前頁面刷新的方法,需要的朋友可以參考下2023-07-07vue3項(xiàng)目中代碼出現(xiàn)紅色波浪線的問題及解決
這篇文章主要介紹了vue3項(xiàng)目中代碼出現(xiàn)紅色波浪線的問題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09