Chart.js瞬间语言环境 [英] Chart.js moment locale
问题描述
我正在构建Angular 2应用程序,并使用Chart.js 2.0显示时间"数据.不幸的是,我无法更改moment.js的语言环境.
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.
我安装了npm,并使用SystemJS导入moment.js和pl.js,但Chart.js抱怨说必须在Chart.js之前加载moment.js(不确定如何做到这一点,在每个源文件中都是在chartjs之前声明).
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).
然后,我尝试了Chart.bundle.min.js(含片刻),该文件可以使用,但只能使用英语.我无法将语言环境更改为"pl".
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'.
以下行对Chart.bundle.min.js无效,日期仍以英文显示.
The following line has no effect with Chart.bundle.min.js and dates are still displayed in english.
moment.locale('pl');
Chart.js是否具有自己的更改语言环境的功能?文档没有指定任何有关帽子的内容.
Does Chart.js have an own function to change locale? The docs don't specify anything about hat.
推荐答案
必须在图表加载之前设置时刻的区域设置,否则必须使用 update()更新图表. https://github.com/chartjs/Chart.js/issues/3108
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
这篇关于Chart.js瞬间语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!