日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

Vue中使用echarts绘制地图,以及只显示南海问题

發布時間:2024/1/1 vue 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Vue中使用echarts绘制地图,以及只显示南海问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

下載echarts依賴

下載依賴我想大家都會:cnpm / npm install echartsyar add echarts typescript項目 npm install @types/echarts 復制代碼

引入

在main.js中引入 import Echarts form 'echarts' Vue.prototype.$echarts = Echarts 復制代碼

在組件中使用

mounted () {this.drawChinaMap(); }, methods: {drawChinaMap () {let myCharts = document.getElementById('chinaMap');let options = {title: {text: 'iphone銷量',subtext: '純屬虛構',left: 'center'},tooltip: {trigger: 'item'},legend: {orient: 'vertical',left: 'left',data: ['iphone3', 'iphone4', 'iphone5']},visualMap: {min: 0,max: 2500,left: 'left',top: 'bottom',text: ['高', '低'], // 文本,默認為數值文本calculable: true},toolbox: {show: true,orient: 'vertical',left: 'right',top: 'center',feature: {mark: {show: true},dataView: {show: true, readOnly: false},restore: {show: true},saveAsImage: {show: true}}},series: [{name: 'iphone3',type: 'map',mapType: 'china',roam: true,label: {normal: {show: false},emphasis: {show: true}},data: [{name: '北京', value: Math.round(Math.random() * 1000)},{name: '天津', value: Math.round(Math.random() * 1000)},{name: '上海', value: Math.round(Math.random() * 1000)},{name: '重慶', value: Math.round(Math.random() * 1000)},{name: '河北', value: Math.round(Math.random() * 1000)},{name: '河南', value: Math.round(Math.random() * 1000)},{name: '云南', value: Math.round(Math.random() * 1000)},{name: '遼寧', value: Math.round(Math.random() * 1000)},{name: '黑龍江', value: Math.round(Math.random() * 1000)},{name: '湖南', value: Math.round(Math.random() * 1000)},{name: '安徽', value: Math.round(Math.random() * 1000)},{name: '山東', value: Math.round(Math.random() * 1000)},{name: '新疆', value: Math.round(Math.random() * 1000)},{name: '江蘇', value: Math.round(Math.random() * 1000)},{name: '浙江', value: Math.round(Math.random() * 1000)},{name: '江西', value: Math.round(Math.random() * 1000)},{name: '湖北', value: Math.round(Math.random() * 1000)},{name: '廣西', value: Math.round(Math.random() * 1000)},{name: '甘肅', value: Math.round(Math.random() * 1000)},{name: '山西', value: Math.round(Math.random() * 1000)},{name: '內蒙古', value: Math.round(Math.random() * 1000)},{name: '陜西', value: Math.round(Math.random() * 1000)},{name: '吉林', value: Math.round(Math.random() * 1000)},{name: '福建', value: Math.round(Math.random() * 1000)},{name: '貴州', value: Math.round(Math.random() * 1000)},{name: '廣東', value: Math.round(Math.random() * 1000)},{name: '青海', value: Math.round(Math.random() * 1000)},{name: '西藏', value: Math.round(Math.random() * 1000)},{name: '四川', value: Math.round(Math.random() * 1000)},{name: '寧夏', value: Math.round(Math.random() * 1000)},{name: '海南', value: Math.round(Math.random() * 1000)},{name: '臺灣', value: Math.round(Math.random() * 1000)},{name: '香港', value: Math.round(Math.random() * 1000)},{name: '澳門', value: Math.round(Math.random() * 1000)}]},{name: 'iphone4',type: 'map',mapType: 'china',label: {normal: {show: false},emphasis: {show: true}},data: [{name: '北京', value: Math.round(Math.random() * 1000)},{name: '天津', value: Math.round(Math.random() * 1000)},{name: '上海', value: Math.round(Math.random() * 1000)},{name: '重慶', value: Math.round(Math.random() * 1000)},{name: '河北', value: Math.round(Math.random() * 1000)},{name: '安徽', value: Math.round(Math.random() * 1000)},{name: '新疆', value: Math.round(Math.random() * 1000)},{name: '浙江', value: Math.round(Math.random() * 1000)},{name: '江西', value: Math.round(Math.random() * 1000)},{name: '山西', value: Math.round(Math.random() * 1000)},{name: '內蒙古', value: Math.round(Math.random() * 1000)},{name: '吉林', value: Math.round(Math.random() * 1000)},{name: '福建', value: Math.round(Math.random() * 1000)},{name: '廣東', value: Math.round(Math.random() * 1000)},{name: '西藏', value: Math.round(Math.random() * 1000)},{name: '四川', value: Math.round(Math.random() * 1000)},{name: '寧夏', value: Math.round(Math.random() * 1000)},{name: '香港', value: Math.round(Math.random() * 1000)},{name: '澳門', value: Math.round(Math.random() * 1000)}]},{name: 'iphone5',type: 'map',mapType: 'china',label: {normal: {show: false},emphasis: {show: true}},data: [{name: '北京', value: Math.round(Math.random() * 1000)},{name: '天津', value: Math.round(Math.random() * 1000)},{name: '上海', value: Math.round(Math.random() * 1000)},{name: '廣東', value: Math.round(Math.random() * 1000)},{name: '臺灣', value: Math.round(Math.random() * 1000)},{name: '香港', value: Math.round(Math.random() * 1000)},{name: '澳門', value: Math.round(Math.random() * 1000)}]}]};myCharts.setOption(optins);} } 復制代碼

問題

  • 以上做法在3.x版本以上只顯示南海

  • 但是畫普通圖表沒問題

    我找了些資料看,有人說缺少china.js

    我是4.x版本

    在依賴包里發現有china.js

    于是我再次引入,問題解決

解決方案

在main.js中引入china.js import 'echarts/map/js/china.js'; 復制代碼

轉載于:https://juejin.im/post/5c9c94b0e51d45381b03ed70

總結

以上是生活随笔為你收集整理的Vue中使用echarts绘制地图,以及只显示南海问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。