Chart.js 时刻语言环境 [英] Chart.js moment locale

查看:19
本文介绍了Chart.js 时刻语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 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 安装了 moment 并使用 SystemJS 导入 moment.js 和 pl.js,但 Chart.js 抱怨必须在 Chart.js 之前加载 moment.js(不知道如何实现,在每个源文件中,moment 都是在 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.

推荐答案

Moment 的语言环境必须在 before 图表加载之前设置,否则必须使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