正如标题所说,我想使用JVectorMap和颜色区域与一组数据,但显示另一个值的标签
$(function(){
$('#world-map-gdp').vectorMap({
map: 'world_mill_en',
backgroundColor: 'transparent',
series: {
regions: [{
values: gdpData,
scale: ['#FFDD00', '#FF0000'],
normalizeFunction: 'polynomial'
}]
},
onRegionLabelShow: function(e, label, code){
label.html(label.html()+' (U.S. troops present are '+gdpData[code]+')');
}
});
});
那么这是我调用的数据示例
var gdpData = {
"US" :3011302, 75,
"IQ" :0, 74,
"IR" :0, 73,
"IF" :0, 72,
"JP" :54437, 71,
"DE" :49104, 70,
"GB" :13062, 69,
"IT" :11963, 68,
所以基本上我想使用刻度上的值 75 为美国着色,并在将鼠标悬停在 3011302 上时显示 的值。
如果有人能伸出援手,将不胜感激。谢谢。
您应该使用两个数据样本:
var dataForLabel = {
"US" :3011302,
"IQ" :0,
"IR" :0,
"IF" :0,
"JP" :54437,
"DE" :49104,
"GB" :13062,
"IT" :11963 }
var dataForScale = {
"US" :75,
"IQ" :74,
"IR" :73,
"IF" :72,
"JP" :71,
"DE" :70,
"GB" :69,
"IT" :68 }
然后
regions: [{
values: dataForScale,
//...
和
onRegionLabelShow: function(e, label, code){
label.html(label.html()+' (U.S. troops present are '+dataForLabel[code]+')');
}