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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用echarts简单制作中国地图

發(fā)布時(shí)間:2024/3/26 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用echarts简单制作中国地图 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

網(wǎng)站需要一張中國地圖,并且鼠標(biāo)經(jīng)過某個(gè)省份,該省份的省份名字顯示,而且該省份的地區(qū)會(huì)變色顯示。

第一種方法:

將每個(gè)省份的圖片定位(先隱藏),拼合成一張中國地圖,然后再定位省份名稱,鼠標(biāo)經(jīng)過省份名字,添加hover事件,將對(duì)應(yīng)圖片顯示。

第二種方法:

使用圖形插件echarts,輕松制作。

http://echarts.baidu.com/doc/example.html在echarts網(wǎng)站上下載文件包

echarts使用方法查看頁面

http://echarts.baidu.com/doc/doc.html#%E5%BC%95%E5%85%A5ECharts3

可以在網(wǎng)站上調(diào)整好需要的樣式再放到本地看效果


自己試驗(yàn)的demo如下:

<!doctype html>
<html>

<head>
??? <meta charset="utf-8">
??? <title>echarts圖形插件使用</title>

</head>

<body>
??? <div id="main" style="height:800px;"></div>
??? <script type="text/javascript" src="js/echarts-all.js"></script>
??? <script type="text/javascript">
??????? var myChart = echarts.init(document.getElementById('main'));
??????? var option = {
??????????? series: [
??????????????? {
??????????????????? name: 'Map',
??????????????????? type: 'map',
??????????????????? mapLocation: {
??????????????????????? x: 'left',
??????????????????????? y: 'top',
??????????????????????? height: 500
??????????????????? },
??????????????????? selectedMode: 'multiple',
??????????????????? itemStyle: {
??????????????????????? normal: {
??????????????????????????? borderWidth: 2,
??????????????????????????? borderColor: 'lightgreen',
??????????????????????????? color: 'orange',
??????????????????????????? label: {
??????????????????????????????? show: false
??????????????????????????? }
??????????????????????? },
??????????????????????? emphasis: { // 也是選中樣式
??????????????????????????? borderWidth: 2,
??????????????????????????? borderColor: '#fff',
??????????????????????????? color: '#32cd32',
??????????????????????????? label: {
??????????????????????????????? show: true,
??????????????????????????????? textStyle: {
??????????????????????????????????? color: '#fff'
??????????????????????????????? }
??????????????????????????? }
??????????????????????? }
??????????????????? },
??????????????????? data: [
??????????????????????? {
??????????????????????????? name: '廣東',
??????????????????????????? value: Math.round(Math.random() * 1000),
??????????????????????????? itemStyle: {
??????????????????????????????? normal: {
??????????????????????????????????? color: '#32cd32',
??????????????????????????????????? label: {
??????????????????????????????????????? show: true,
??????????????????????????????????????? textStyle: {
??????????????????????????????????????????? color: '#fff',
??????????????????????????????????????????? fontSize: 15
??????????????????????????????????????? }
??????????????????????????????????? }
??????????????????????????????? },
??????????????????????????????? emphasis: { // 也是選中樣式
??????????????????????????????????? borderWidth: 5,
??????????????????????????????????? borderColor: 'yellow',
??????????????????????????????????? color: '#cd5c5c',
??????????????????????????????????? label: {
??????????????????????????????????????? show: false,
??????????????????????????????????????? textStyle: {
??????????????????????????????????????????? color: 'blue'
??????????????????????????????????????? }
??????????????????????????????????? }
??????????????????????????????? }
??????????????????????????? }
??????????????? }
??????????? ],
??????????????????? markPoint: {
??????????????????????? itemStyle: {
??????????????????????????? normal: {
??????????????????????????????? color: 'skyblue'
??????????????????????????? }
??????????????????????? },
??????????????????????? data: [
??????????????????????????? {
??????????????????????????????? name: '天津',
??????????????????????????????? value: 350
??????????????????????????? },
??????????????????????????? {
??????????????????????????????? name: '上海',
??????????????????????????????? value: 103
??????????????????????????? },
??????????????????????????? {
??????????????????????????????? name: 'echarts',
??????????????????????????????? symbol: 'image://../asset/img/echarts-logo.png',
??????????????????????????????? symbolSize: 21,
??????????????????????????????? x: 300,
??????????????????????????????? y: 100
??????????????????? }
??????????????? ]
??????????????????? },
??????????????????? geoCoord: {
??????????????????????? '上海': [121.4648, 31.2891],
??????????????????????? '天津': [117.4219, 39.4189]
??????????????????? }
??????? }
??? ]
??????? }
??????? myChart.setOption(option);
??? </script>
</body>

</html>

效果圖如下:



總結(jié)

以上是生活随笔為你收集整理的使用echarts简单制作中国地图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。