Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart.js moment locale

I'm building an Angular 2 app and use Chart.js 2.0 to display 'time' data. Unfortunately I am not able to change the locale of moment.js.

I npm installed moment and import moment.js and pl.js using SystemJS, but Chart.js complains that moment.js has to be loaded before Chart.js (not sure how to accomplish that, in every source file moment is declared before chartjs).

Then I tried the Chart.bundle.min.js (with moment included), which works but only in english. I am not able to change the locale to 'pl'.

The following line has no effect with Chart.bundle.min.js and dates are still displayed in english.

moment.locale('pl');

Does Chart.js have an own function to change locale? The docs don't specify anything about hat.

like image 745
Alexander Ciesielski Avatar asked Oct 31 '22 00:10

Alexander Ciesielski


1 Answers

Moment's locale must be set before the chart load else the chart must be updated with update(). https://github.com/chartjs/Chart.js/issues/3108

like image 191
Mat'arangéÇa Avatar answered Nov 13 '22 03:11

Mat'arangéÇa