gpt4 book ai didi

css - 更改 jvectormap 负值颜色

转载 作者:行者123 更新时间:2023-11-28 08:05:51 26 4
gpt4 key购买 nike

默认情况下,当我的 jvectormap 中有负值时,它将国家/地区着色为黑色(检查国家/地区元素时我看到以下“填充”值:#000NaN)。我想改变这种颜色。我该怎么做?

编辑:这很老套,但我通过循环国家和检查黑色来更新黑色的国家颜色。代码如下:

        try {
map = elVectorMap.vectorMap('get', 'mapObject');
map.series.regions[0].setValues(data);
} catch (e) {
var vectorMapOptions = {
map: 'world_mill_en',
backgroundColor: '#ffffff',
regionStyle: {
initial: {
fill: '#aac5e1'
}
},
series: {
regions: [{
values: data,
scale: ['#aac5e1', '#0e569f'],
normalizeFunction: 'polynomial'
}]
}
};
elVectorMap.vectorMap(vectorMapOptions);
}

// Change the color of negative value countries from black to red
elVectorMap.find('.jvectormap-element[fill="#000NaN"]').each(function(){
$(this).css('fill', '#ffcfcd');
});

最佳答案

使用此归一化函数代替“多项式”或“线性”值

normalizeFunction: function(value) {
if (value < 0)
return - Math.pow(Math.abs(value), 0.2)
return Math.pow(value, 0.2);
},

关于css - 更改 jvectormap 负值颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29495649/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com