如标题所示我想使用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的值。
如果有人可以伸出援助之手,我们将不胜感激。 感谢。答案 0 :(得分:0)
您应该使用两个数据样本:
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]+')');
}