gpt4 book ai didi

javascript - HighMaps 不显示国家数据

转载 作者:行者123 更新时间:2023-11-30 19:28:29 25 4
gpt4 key购买 nike

我正在使用 Highcharts Js 来显示 Highmaps map 气泡数据。但问题是图表没有在科索沃国家绘制泡沫。例如如果我有如下 JSON 数据。

[
{"Country":"kosovo","persons":"2","CountryCode":"XK"},
{"Country":"india","persons":"2","CountryCode":"IN"}
]

map 显示时仅包含印度国家/地区数据。没有显示任何科索沃国家。

enter image description here

这是我使用的 Javascript:

var data_country = [{"Country":"kosovo","persons":"2","CountryCode":"XK"}, 
{"Country":"india","persons":"2","CountryCode":"IN"}
] ;
data_country = data_country.map(function(el){
return {name: el.Country, z: parseInt(el.persons), 'iso-a2': el.CountryCode}
})

Highcharts.mapChart('world-map', {
chart: {
plotBorderWidth: 1,
plotBorderColor: '#ffffff',
borderColor: "#ffffff",
plotBackgroundColor: '#FFFFff',
map: 'custom/world'
},

title: {
text: "" ,
enabled: false
},

credits: {
enabled: false
},
exporting:{
enabled: false
},
legend: {
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
name: 'Countries',
color: '#E0E0E0',

states: {
inactive: {
opacity: 1
}
},
enableMouseTracking: false
}, {
type: 'mapbubble',
name: '',
joinBy: 'iso-a2',//'iso-a3', 'code3'],
data: data_country,
minSize: '4%',
color: '#577ba8',
marker: {
fillOpacity: 0.9
},
maxSize: '4%',
tooltip: {
pointFormat: '{point.properties.name}'
}
}]
});

请告诉我是否遗漏了什么或者这是 Highmaps 错误。

最佳答案

我看到您使用的是非官方国家代码,因为它没有官方 ISO 国家代码:

The unofficial 2 and 3-digit codes are used by the European Commission and others until Kosovo is assigned an ISO code.

我还看到在 Highmaps 中使用 KV 似乎可行。我不确定他们为什么使用这个部分国家代码。例如,您的代码 ( JSFiddle ):

var data_country = [{"Country":"kosovo","persons":"2","CountryCode":"KV"}, 
{"Country":"india","persons":"2","CountryCode":"IN"}
];
data_country = data_country.map(function(el){
return {name: el.Country, z: parseInt(el.persons), 'iso-a2': el.CountryCode}
});

关于javascript - HighMaps 不显示国家数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56680363/

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