Search code examples
angularjshighchartshighcharts-ng

Highcharts-NG, change language


I use Highcharts-ng in my angularjs application and visualization looks very well. I have just one problem, i can't change the language of the months.

Saw that i usually can overwrite the lang with shortMonths, months etc. but it doesn't affect.

In my $scope.chartConfig i added the following configuration:

$scope.chartConfig = {
                        "options": {
                            chart: {
                                type: "column",
                                zoomType: "x"
                            },
                            plotOptions: {
                                "series": {
                                    "stacking": "normal"
                                }
                            },
                            "tooltip": {
                                headerFormat: '<b>{series.name}</b><br/>',
                                pointFormat: '{point.y:,.2f} €',
                            },
                            lang: {
                                loading: 'Daten werden geladen...',
                                months: "Januar,Februar,März,April,Mayi,Juni,Juli,August,September,Oktober,November,DeZember".split(","),
                                shortMonths: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
                                weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
                                decimalPoint: ',',
                                thousandsSep: '.',
                                resetZoom: "Zoom zurücksetzen",
                                resetZoomTitle: "Zoom zurücksetzen"
                            },
                        },...

It displays the loading lang variable "Daten werden geladen..." but not the translated months.

Would be great if somebody has a tip to solve that problem. Thanks in advance.


Solution

  • Set the language option (global) before initiating your charts.(any chart)

    Highcharts.setOptions({
        lang: {
            months: ["Januar,Februar,März,April,Mayi,Juni,Juli,August,September,Oktober,November,DeZember"],
            weekdays: ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Frietag', 'Samstag', 'Sonntag']
        }
    });
    

    Reference