繁体   English   中英

如何更改高图泡泡颜色

[英]How to change highmap bubble color

我试图根据城市名称为气泡着色。 像是this.point.capital == Montgomery&this.point.capital == Juneau; color =“red”。 但我无法将此函数添加到color属性中。 你能帮我吗?

谢谢!!!!

series: [{
            name: 'Basemap',
            mapData: map,
            borderColor: '#606060',
            nullColor: 'rgba(200, 200, 200, 0.2)',
            showInLegend: false
        }, {
            name: 'Separators',
            type: 'mapline',
            data: H.geojson(map, 'mapline'),
            color: '#101010',
            enableMouseTracking: false
        }, {
            type: 'mapbubble',
            dataLabels: {
                enabled: true,
                format: '{point.capital}'
            },
            name: 'Cities',
            data: data,
            maxSize: '12%',
            color: H.getOptions().colors[0]
        }]

http://jsfiddle.net/oufwhmz0/

在启动图表之前,在data阵列中单独为每个气泡(不是整个系列)执行此操作。 例如扩展你的代码( JSFiddle ):

function determineColor(entry) {
    if(entry.capital == "Montgomery")
        return "#FF00FF";
    else if(entry.capital == "Salt Lake City")
        return "#00FF00";
    return null;
}

// Add series with state capital bubbles
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=us-capitals.json&callback=?', function (json) {
    var data = [];
    $.each(json, function (ix, entry) {
        entry.z = entry.population;
        entry.color = determineColor(entry); // Added
        data.push(entry);
    });

    // ... rest as usual
});

这只是设置每个entrycolor (它将是一个气泡),由determineColor函数定义。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM