apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.6k stars 19.62k forks source link

GitHub中下载的map上海市的json地图不能显示,其他省都没啥问题 #7288

Closed zhangqixu closed 4 years ago

zhangqixu commented 6 years ago

One-line summary [问题简述]

GitHub中下载的shanghai.json地图不能显示,其他省都没啥问题,其他几个直辖市都能显示(例如:重庆,天津)

Version & Environment [版本及环境]

Expected behaviour [期望结果]

能正常显示上海市的地图;

ECharts option [ECharts配置项]

var province = {
            "北京": "beijing", "重庆": "chongqing", "上海": "shanghai", "天津": "tianjin", "澳门": "aomen", "香港": "xianggang", "台湾": "taiwan",
            "安徽": "anhui", "福建": "fujian", "甘肃": "gansu", "广东": "guangdong", "广西": "guangxi", "贵州": "guizhou", "海南": "hainan", "河北": "hebei", "黑龙江": "heilongjiang", "河南": "henan", "湖北": "hubei", "湖南": "hunan", "江苏": "jiangsu", "江西": "jiangxi", "吉林": "jilin", "辽宁": "liaoning", "内蒙古": "neimenggu", "宁夏": "ningxia", "青海": "qinghai", "山东": "shandong", "山西": "shanxi", "陕西": "shanxi1", "四川": "sichuan", "新疆": "xinjiang", "西藏": "xizang", "云南": "yunnan", "浙江": "zhejiang"
        }
        myChart.on("click", function (param) {
            var prov = province[param.name];
            var provname = param.name;
            //if (param.value > 0) {

            //} else {
            //    layer.msg(param.name + '暂无数据', { icon: 2, time: 1000 });
            //    return
            //}
            $.getJSON("./js/province/" + prov + ".json", function (chinaJson) {
                myChart.clear();
                echarts.registerMap(prov, chinaJson);
                option = {
                    color: ["#0099ff", "#C23531"],
                    title: {
                        text: provname + '项目分布',
                        left: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: function (params) {
                            if (params.value>0) {
                                var undomile = params.value - params.data.value;
                                return "完成里程:" + params.data.value + "<br />未完成里程:" + undomile + "<br />" + params.name + ":" + params.value;
                            } else {
                                return params.name+":暂无数据"
                            }
                        }
                    },
                    legend: {
                        orient: 'vertical',
                        left: 'left',
                        data: ['完成里程', '未完成里程']
                    },
                    visualMap: {
                        min: 0,
                        max: 2500,
                        left: 'left',
                        top: 'bottom',
                        text: ['高', '低'],           // 文本,默认为数值文本
                        calculable: true,
                        color: ["#003300", "#99CCFF"],
                    },
                    toolbox: {
                        show: true,
                        orient: 'vertical',
                        top: 'center',
                        right: "20",
                        feature: {
                            myTool: {
                                show: true,
                                title: '返回全国',
                                icon: '',
                                onclick: function () {
                                    myChart.clear();
                                    chinaMap(echart_map[0]);
                                }
                            },
                            dataView: { readOnly: false },
                            restore: {},
                            saveAsImage: {}
                        }
                    },
                    series: [
                        {
                            name: '完成里程',
                            type: 'map',
                            map: prov,
                            label: {
                                normal: {
                                    show: true
                                },
                                emphasis: {
                                    show: true
                                }
                            },
                            itemStyle: {
                                normal: {//336699#
                                    borderColor: "#000",//FBBF45
                                    areaColor: "#99CCFF",
                                    show: true
                                },
                            },
                            zoom:1,
                            roam: true,
                            scaleLimit: {
                                min: 1,
                                max:5
                            },
                            data: [
                                { name: "荆州市", value: "900", }
                            ],
                        },
                        {
                            name: '未完成里程',
                            type: 'map',
                            map: prov,
                            label: {
                                normal: {
                                    show: true
                                },
                                emphasis: {
                                    show: true
                                }
                            },
                            itemStyle: {
                                normal: {//336699#
                                    borderColor: "#000",//FBBF45
                                    areaColor: "#99CCFF",
                                    show: true
                                },
                            },
                            zoom: 1,
                            roam: true,
                            scaleLimit: {
                                min: 1,
                                max: 5
                            },
                            data: [
                                { name: "荆州市", value: "200", }
                            ],
                        }
                    ]
                }

                myChart.setOption(option);
            })
        })

Other comments [其他信息]

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.