How to add language translation to amcharts?
1 answer
The diagram does not load the language file. You must enable it as the rest of the JS includes:
<script src="amcharts/amcharts.js"></script>
<script src="amcharts/serial.js"></script>
<script src="amcharts/lang/cn.js"></script>
Also, as you correctly pointed out, you need to add a statement to the diagram to use a specific language:
AmCharts.makeChart( "chartdiv", {
"language": "cn",
...
} );
As for the axis labels, if you are using the category axis by date ( parseDates: true
), then the month / day of the week in the dates will be counted by the chart itself if your translation files include them.
If it is a series-based regular chart, the chart will use whatever is in the "categoryField" of your data as category labels. This means that you will need your details to include these tags / categories in your target language.
i.e:.
var chartData = [ {
"category": "First label",
"value": 100
}, {
"category": "Second label",
"value": 200
}, {
"category": "Third label",
"value": 300
} ];
+1
source to share