zoukankan      html  css  js  c++  java
  • 1、ECharts(中国地图篇)的使用

    一、
    网址:            http://echarts.baidu.com/download.html
    点击:            完整
    下载文件:        echarts.min.js

    网址:            http://echarts.baidu.com/download-map.html
    点击:            中国地图 - JS
    下载文件:        china.js

    二、代码示例

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <meta http-equiv="X-UA-Compatible" content="IE=EDGE">
            <title>ECharts</title>
            <link rel="stylesheet" type="text/css" href="css/main.css"/>
            <script src="js/jquery-1.9.1.min.js"></script>
            <script src="js/echarts.min.js"></script>
            <script src="js/china.js"></script>
            <style>#china-map {width:1000px; height: 1000px;margin: auto;}</style>
        </head>
        <body>        
    
            <div id="china-map"></div>
            
            <script>
                var myChart = echarts.init(document.getElementById('china-map'));
                var option = {
                    tooltip: {
    //                    show: false //不显示提示标签
                        formatter: '{b}', //提示标签格式
                        backgroundColor:"#ff7f50",//提示标签背景颜色
                        textStyle:{color:"#fff"} //提示标签字体颜色
                    },
                    series: [{
                        type: 'map',
                        mapType: 'china',
                        label: {
                            normal: {
                                show: true,//显示省份标签
                                textStyle:{color:"#c71585"}//省份标签字体颜色
                            },    
                            emphasis: {//对应的鼠标悬浮效果
                                show: true,
                                textStyle:{color:"#800080"}
                            } 
                        },
                        itemStyle: {
                            normal: {
                                borderWidth: .5,//区域边框宽度
                                borderColor: '#009fe8',//区域边框颜色
                                areaColor:"#ffefd5",//区域颜色
                            },
                            emphasis: {
                                borderWidth: .5,
                                borderColor: '#4b0082',
                                areaColor:"#ffdead",
                            }
                        },
                        data:[
                            {name:'福建', selected:true}//福建为选中状态
                        ]
                    }],
                };
                
                myChart.setOption(option);
                myChart.on('mouseover', function (params) {
                    var dataIndex = params.dataIndex;
                    console.log(params);
                });
            </script>
            
        </body>
    </html>

    三、效果图


    四、修改省份标签位置:
    打开china.js文件,修改"properties":{"cp":[X坐标,Y坐标],...}

  • 相关阅读:
    legend3---videojs存储视频的播放速率便于用户观看视频
    legend3---mathjax的动态渲染问题解决
    matplotlib库疑难问题---10、画直方图
    matplotlib库疑难问题---9、画箭头(综合实例)
    js释放图片资源
    javascript中的原型与原型链
    前端跨域方式
    matplotlib清除 axes 和 figure
    matplotlib画直方图细解
    CentOS 7.8 安装 Python 3.8.5
  • 原文地址:https://www.cnblogs.com/xianwen/p/6045454.html
Copyright © 2011-2022 走看看