echarts报错Cannot read property 'features' of undefined

Posted zhzhang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了echarts报错Cannot read property 'features' of undefined相关的知识,希望对你有一定的参考价值。

引入地图的时候

echarts2报错:

Uncaught Error: [MODULE_MISS]"echarts/src/util/mapData/params" is not exists!

原因不明,但是感觉和缺js文件有关(因为echarts3报错就是因为缺少了world.js)

 

echarts3报错:

Uncaught TypeError: Cannot read property \'features\' of undefined

原因如下:缺少world.js,然后成功:

完成以上功能的代码如下:

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>世界地图-ECharts</title>
        <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="../js/tld/echarts3.min.js"></script>
        <script type="text/javascript" src="../js/tld/world.echarts.js"></script>
    </head>

    <body>

        <div id="main" style="width:100%;height:400px;"></div>
        <script type="text/javascript">
            // 基于准备好的dom,初始化echarts实例
            var myChart = echarts.init(document.getElementById(\'main\'));

            // 指定图表的配置项和数据
            var option = {
                title: {
                    text: \'World Population (2010)\',
                    subtext: \'from United Nations, Total population, both sexes combined, as of 1 July (thousands)\',
                    sublink: \'http://esa.un.org/wpp/Excel-Data/population.htm\',
                    left: \'center\',
                    top: \'top\'
                },
                tooltip: {
                    trigger: \'item\',
                    formatter: function(params) {
                        var value = (params.value + \'\').split(\'.\');
                        value = value[0].replace(/(\\d{1,3})(?=(?:\\d{3})+(?!\\d))/g, \'$1,\') +
                            \'.\' + value[1];
                        return params.seriesName + \'<br/>\' + params.name + \' : \' + value;
                    }
                },
                toolbox: {
                    show: true,
                    orient: \'vertical\',
                    left: \'right\',
                    top: \'center\',
                    feature: {
                        dataView: {
                            readOnly: false
                        },
                        restore: {},
                        saveAsImage: {}
                    }
                },
                visualMap: {
                    min: 0,
                    max: 1000000,
                    text: [\'High\', \'Low\'],
                    realtime: false,
                    calculable: true,
                    color: [\'orangered\', \'yellow\', \'lightskyblue\']
                },
                series: [{
                    name: \'World Population (2010)\',
                    type: \'map\',
                    mapType: \'world\',
                    roam: true,
                    itemStyle: {
                        emphasis: {
                            label: {
                                show: true
                            }
                        }
                    },
                    data: [{
                        name: \'Afghanistan\',
                        value: 28397.812
                    }, {
                        name: \'Angola\',
                        value: 19549.124
                    }, {
                        name: \'Albania\',
                        value: 3150.143
                    }, {
                        name: \'United Arab Emirates\',
                        value: 8441.537
                    }, {
                        name: \'Argentina\',
                        value: 40374.224
                    }, {
                        name: \'Armenia\',
                        value: 2963.496
                    }, {
                        name: \'French Southern and Antarctic Lands\',
                        value: 268.065
                    }, {
                        name: \'Australia\',
                        value: 22404.488
                    }, {
                        name: \'Austria\',
                        value: 8401.924
                    }, {
                        name: \'Azerbaijan\',
                        value: 9094.718
                    }, {
                        name: \'Burundi\',
                        value: 9232.753
                    }, {
                        name: \'Belgium\',
                        value: 10941.288
                    }, {
                        name: \'Benin\',
                        value: 9509.798
                    }, {
                        name: \'Burkina Faso\',
                        value: 15540.284
                    }, {
                        name: \'Bangladesh\',
                        value: 151125.475
                    }, {
                        name: \'Bulgaria\',
                        value: 7389.175
                    }, {
                        name: \'The Bahamas\',
                        value: 66402.316
                    }, {
                        name: \'Bosnia and Herzegovina\',
                        value: 3845.929
                    }, {
                        name: \'Belarus\',
                        value: 9491.07
                    }, {
                        name: \'Belize\',
                        value: 308.595
                    }, {
                        name: \'Bermuda\',
                        value: 64.951
                    }, {
                        name: \'Bolivia\',
                        value: 716.939
                    }, {
                        name: \'Brazil\',
                        value: 195210.154
                    }, {
                        name: \'Brunei\',
                        value: 27.223
                    }, {
                        name: \'Bhutan\',
                        value: 716.939
                    }, {
                        name: \'Botswana\',
                        value: 1969.341
                    }, {
                        name: \'Central African Republic\',
                        value: 4349.921
                    }, {
                        name: \'Canada\',
                        value: 34126.24
                    }, {
                        name: \'Switzerland\',
                        value: 7830.534
                    }, {
                        name: \'Chile\',
                        value: 17150.76
                    }, {
                        name: \'China\',
                        value: 1359821.465
                    }, {
                        name: \'Ivory Coast\',
                        value: 60508.978
                    }, {
                        name: \'Cameroon\',
                        value: 20624.343
                    }, {
                        name: \'Democratic Republic of the Congo\',
                        value: 62191.161
                    }, {
                        name: \'Republic of the Congo\',
                        value: 3573.024
                    }, {
                        name: \'Colombia\',
                        value: 46444.798
                    }, {
                        name: \'Costa Rica\',
                        value: 4669.685
                    }, {
                        name: \'Cuba\',
                        value: 11281.768
                    }, {
                        name: \'Northern Cyprus\',
                        value: 1.468
                    }, {
                        name: \'Cyprus\',
                        value: 1103.685
                    }, {
                        name: \'Czech Republic\',
                        value: 10553.701
                    }, {
                        name: \'Germany\',
                        value: 83017.404
                    }, {
                        name: \'Djibouti\',
                        value: 834.036
                    }, {
                        name: \'Denmark\',
                        value: 5550.959
                    }, {
                        name: \'Dominican Republic\',
                        value: 10016.797
                    }, {
                        name: \'Algeria\',
                        value: 37062.82
                    }, {
                        name: \'Ecuador\',
                        value: 15001.072
                    }, {
                        name: \'Egypt\',
                        value: 78075.705
                    }, {
                        name: \'Eritrea\',
                        value: 5741.159
                    }, {
                        name: \'Spain\',
                        value: 46182.038
                    }, {
                        name: \'Estonia\',
                        value: 1298.533
                    }, {
                        name: \'Ethiopia\',
                        value: 87095.281
                    }, {
                        name: \'Finland\',
                        value: 5367.693
                    }, {
                        name: \'Fiji\',
                        value: 860.559
                    }, {
                        name: \'Falkland Islands\',
                        value: 49.581
                    }, {
                        name: \'France\',
                        value: 63230.866
                    }, {
                        name: \'Gabon\',
                        value: 1556.222
                    }, {
                        name: \'United Kingdom\',
                        value: 62066.35
                    }, {
                        name: \'Georgia\',
                        value: 4388.674
                    }, {
                        name: \'Ghana\',
                        value: 24262.901
                    }, {
                        name: \'Guinea\',
                        value: 10876.033
                    }, {
                        name: \'Gambia\',
                        value: 1680.64
                    }, {
                        name: \'Guinea Bissau\',
                        value: 10876.033
                    }, {
                        name: \'Equatorial Guinea\',
                        value: 696.167
                    }, {
                        name: \'Greece\',
                        value: 11109.999
                    }, {
                        name: \'Greenland\',
                        value: 56.546
                    }, {
                        name: \'Guatemala\',
                        value: 14341.576
                    }, {
                        name: \'French Guiana\',
                        value: 231.169
                    }, {
                        name: \'Guyana\',
                        value: 786.126
                    }, {
                        name: \'Honduras\',
                        value: 7621.204
                    }, {
                        name: \'Croatia\',
                        value: 4338.027
                    }, {
                        name: \'Haiti\',
                        value: 9896.4
                    }, {
                        name: \'Hungary\',
                        value: 10014.633
                    }, {
                        name: 解决vue3中使用echart echart报错:Cannot read properties of undefined (reading ‘type‘)

echarts js报错 Cannot read property 'getAttribute' of null

Echarts报错 Cannot read property ‘init’ of undefined

在vue中使用echarts报错"TypeError: Cannot read property 'getAttribute' of null

Echarts 明明和官方文档配置一致,图表加载却是报错:Error in mounted hook: "TypeError: Cannot read property 'get&#

java中echarts关系图中如何引用dataTool:Uncaught TypeError: Cannot read property 'gexf' of undefined