1

我使用了 highcharts 网站上的演示示例,唯一的修改是:

  • 将地图更改为 world.js
  • 评论“allAreas”属性

$(function () {


    // Instanciate the map
    $('#container').highcharts('Map', {
        chart: {
            spacingBottom: 20
        },
        title : {
            text : 'Europe time zones'
        },

        legend: {
            enabled: true
        },

        plotOptions: {
            map: {
                //allAreas: false,
                joinBy: ['iso-a2', 'code'],
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    formatter: function () {
                        if (this.point.properties && this.point.properties.labelrank.toString() < 5) {
                            return this.point.properties['iso-a2'];
                        }
                    },
                    format: null,
                    style: {
                        fontWeight: 'bold'
                    }
                },
                mapData: Highcharts.maps['custom/world'],
                tooltip: {
                    headerFormat: '',
                    pointFormat: '{point.name}: <b>{series.name}</b>'
                }

            }
        },

        series : [{
            name: 'UTC',
            id: 'UTC',
            data: $.map(['IE', 'IS', 'GB', 'PT'], function (code) {
                return { code: code };
            })
        }, {
            name: 'UTC + 1',
            data: $.map(['NO', 'SE', 'DK', 'DE', 'NL', 'BE', 'LU', 'ES', 'FR', 'PL', 'CZ', 'AT', 'CH', 'LI', 'SK', 'HU',
                    'SI', 'IT', 'SM', 'HR', 'BA', 'YF', 'ME', 'AL', 'MK'], function (code) {
                return { code: code };
            })
        }, {
            name: 'UTC + 2',
            data: $.map(['FI', 'EE', 'LV', 'LT', 'BY', 'UA', 'MD', 'RO', 'BG', 'GR', 'TR', 'CY'], function (code) {
                return { code: code };
            })
        }, {
            name: 'UTC + 3',
            data: $.map(['RU'], function (code) {
                return { code: code };
            })
        }]
    });
});

JSFiddle中的代码 为什么只有单个系列可见?

4

1 回答 1

1

导致问题的行是这样的://allAreas: false.

这是解释以及如何修复它(摘自 Highcharts 支持论坛)

根据 API,设置allAreastrue将呈现所有区域,以及没有值的区域(作为空值)。另一个选项是nullColor默认情况下是灰色阴影,并设置空值使用的颜色。

因此,如果您设置allAreastrue,则每个系列将绘制所有区域,而具有空值的区域将填充为灰色( nullColor)。因为后面的系列有更高的z-index这些在其他系列的顶部,导致灰色的形状覆盖了它下面的形状。

如果要设置allAreastrue但仍能看穿不同的系列,则必须将其设置nullColor为透明:

rgba(0,0,0,0)

在这里工作 JSFiddle

于 2015-01-07T03:49:37.890 回答