Adds option to override default formats in adapter #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think it’s possible to change
time.scale
with this adapter, but not possible to changetime.displayFormat
using this adapter.For example, you can change
time.unit
to'month'
to use date-fns to display the month, but you cannot usetime.displayFormats
to change the display ofmonth
from the default ofMMM yyyy
to your custom stringMMMM
.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 havetime.displayFormats
and alsoadapters.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.