Error: [REQUIRE_FATAL]Relative ID is not allowed in global require: ../echarts/src/config

豬兒 发布于 2014/04/29 19:30
阅读 2K+
收藏 0

@Kener-林峰 你好,想跟你请教个问题:


<script type="text/javascript">
    require.config({
        paths: {
            echarts: '../echarts/echarts',
            'echarts/chart/map': '../echarts/echarts-map'
        }
    });

    option = {
        tooltip: {
            trigger: 'item',
            formatter: '{b}'
        },
        series: [
        {
            name: '中国',
            type: 'map',
            mapType: 'china',
            selectedMode: 'multiple',
            itemStyle: {
                normal: { label: { show: true } },
                emphasis: { label: { show: true }, color: '32cd32' }
            },
            data: [
                { name: '广东', selected: true }
            ]
        }
    ]
    };
    /*  底下这段代码不写   地图可以显示  没问题  加了这段代码  就有问题   但是我要获取当前点击的是那个省份  所以要加这段代码 来获取事件的参数    */
    var ecConfig = require('../echarts/src/config');
    myChart.on(ecConfig.EVENT.MAP_SELECTED, function (param) {
        var selected = param.selected;
        var str = '';
        for (var p in selected) {
            if (selected[p]) {
                str += p;
            }
        }
        window.location.href = "htpp://www.baidu.com?province=" + str;
    })
    require(
             [
               'echarts',
               'echarts/chart/map'
            ],

            function (ec) {
                var myChart = ec.init(document.getElementById('main'));
                myChart.setOption(option);
            }
       );
    
       </script>

返回顶部
顶部