【问题标题】:Highcharts + Highmaps module not workingHighcharts + Highmaps 模块不工作
【发布时间】:2015-12-04 19:43:05
【问题描述】:

我正在尝试复制 Highmaps 演示 › 地图气泡,但我想将其他图表添加到同一页面。当我加载 Highcharts 脚本和 Highmaps 模块脚本时,图表不会呈现。浏览器抛出一般错误。示例见 jsfiddle。

https://jsfiddle.net/hkjbn6wg/1/

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/maps/modules/map.js"></script>
<script src="http://code.highcharts.com/maps/modules/data.js"></script>
<script src="http://code.highcharts.com/mapdata/custom/world.js"></script>

<div id="container" style="height: 500px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>

$(function () {

    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=world-population.json&callback=?', function (data) {

        var mapData = Highcharts.geojson(Highcharts.maps['custom/world']);

        // Correct UK to GB in data
        $.each(data, function () {
            if (this.code === 'UK') {
                this.code = 'GB';
            }
        });

        $('#container').highcharts('Map', {
            chart : {
                borderWidth : 1
            },

            title: {
                text: 'World population 2013 by country'
            },

            subtitle : {
                text : 'Demo of Highcharts map with bubbles'
            },

            legend: {
                enabled: false
            },

            mapNavigation: {
                enabled: true,
                buttonOptions: {
                    verticalAlign: 'bottom'
                }
            },

            series : [{
                name: 'Countries',
                mapData: mapData,
                color: '#E0E0E0',
                enableMouseTracking: false
            }, {
                type: 'mapbubble',
                mapData: mapData,
                name: 'Population 2013',
                joinBy: ['iso-a2', 'code'],
                data: data,
                minSize: 4,
                maxSize: '12%',
                tooltip: {
                    pointFormat: '{point.code}: {point.z} thousands'
                }
            }]
        });

    });
});

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    错误被打印出来,因为你错过了 highcharts-more.js 文件。

    添加对该文件的引用,示例将起作用。

    <script src="http://code.highcharts.com/highcharts-more.js"></script>
    

    http://jsfiddle.net/hkjbn6wg/2/

    【讨论】:

    • 效果很好。你能指点我那个文件的文档吗?我不知道我是怎么错过的。谢谢!
    • 在控制台(开发人员工具)中,您会收到错误消息。只有您需要在此链接内单击以检查 highcharts 有什么问题。
    猜你喜欢
    • 2021-10-09
    • 2014-06-14
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-02
    • 2017-01-01
    • 1970-01-01
    相关资源
    最近更新 更多