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

Adds option to override default formats in adapter #27

Closed
wants to merge 3 commits into from

Conversation

kennethormandy
Copy link

I think it’s possible to change time.scale with this adapter, but not possible to change time.displayFormat using this adapter.

For example, you can change time.unit to 'month' to use date-fns to display the month, but you cannot use time.displayFormats to change the display of month from the default of MMM yyyy to your custom string MMMM.

This Pull Request adds an option to pass in formats to modify the default FORMATS object.

If there’s a different way of doing that already, that’s fine too! I intentionally didn’t call it displayFormats as it seems confusing to have time.displayFormats and also adapters.data.displayFormats, but maybe it’s also confusing to have them not match.

This does use Object.assign for convenience, which I think works fine based on Chart.js’ browser support. If that’s an issue, the option could override the whole object instead.

@kurkle
Copy link
Member

kurkle commented Feb 3, 2021

This already works, at least with @next version: https://codepen.io/kurkle/pen/qBqOxwK
What versions are you using?

@kennethormandy
Copy link
Author

I wasn’t aware there was a @next version, so I was using v1.0.0 from npm.

Since it looks like that’s already handled, I’ll close this. It might be worth adding a note about the latest version in the README. Thanks for the sample!

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

Successfully merging this pull request may close these issues.

None yet

2 participants