欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

echarts地圖設(shè)置背景圖片及海岸線實(shí)例代碼

 更新時(shí)間:2022年12月09日 15:40:02   作者:紫雪璇雨  
公司的業(yè)務(wù)涉及到統(tǒng)計(jì)圖的有很多,最近一直echarts里面踩各種坑,下面這篇文章主要給大家介紹了關(guān)于echarts地圖設(shè)置背景圖片及海岸線的相關(guān)資料,需要的朋友可以參考下

1、地圖設(shè)置背景圖片

// data
domImg: require('@/assets/images/largescreen/nation/map_bg.png'),
 
// js 渲染地圖之前
var domImg = document.createElement("img");
domImg.style.height = domImg.height = domImg.width = domImg.style.width = "100px";
domImg.src = that.domImg;
 
// js 渲染地址時(shí),在地圖配置項(xiàng)geo中itemStyle
normal: {
    areaColor: {
        type: "pattern",
        image: domImg, //配置圖片
        repeat: "repeat", //可選值repeat、no-repeat、repeat-x、repeat-y
    },
}

2、地圖外部多層輪廓線

首先來看單層加粗外邊框,其實(shí)很簡單。咱們看一下效果

// 在地圖配置項(xiàng)series中添加樣式,效果如下圖
itemStyle: {
       normal: {
           areaColor: '#3075b2',
           borderColor: '#4c99f9',
           borderWidth: 1
       },
       emphasis: {
           areaColor: '#01215c'
       }
}

// 在地圖的配置項(xiàng)geo中設(shè)置,效果如下圖
itemStyle: {
       normal: {
           areaColor: '#01215c',
           borderWidth: 5,//設(shè)置外層邊框
           borderColor:'#9ffcff',
       }
}

 在地圖配置項(xiàng)series、geo中設(shè)置邊框,單獨(dú)設(shè)置就是上圖所示。一起設(shè)置如下圖,中間邊框細(xì),外輪廓邊框粗的效果。

外輪廓加投影就是在 geo中添加 shadowColor設(shè)置,以及偏移shadowOffsetX、shadowOffsetY、shadowBlur。

如果想要多層外輪廓,就是在geo設(shè)置多個(gè)對象。

// 通過偏移,縮放來實(shí)現(xiàn)多層外輪廓的效果
this.option.geo = [
          {
            // 主圖
            map: map,
            zlevel: 0,
            zoom: 1.2, //當(dāng)前視角的縮放比例
            roam: false, //是否開啟平游或縮放
            center: undefined,
            show: true,
            label: {
              normal: {
                show: false,
              },
              emphasis: {
                show: false,
              },
            },
            itemStyle: {
              normal: {
                borderColor: "rgba(141, 199, 255,1)",
                borderWidth: 1,
                areaColor: {
                  type: "pattern",
                  image: domImg, //配置圖片
                  repeat: "repeat", //可選值repeat、no-repeat、repeat-x、repeat-y
                },
              },
              emphasis: {
                areaColor: "#2d9eff", //懸浮區(qū)背景
                shadowColor: "rgba(20, 113, 255,1)",
                shadowOffsetX: -2,
                shadowOffsetY: 5,
                shadowBlur: 10,
              },
            },
          },
          //第一層投影
          {
            map: map,
            zlevel: -1,
            zoom: 1.22, //當(dāng)前視角的縮放比例
            roam: false, //是否開啟平游或縮放
            center: undefined,
            show: true,
            label: {
              normal: {
                show: false,
              },
              emphasis: {
                show: false,
              },
            },
            itemStyle: {
              normal: {
                borderJoin: "round",
                borderColor: "rgba(176,228,252,1)",
                borderWidth: 3,
                areaColor: "rgba(133,188,232,1)",
                shadowColor: "rgba(133,188,232,.7)",
                shadowOffsetX: 0,
                shadowOffsetY: 0,
                shadowBlur: 25,
              },
              emphasis: {
                show: false,
              },
            },
          },
          // 第二層投影
          {
            map: map,
            zlevel: -2,
            zoom: 1.2, //當(dāng)前視角的縮放比例
            roam: false, //是否開啟平游或縮放
            center: undefined,
            show: true,
            label: {
              normal: {
                show: false,
              },
              emphasis: {
                show: false,
              },
            },
            itemStyle: {
              normal: {
                borderJoin: "round",
                areaColor: "rgba(30,49,105,1)",
                shadowColor: "rgba(30,49,105,1)",
                shadowOffsetX: -5,
                shadowOffsetY: 6,
              },
              emphasis: {
                show: false,
              },
            },
          },
}

