简体   繁体   English

Chart.js - x 轴和工具提示 label 在浏览器语言不是英语时在 Chrome 中显示“未定义”

[英]Chart.js - x-axis and tooltip label shows “undefined” in Chrome when browser language is NOT English

I have an issue with Chart.js on my website.我在我的网站上遇到了 Chart.js 的问题。 The chart is showing properly when the app language in Chrome is set to English, but when I change my browser language to another language, for example Norwegian, both the x-axis and tooltip label shows undefined instead of correct date.当 Chrome 中的应用程序语言设置为英语时,图表显示正确,但是当我将浏览器语言更改为另一种语言(例如挪威语)时,x 轴和工具提示 label 显示undefined而不是正确日期。

You can see preview page here: https://coinpanda.tax/price/bitcoin/您可以在此处查看预览页面: https://coinpanda.tax/price/bitcoin/

Does anyone have an idea what might be causing this?有谁知道可能是什么原因造成的?

Graph not showing correctly:图表显示不正确: 图表显示不正确

Graph showing correctly:图表正确显示: 图表显示正确

This is possibly related to how you've included Chart.js in your web page.这可能与您在 web 页面中包含 Chart.js 的方式有关。 Since Chart.js is dependent upon moment.js for time axes you need to ensure moment.js includes all the locales you want to support.由于 Chart.js 依赖于 moment.js作为时间轴,因此您需要确保 moment.js包含您想要支持的所有语言环境

  • If you're using the Chart.js bundled build (which includes moment.js) then you'll need to switch to the non-bundled build and include moment.js+locales separately.如果您使用的是Chart.js 捆绑构建(包括 moment.js),那么您需要切换到非捆绑构建并分别包含 moment.js+locales。
  • If you're already using the stand-alone build then you need to add the relevant locales.如果您已经在使用独立构建,那么您需要添加相关的语言环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM