Highcharts Highmaps:如何更改州的名称
我需要更改Highmaps地图集合中此地图中的州名称。具体来说,我需要将“Distrito Federal”的名称更改为“CDMX”。在系列数据中,这是一个点:['mx-df',10]。我到处寻找答案,但我不知道怎么做。有人能帮忙吗 这里有一个指向JSFIDLE的链接: 以下是HTML:Highcharts Highmaps:如何更改州的名称,highcharts,Highcharts,我需要更改Highmaps地图集合中此地图中的州名称。具体来说,我需要将“Distrito Federal”的名称更改为“CDMX”。在系列数据中,这是一个点:['mx-df',10]。我到处寻找答案,但我不知道怎么做。有人能帮忙吗 这里有一个指向JSFIDLE的链接: 以下是HTML: <script src="https://code.highcharts.com/maps/highmaps.js"></script> <script src="https://
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/mapdata/countries/mx/mx-all.js"></script>
<div id="container"></div>
您可以使用
formatter
功能更改工具提示和数据标签中显示的信息:
series: [{
...,
dataLabels: {
enabled: true,
formatter: function() {
if (this.point['hc-key'] === 'mx-df') {
return 'CDMX';
}
return this.point.name;
}
}
}],
tooltip: {
pointFormatter: function() {
if (this['hc-key'] === 'mx-df') {
return 'CDMX: ' + this.value;
}
return this.name + ' ' + this.value;
}
}
现场演示: API参考:
#container {
height: 500px;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
.loading {
margin-top: 10em;
text-align: center;
color: gray;
}
series: [{
...,
dataLabels: {
enabled: true,
formatter: function() {
if (this.point['hc-key'] === 'mx-df') {
return 'CDMX';
}
return this.point.name;
}
}
}],
tooltip: {
pointFormatter: function() {
if (this['hc-key'] === 'mx-df') {
return 'CDMX: ' + this.value;
}
return this.name + ' ' + this.value;
}
}