3、地圖海岸線

在echarts中regions是對特定的區(qū)域配置樣式,opacity中0的時(shí)候不會繪制該圖形,所以根據(jù)regions配置項(xiàng)來清除一部分圖形。這樣一來,直接在一個(gè)map上是不能實(shí)現(xiàn)海岸線效果的。那就需要兩個(gè)div地圖來實(shí)現(xiàn)海岸線效果。一層map是頂層的,完整數(shù)據(jù)的地圖,一層是去掉海岸想相關(guān)數(shù)據(jù)的地圖層。

// 首先把一部分圖形隱藏
regionsOption:[
    {
      name: "北京市",
      itemStyle: {
        // 隱藏地圖
        normal: {
          opacity: 0, // 為 0 時(shí)不繪制該圖形
        }
      },
      label: {
        show: false // 隱藏文字
      }
    },
    
    ......
 
    {
      name: "南海諸島",
      itemStyle: {
        // 隱藏地圖
        normal: {
          opacity: 0, // 為 0 時(shí)不繪制該圖形
        }
      },
      label: {
        show: false // 隱藏文字
      }
    },
  ]

完整的地圖數(shù)據(jù)我是從DataV.GeoAtlas下載的。

對某些省份圖形的隱藏之后,發(fā)現(xiàn),遼寧、廣西在海岸線中只占一部分,就不能根據(jù)隱藏圖形來實(shí)現(xiàn)了。但是可以修改地圖繪制的經(jīng)緯度,把遼寧、廣西的一部分經(jīng)緯度繪制去掉就可以得到下圖效果。 下載海岸線除去遼寧廣西部分經(jīng)緯度json數(shù)據(jù)

4、地圖中高亮顯示有數(shù)據(jù)的城市

數(shù)據(jù)高亮顯示,在地圖配置項(xiàng)series中data中設(shè)置itemStyle.areaColor。還可以加scatter,effectScatter都可以,根據(jù)需求來定。

// series-map.data.itemStyle地圖數(shù)據(jù)高亮顯示
var data = [
    { name: '天津', value: 4075, itemStyle: {areaColor: '#faa'} },
    { name: '湖北', value: 500, itemStyle: {areaColor: '#faa'} }
];
 
 
// series-effectScatter帶有漣漪特效動(dòng)畫的散點(diǎn)(氣泡)圖
// this.convertData() 的數(shù)據(jù)格式:根據(jù)獲取地圖的數(shù)據(jù),篩選出和data對應(yīng)的數(shù)據(jù),格式:[{name: 'name', value: 'value'}]
{
          type: "effectScatter",
          coordinateSystem: "geo",
          data: this.convertData(),
          // geoIndex:1,
          symbolSize: function (val) {
            return 10;
          },
          showEffectOn: "render",
          rippleEffect: {
            brushType: "stroke",
          },
          hoverAnimation: true,
          label: {
            normal: {
              formatter: "",
              position: "top",
              show: true,
              color: "#fff",
              fontSize: 10,
              fontWeight: 800,
            },
          },
          itemStyle: {
            normal: {
              color: "#fdfbcc",
              shadowBlur: 10,
              shadowColor: "#fdfbcc",
            },
          },
          zlevel: 1,
        },

5、滾動(dòng)高亮輪播

根據(jù)dispatchAction來設(shè)置地圖的配置項(xiàng),和定時(shí)器相結(jié)合來實(shí)現(xiàn)滾動(dòng)高亮顯示

