Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: moment is not defined #5236

Closed
volkerp opened this issue Feb 5, 2018 · 6 comments
Closed

ReferenceError: moment is not defined #5236

volkerp opened this issue Feb 5, 2018 · 6 comments

Comments

@volkerp
Copy link

volkerp commented Feb 5, 2018

moment.js functions do not work in current releases Chart.bundle.js and Chart.bundle.min.js.
moment.js has to be manually imported.

Regards

@simonbrunel
Copy link
Member

@volkerp do you mean:

  • a. Chart.bundle.*.js (2.7.1?) doesn't work (bug) or
  • b. you can't use moment.js in your code?

If a. please provide way more details and a jsfiddle that reproduces your issue (as requested in our issue template displayed when creating an issue).

If b. the moment version embedded in Chart.bundle.*.js is private to Chart.js so if you want to use moment.js yourself, it's better to use Chart.*.js (non bundled) and import moment.js manually.

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>

@mestaritonttu
Copy link

@gdvalderrama
Copy link
Contributor

@simonbrunel

the moment version embedded in Chart.bundle..js is private to Chart.js so if you want to use moment.js yourself, it's better to use Chart..js (non bundled) and import moment.js manually

It'd be nice to have this in the installation docs.

@simonbrunel
Copy link
Member

@mestaritonttu that's case b, so you need to import moment yourself, separately to Chart.js (codepen).

@gdvalderrama agree, can you please submit a PR with that update in the "Bundled Build" section?

@etimberg am I correct about case b?

@simonbrunel
Copy link
Member

I'm closing this ticket since we are not going to expose the internal moment. We are actually thinking to switch to luxon or date-fns for which I'm pretty sure we will not expose anything. IMO, we should even get rid of the confusing bundle version.

@gdvalderrama
Copy link
Contributor

@simonbrunel sure, here's the PR: #5528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants