中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

vue怎么實現echarts中的儀表盤

發布時間:2022-03-28 09:07:22 來源:億速云 閱讀:362 作者:iii 欄目:開發技術

這篇文章主要介紹“vue怎么實現echarts中的儀表盤”,在日常操作中,相信很多人在vue怎么實現echarts中的儀表盤問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”vue怎么實現echarts中的儀表盤”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

最終結果

vue怎么實現echarts中的儀表盤

一、安裝

1. 首先需要安裝echarts依賴包

npm install echarts -S

2. 或者使用國內的淘寶鏡像:

npm install -g cnpm --registry=https://registry.npm.taobao.org

二、創建圖表

全局引入

main.js

// 引入echarts
import echarts from 'echarts'

Vue.prototype.$echarts = echarts

Hello.vue

<div id="myChart" :></div>
export default {
    data(){
      return {}
    }, 
     mounted(){
        this.myChart() //函數調用
     },
     methods:{
        myChart() {
        let columnar = this.$echarts.init(document.getElementById('myChart'));
        columnar.setOption({
          tooltip : {
            formatter: "{a} <br/>{c} {b}"
          },
          toolbox: {
            show: true,
            feature: {
              restore: {show: true},
              saveAsImage: {show: true}
            }
          },
          series : [
           {
                    name: '空氣質量:',
                    type: 'gauge',
                    z: 3,
                    min: 0,
                    max: 500,
                    splitNumber: 10,
                    radius: '60%',
                    axisLine: {
                        lineStyle: {
                            width: 10,
                            color: [[0.1, 'green'], [0.2, 'yellow'],[0.3, 'orange'],[0.4,'#db555e'],[0.5,'#ba3779'],[1.1,'#881326'] ]
                        }
                    },
                    axisTick: {
                        length: 15,
                        lineStyle: {
                            color: 'auto'
                        }
                    },
                    //刻度分割線樣式
                    splitLine: {
                        length: 20,
                        lineStyle: {
                            color: 'white'
                        }
                    },
                    //刻度數字樣式
                    axisLabel: {
                        fontWeight:'bold',
                        color: '#0085FF',
                    },
                    detail : {
                        //說明數字大小
                        formatter: function (value) {
                            return value;
                        },
                        offsetCenter:['0%','80%'],
                        fontWeight: 'bolder',
                        borderRadius: 3,
                        backgroundColor: '#0085FF',
                        fontSize:14,
                        width: 100,
                        color: 'white',
                        padding:[5,15,2,15]
                    },
                data:[1,2,3,4,5,6,7]
                },
            {
                    name: 'PM2.5:',
                    type: 'gauge',
                    center: ['20%', '55%'],
                    radius: '40%',
                    min:0,
                    max:350,
                    valu:55,
                    endAngle:45,
                    splitNumber:5,
                    axisLine: {
                        lineStyle: {
                            width: 8,
                            color: [[0.2, 'green'], [0.4, 'yellow'],[1.1,'orange'] ]
                        }
                    },
                

                    axisTick: {
                        length:12,
                        lineStyle: {
                            color: 'auto'
                        }
                    },
                    splitLine: {
                        length:20,
                        lineStyle: {
                            color: 'auto'
                        }
                    },
                    pointer: {
                        width:5,
                        color:'red'
                    },
                //刻度數字樣式
                    axisLabel: {
                        fontWeight:'bold',
                        color: '#0085FF',
                        fontSize:8,   //改變儀表盤內刻度數字的大小
                        
                    },
                    detail: {
                        formatter: function (value) {
                            return value;
                        },
                        offsetCenter:['15%','75%'],
                        fontWeight: 'bolder',
                        borderRadius: 3,
                        backgroundColor: '#0085FF',
                        fontSize:14,
                        width: 100,
                        color: 'white',
                        padding:[5,15,2,15]
                    },
                    data:[1,2,3,4,5,6]
                },
           {
                    name: 'PM10:',
                    type: 'gauge',
                    //儀表盤位置
                    center: ['79%', '55%'],
                    //儀表盤半徑
                    radius: '40%',
                    min:0,
                    max:500,
                    startAngle:130,
                    splitNumber:5,
                    //儀表盤弧線寬度
                    axisLine: {
                        lineStyle: {
                            width: 8,
                            color: [[0.2, 'green'], [0.4, 'yellow'],[1, 'orange'] ]
                        }  
                        
                    },
                    //儀表盤小刻度樣式
                    axisTick: {
                        length:12,
                        lineStyle: {
                            color: 'auto'
                        }
                    },
                    //儀表盤大刻度樣式
                    splitLine: {
                        length:20,
                        lineStyle: {
                            color: 'auto'
                        }
                    },
                    //儀表盤指針樣式
                    pointer: {
                        width:5,//指針的寬度
                        length:"60%", //指針長度,按照半圓半徑的百分比
                        shadowColor : 'blue', //默認透明
                        shadowBlur: 5
                    },

                    //刻度數字樣式
                    axisLabel: {
                        fontWeight:'bold',
                        color: 'auto',
                        fontSize:8,   //改變儀表盤內刻度數字的大小
                        
                    },
                    detail: {
                        //說明數字大小
                        formatter: function (value) {
                            return value;
                        },
                        //儀表盤下方文字說明
                        offsetCenter:['0%','80%'],
                        fontWeight: 'bolder',
                        borderRadius: 3,
                        backgroundColor: '#0085FF',
                        fontSize:14,
                        width: 100,
                        color: 'white',
                        padding:[5,15,2,15]
                    },
                data:[1,2,3,4]
                }
          ]
        })
      }
  }

到此,關于“vue怎么實現echarts中的儀表盤”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

孝义市| 信丰县| 浦北县| 靖西县| 阿图什市| 萍乡市| 凤凰县| 小金县| 景泰县| 双鸭山市| 九江市| 高雄市| 阳春市| 龙井市| 孟连| 东平县| 深州市| 堆龙德庆县| 布拖县| 库伦旗| 阿巴嘎旗| 郸城县| 咸丰县| 县级市| 贺兰县| 静海县| 千阳县| 施秉县| 漯河市| 桦南县| 民和| 鱼台县| 松阳县| 阿拉善右旗| 宜丰县| 兴化市| 凤庆县| 潞西市| 新邵县| 共和县| 大连市|