// 設(shè)置鼠標(biāo)移入移出地圖以及點(diǎn)擊地圖
mounted() {
    this.$nextTick(() => {
      this.initEcharts();
      let that = this;
      this.chart.on("click", this.echartsMapClick);
      this.chart.on("mouseover", this.echartsMapMouseover);
      this.chart.on("mouseout", this.echartsMapMouseout);
    })
}
 
 
    // 地圖鼠標(biāo)移入事件
    echartsMapMouseover() {
      clearInterval(this.tooltipAutoplay);
    },
    // 地圖鼠標(biāo)移出事件
    echartsMapMouseout() {
      this.setTooltipAutoplay();
    },
    // 動(dòng)態(tài)顯示tooltip
    setTooltipAutoplay() {
      clearInterval(this.tooltipAutoplay);
      var index = 0; //播放所在下標(biāo)
      var itemIndexList = new Array(this.mapDataList.length); //固定數(shù)組長度為3
      for (var i = 0; i < itemIndexList.length; i++) {
        itemIndexList[i] = i;
      }
      this.tooltipAutoplay = setInterval(() => {
        this.chart.dispatchAction({
          type: "downplay",
          seriesIndex: 0,
          dataIndex: itemIndexList,
        });
        this.chart.dispatchAction({
          type: "showTip",
          seriesIndex: 0,
          dataIndex: this.tooltipAutoplayIndex,
        });
        this.chart.dispatchAction({
          type: "highlight",
          seriesIndex: 0,
          dataIndex: this.tooltipAutoplayIndex,
        });
        this.tooltipAutoplayIndex++;
        if (this.tooltipAutoplayIndex >= this.mapDataList.length) {
          this.tooltipAutoplayIndex = 0;
          this.setTooltipAutoplay();
        }
      }, 6666);
    },

總結(jié)

到此這篇關(guān)于echarts地圖設(shè)置背景圖片及海岸線的文章就介紹到這了,更多相關(guān)echarts地圖設(shè)置背景圖片 海岸線內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 原生js輪播特效

    原生js輪播特效

    這篇文章主要為大家詳細(xì)介紹了原生js輪播特效,簡單實(shí)用的代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • 淺談layui 數(shù)據(jù)表格前后臺傳值的問題

    淺談layui 數(shù)據(jù)表格前后臺傳值的問題

    今天小編就為大家分享一篇淺談layui 數(shù)據(jù)表格前后臺傳值的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-09-09
  • JavaScript實(shí)現(xiàn)二級菜單的制作

    JavaScript實(shí)現(xiàn)二級菜單的制作

    這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)二級菜單的制作,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • JS異步編程Promise對象詳解

    JS異步編程Promise對象詳解

    本文詳細(xì)講解了JS異步編程之Promise對象,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • 工作中常用js功能匯總

    工作中常用js功能匯總

    這篇文章主要介紹了一些工作中常用js功能的匯總,幫助大家提高工作效率,加深對js的理解,感興趣的朋友可以了解下
    2020-11-11
  • Javascript 遍歷頁面text控件詳解

    Javascript 遍歷頁面text控件詳解

    本篇文章主要是對Javascript遍歷頁面text控件進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-01-01
  • BootStrap Fileinput初始化時(shí)的一些參數(shù)

    BootStrap Fileinput初始化時(shí)的一些參數(shù)

    本文通過一個(gè)例子給大家簡單介紹了bootstrap fileinput初始化時(shí)的一些參數(shù),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下
    2016-12-12
  • JS顯示日歷和天氣的方法

    JS顯示日歷和天氣的方法

    這篇文章主要介紹了JS顯示日歷和天氣的方法,涉及JavaScript日期與時(shí)間的操作技巧,非常簡單實(shí)用,需要的朋友可以參考下
    2016-03-03
  • 利用javaScript實(shí)現(xiàn)點(diǎn)擊輸入框彈出窗體選擇信息

    利用javaScript實(shí)現(xiàn)點(diǎn)擊輸入框彈出窗體選擇信息

    這篇文章主要是對利用javaScript實(shí)現(xiàn)點(diǎn)擊輸入框彈出窗體選擇信息進(jìn)的實(shí)例行了詳細(xì)的介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2013-12-12
  • element-plus 官方表格排序問題小結(jié)

    element-plus 官方表格排序問題小結(jié)

    在使用Element Plus官方API時(shí),表格默認(rèn)排序可能會遇到問題,一個(gè)列表可能被多次排序影響數(shù)據(jù)展示,解決方法是修改useSortTable.js文件,這樣可以確保表格按預(yù)期正確排序,更多詳情可查閱相關(guān)的技術(shù)文檔或資源
    2024-10-10

最新評論