最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

在vue中使用echarts實(shí)現(xiàn)飛機(jī)航線水滴圖詞云圖效果

 更新時(shí)間:2022年08月15日 17:12:21   作者:扣1送地獄火  
這篇文章主要介紹了在vue中使用echarts實(shí)現(xiàn)飛機(jī)航線?水滴圖?詞云圖,通過(guò)引入中國(guó)地圖JS文件,會(huì)自動(dòng)注冊(cè)地圖,文中結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下

vue中引入echarts

npm install echarts 

在main.js中引用并掛載到vue上便于使用

import * as echarts from 'echarts'
Vue.prototype.$echarts =echarts

飛機(jī)航線

html

<template>
  <div class="com-container">
    <div
      class="com-chart"
      ref="chart"
    ></div>
  </div>
</template>

css

.com-page {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
 
.com-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
 
.com-chart {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
 
canvas {
  border-radius: 20px;
}
 
.com-container {
  position: relative;
}

準(zhǔn)備數(shù)據(jù)

引入中國(guó)地圖JS文件,會(huì)自動(dòng)注冊(cè)地圖;

// 中國(guó)地圖JS文件
require('echarts/map/js/china')

也可以通過(guò)axios方式引入json文件,需要手動(dòng)注冊(cè)echarts.registerMap('china', chinaJson.data)

      const ret = await axios.get('http://localhost:8999/static/map/china.json')
      this.echarts.registerMap('china', ret.data)

地圖數(shù)據(jù) 可以使用各個(gè)城市的數(shù)據(jù) 我這里沒(méi)去找

     chinaGeoCoordMap: {
        黑龍江: [127.9688, 45.368],
        內(nèi)蒙古: [110.3467, 41.4899],
        吉林: [125.8154, 44.2584],
        北京市: [116.4551, 40.2539],
        遼寧: [123.1238, 42.1216],
        河北: [114.4995, 38.1006],
        天津: [117.4219, 39.4189],
        山西: [112.3352, 37.9413],
        陜西: [109.1162, 34.2004],
        甘肅: [103.5901, 36.3043],
        寧夏: [106.3586, 38.1775],
        青海: [101.4038, 36.8207],
        新疆: [87.9236, 43.5883],
        西藏: [91.11, 29.97],
        四川: [103.9526, 30.7617],
        重慶: [108.384366, 30.439702],
        山東: [117.1582, 36.8701],
        河南: [113.4668, 34.6234],
        江蘇: [118.8062, 31.9208],
        安徽: [117.29, 32.0581],
        湖北: [114.3896, 30.6628],
        浙江: [119.5313, 29.8773],
        福建: [119.4543, 25.9222],
        江西: [116.0046, 28.6633],
        湖南: [113.0823, 28.2568],
        貴州: [106.6992, 26.7682],
        云南: [102.9199, 25.4663],
        廣東: [113.12244, 23.009505],
        廣西: [108.479, 23.1152],
        海南: [110.3893, 19.8516],
        上海: [121.4648, 31.2891]
      },

飛線數(shù)據(jù) 配置航線起點(diǎn)和終點(diǎn)數(shù)據(jù)

       HxDatas: [
 
        {
          start: '甘肅',
          end: '寧夏'
        },
        {
          start: '青海',
          end: '新疆'
        },
 
        {
          start: '西藏',
          end: '四川'
 
        },
 
        {
          start: '山東',
          end: '河南'
 
        },
 
        {
          start: '江蘇',
          end: '安徽'
 
        },
 
        {
          start: '湖北',
          end: '福建'
 
        },
 
        {
          start: '江西',
          end: '黑龍江'
        },
        {
          start: '內(nèi)蒙古',
          end: '吉林'
        },
        {
          start: '遼寧',
          end: '河北'
        },
        {
          start: '天津',
          end: '山西'
        },
        {
          start: '陜西',
          end: '海南'
        },
        {
          start: '上海',
          end: '湖南'
        },
        {
          start: '貴州',
          end: '廣西'
 
        }
 
      ]

處理飛行數(shù)據(jù)獲得起點(diǎn)和終點(diǎn)坐標(biāo)起點(diǎn)和終點(diǎn)

我這里統(tǒng)一設(shè)置了以北京為起點(diǎn)

 methods: {
   convertData (data) {
      const res = []
      const fromCoord = this.chinaGeoCoordMap[data.start]// 起點(diǎn)坐標(biāo)
      const toCoord = this.chinaGeoCoordMap[data.end]// 終點(diǎn)坐標(biāo)
      if (fromCoord && toCoord) {
        res.push([
      
          // fromCoord,
          [116.4551, 40.2539], // 北京坐標(biāo)
          fromCoord
 
          // 航班數(shù)量
          // value:
 
        ])
      }
      // console.log(res)
      return res
    }
}

配置地圖

this.chartInstance = this.$echarts.init(this.$refs.charts)
const initOption = {
        geo: {
          type: 'map',
          map: 'china',
          top: '5%',
          bottom: '5%',
          itemStyle: {
            areaColor: 'rgba(3, 22, 32, 1)',
            borderColor: '#b2def2'
          }
        }
}
  this.chartInstance.setOption(initOption)

配置折線line和散點(diǎn)

planePath: 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z'
 
 this.HxDatas.forEach((item, i) => {
        // console.log(this.convertData(item))
        seriesArr.push(
          {
            type: 'lines',
            zlevel: 2,
            coordinateSystem: 'geo',
            symbol: ['none', 'arrow'], // 線兩端的標(biāo)記類型,可以是一個(gè)數(shù)組分別指定兩端
            blendMode: 'lighter',
            dimensions: ['value'],
            polyline: true,
            effect: { // 線特效的配置  飛機(jī)樣式
              show: true,
              period: 8, // 特效動(dòng)畫的時(shí)間
              trailLength: 0.1, // 特效尾跡的長(zhǎng)度。取從 0 到 1 的值,數(shù)值越大尾跡越長(zhǎng)。
              // width: 1, // 尾跡線條寬度
              opacity: 0.7, // 尾跡線條透明度
              color: '#fff',
              curveness: 0.1,
              symbolSize: 13, // 特效標(biāo)記的大小,可以設(shè)置成諸如 10 這樣單一的數(shù)字,也可以用數(shù)組分開表示高和寬,例如 [20, 10] 表示標(biāo)記寬為20,高為10。
              symbol: this.planePath
 
            },
            // 線條樣式
            lineStyle: {
              normal: {
                show: true,
                curveness: 0.4, // 尾跡線條曲直度
                color: '#007acc' // 飛線顏色
              }
            },
            data: this.convertData(item)
          },
 
            // 配置起點(diǎn)和終點(diǎn)散點(diǎn)樣式
            {
            type: 'effectScatter',
            data: this.convertData(item)[0],
            zlevel: 2,
            coordinateSystem: 'geo',
            rippleEffect: {
              // 漣漪特效
              // period: 4, // 動(dòng)畫時(shí)間,值越小速度越快
              brushType: 'stroke', // 波紋繪制方式 stroke, fill
              scale: 10 // 波紋圓環(huán)最大限制,值越大波紋越大
              // color: '#fcdd6e'
            },
 
            itemStyle: { // 控制散點(diǎn)的樣式
              show: true,
              color: function () {
                return 'rgb(' + [
                  Math.round(Math.random() * 255),
                  Math.round(Math.random() * 255),
                  Math.round(Math.random() * 255),
                  0.5].join(',') + ')'
              }
            },
            symbol: 'circle',
            symbolSize: function (val) {
              return 5 // 圓環(huán)大小
            }
 
          }
 
        )
      })
 
      const dataoption = {
        series: seriesArr
      }
 
      this.chartInstance.setOption(dataoption)

使用

給父盒子開啟相對(duì)定位

包含組件的子盒子絕對(duì)定位

便于控制組件在頁(yè)面中呈現(xiàn)的位置

父層position:relative;子層position:absolute;的話, 就是依照父層的邊界進(jìn)行定位的

<template>
<div class="com-page">
      <div class="left">
        <Map></Map>
      </div>
</div>
 
</template>
 
<style>
 
.com-container {
  position: relative;
  ...
}
.left{
    position:absolute
    ...
}
 
</style>

水滴圖

需要額外引入

npm i echarts-liquidfill

在需要的組件

我這里用了 import * as echarts from 'echarts' 沒(méi)效果 改了import * as echarts from 'echarts/core'才有數(shù)據(jù)

import * as echarts from 'echarts/core'
import 'echarts-liquidfill'

配置

      this.chartInstance = this.echarts.init(this.$refs.liquidchart, this.theme)
      const initOption = {
        series: [
          {
            type: 'liquidFill',
            center: ['10%', '30%'],
            data: [0.43], // 水球的數(shù)據(jù)
            radius: '35%', // 水球的實(shí)際大小,如果不寫會(huì)比容器小很多
            backgroundStyle: {
              color: '#031620'// 沒(méi)有水球的背景顏色
            },
            name: '1號(hào)倉(cāng)庫(kù)',
            label: {
              normal: {
                formatter () {
                  return '8000件'// 中間數(shù)據(jù)
                },
                color: '#FFFFFF ',
                insideColor: '#fff',
                textStyle: {
                  fontSize: 10,
                  fontWeight: 'bold',
                  fontFamily: 'SourceHanSansCN-Regular'
                }
              }
            },
            color: [
              {
                type: 'linear',
                x: 0,
                y: 1,
                x2: 0,
                y2: 0,
                colorStops: [
                  {
                    offset: 1,
                    color: ['#326872'] // 0% 處的顏色
                  },
                  {
                    offset: 0,
                    color: ['#3BE7EC'] // 100% 處的顏色
                  }
                ],
                global: false // 缺省為 false
              }
            ],
            outline: {
              show: true,
              radius: '80%',
              borderDistance: 5,
              itemStyle: {
                borderColor: '#4381DC',
                borderWidth: 2
              }
            }
          },
 
        ]
 
      }
      this.chartInstance.setOption(initOption)

詞云圖

也需要另外引入

import 'echarts-wordcloud'

配置

    initchart () {
      this.myChart = this.echarts.init(this.$refs.wordcloud)
      this.myChart.setOption({
        series: [
          {
            type: 'wordCloud',
            // 用來(lái)調(diào)整詞之間的距離
            gridSize: 1,
            // 用來(lái)調(diào)整字的大小范圍
            // Text size range which the value in data will be mapped to.
            // Default to have minimum 12px and maximum 60px size.
            sizeRange: [14, 60],
            // Text rotation range and step in degree. Text will be rotated randomly in range [-90,                                                                             90] by rotationStep 45
            // 用來(lái)調(diào)整詞的旋轉(zhuǎn)方向,,[0,0]--代表著沒(méi)有角度,也就是詞為水平方向,需要設(shè)置角度參考注釋內(nèi)容
            rotationRange: [-45, 0, 45, 90],
            // rotationRange: [ 0,90],
            // rotationRange: [0, 0],
            // 隨機(jī)生成字體顏色
            // maskImage: maskImage,
 
            textStyle: {
              color: function () {
                return 'rgb(' + [
                  Math.round(Math.random() * 255),
                  Math.round(Math.random() * 255),
                  Math.round(Math.random() * 255)
                ].join(',') + ')'
              },
              fontFamily: 'sans-serif',
              fontWeight: 'normal'
 
              // emphasis: {
              //   shadowBlur: 10,
              //   shadowColor: '#333'
              // }
            },
 
            // 位置相關(guān)設(shè)置
            // Folllowing left/top/width/height/right/bottom are used for positioning the word cloud
            // Default to be put in the center and has 75% x 80% size.
            left: 'center',
            top: 'center',
            right: null,
            bottom: null,
 
            // 數(shù)據(jù)
            data: this.wordList
          }
        ]
      })
    }

data

      wordList: [
        {
          name: '短袖',
          value: 15000
        },
        {
          name: '連衣裙',
          value: 10081
        },
        {
          name: '純天然',
          value: 9386
        },
        {
          name: '植物',
          value: 7500
        },
        {
          name: '輕薄',
          value: 7500
        },
        {
          name: '洗發(fā)水',
          value: 6500
        },
        {
          name: '防曬霜',
          value: 6500
        },
        {
          name: '抗老',
          value: 6000
        },
        {
          name: '國(guó)風(fēng)',
          value: 4500
        },
        {
          name: '輕復(fù)古',
          value: 3800
        },
        {
          name: '鞋柜',
          value: 3000
        },
        {
          name: '秋季',
          value: 2500
        },
        {
          name: '襯衫',
          value: 2300
        },
        {
          name: '鏤空',
          value: 2000
        },
        {
          name: '月餅',
          value: 1900
        },
        {
          name: '空調(diào)',
          value: 1800
        },
        {
          name: '零食',
          value: 1700
        },
        {
          name: '咖啡',
          value: 1600
        },
        {
          name: '盛夏套裝',
          value: 1500
        },
        {
          name: '情侶睡衣',
          value: 1200
        }
      ]

由于篇幅原因我這里沒(méi)有對(duì)屏幕自適應(yīng)進(jìn)行介紹

到此這篇關(guān)于在vue中使用echarts實(shí)現(xiàn)飛機(jī)航線水滴圖詞云圖效果的文章就介紹到這了,更多相關(guān)vue echarts飛機(jī)航線 水滴圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

通渭县| 马关县| 临沭县| 邵阳县| 达拉特旗| 龙南县| 神池县| 蒙城县| 浦江县| 东乡族自治县| 沈丘县| 武乡县| 五河县| 库车县| 沭阳县| 霍州市| 金阳县| 重庆市| 易门县| 洞口县| 竹山县| 股票| 宁海县| 陕西省| 蒙山县| 萨嘎县| 宁明县| 西充县| 左贡县| 汉源县| 南康市| 鄯善县| 德庆县| 柳江县| 廉江市| 衡东县| 乌鲁木齐市| 客服| 邓州市| 新巴尔虎左旗| 嘉禾县|