Amcharts热图图表翻译国家名称 [英] Amcharts heatmap chart translate country names
问题描述
我有一张带有世界地图的Amcharts热图图表.我想在气球文本中用意大利语翻译国家/地区名称.
我有一个文件,其中的国家名称是用意大利语翻译的,例如var mapTranslations = {"Andorra": "Andorra", "United Arab Emirates": "Emirati Arabi Uniti", "Afghanistan": "Afghanistan", "Bosnia and Herzegovina": "Bosnia Erzegovina", "Barbados": "Barbados", "Bangladesh": "Bangladesh", "Belgium": "Belgio"
,但是我不能在气球文本中调用翻译后的名称.
如果我使用
I have an Amcharts heatmap chart with a world map. I would like to translate country names in Italian in the balloon text.
I have a file where the names of the countries are translated in Italian, like this var mapTranslations = {"Andorra": "Andorra", "United Arab Emirates": "Emirati Arabi Uniti", "Afghanistan": "Afghanistan", "Bosnia and Herzegovina": "Bosnia Erzegovina", "Barbados": "Barbados", "Bangladesh": "Bangladesh", "Belgium": "Belgio"
but I cannot call the translated name in the balloon text.
If I use
"areasSettings": {
"balloonText": "[[title]]: [[value]] sessioni"
},
我看到带有相应值的英语国家名称,但是如果我尝试在BalloonText属性中调用mapTranslations,则会得到未定义.
I see country names in English with the corresponding value, but if I try to call mapTranslations in the balloonText property I get Undefined.
推荐答案
AmMaps随附了自己的多种语言翻译,包括意大利语.您所要做的就是包括地图的"it.js"
翻译文件并设置 "it"
,例如:
AmMaps comes withs its own translations for many languages, including Italian. All you have to do is include the maps' "it.js"
translation file and set the language
property to "it"
, for example:
var map = AmCharts.makeChart("mapdiv", {
"type": "map",
"language": "it",
"dataProvider": {
"map": "worldLow",
"getAreasFromMap": true
}
});
#mapdiv {
width: 100%;
height: 300px;
}
<script src="https://www.amcharts.com/lib/3/ammap.js"></script>
<script src="https://www.amcharts.com/lib/3/maps/js/worldLow.js"></script>
<script src="https://www.amcharts.com/lib/3/lang-maps/it.js"></script>
<div id="mapdiv"></div>
请注意,如果要直接从amcharts网站添加语言文件,则必须使用lang-maps目录.如果要在网络服务器上托管amcharts文件,则语言文件位于lang目录中.
Note that if you're including the language file directly from the amcharts website you have to use the lang-maps directory. If you're hosting the amcharts files on your webserver, the language files are in the lang directory.
如果您需要使用自己的翻译文件,我建议遵循语言文件中的amcharts格式并使用language
属性.
If you need to use your own translation file, I recommend following the amcharts format in the language files and use the language
property.
这篇关于Amcharts热图图表翻译国家名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!