1
问题是关于如何在Highmaps的世界地图中创建自定义数据标签like here。我想为我绘制为mappoint
的pointData数据标签。 到目前为止,我有我的地图配置高地图:世界地图上的自定义数据标签
{
title: {
text: 'Test map'
},
tooltip: {
enabled: true
},
mapNavigation: {
enabled: true
},
series: [
{
mapData: Highcharts.maps["custom/world"],
data: countryData,
joinBy: ['hc-key', 'key'],
name: "Country Info",
states: {
hover: {
color: "#00b700"
}
},
tooltip: {
headerFormat: '',
pointFormat: '{point.name}'
},
dataLabels: {
enabled: true,
formatter: function() {
return this.point.name;
}
},
point: {
events: {
click() {
console.log("Code : ", this.key)
}
}
}
},{
type: 'mappoint',
mapData: Highcharts.maps["custom/world"],
data: pointData,
name: 'Point Info',
states: {
hover: {
color: "#abb700"
}
},
tooltip: {
headerFormat: '',
pointFormat: '{point.location}'
},
dataLabels: {
enabled: true,
formatter: function() {
return this.point.name;
}
},
point: {
events: {
click() {
console.log("Code : ", this.options.countryCode)
}
}
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'bottom'
}
}
]
}
和数据,我送入是:
1)countryData:
[
{
"key": "in",
"index": 2
},
{
"key": "us",
"index": 2
}
]
2)pointData
[
{
"countryCode": "in",
"site_id": 3,
"center_count": 2,
"location": "(Ahmedabad,India,APAC)",
"headcount": 600,
"lat": 23.022505,
"lon": 72.5713621
},
{
"countryCode": "us",
"site_id": 4,
"center_count": 2,
"location": "(Arcadia,Greece,EMEA)",
"headcount": 700,
"lat": 34.1397292,
"lon": -118.0353449
}
]
注:为简洁起见,一些变量已被替换为值。