Chart.js
Chart.js copied to clipboard
Simple adapter for time axes
Feature Proposal
Having rather simple use cases and reading these articles "Do you really need a date library?" I was wondering whether it wasn't possible to write an adapter for basic needs using Intl.DateTimeFormat only.
Possible Implementation
Here is my code. It might serve as a starter for a default adapter that needs to be replaced with a date library based adapter only if more sophisticated parsing/formatting functions are required.
I think the date-fns adapter is about as barebones as can be. I believe date-fns only using standards under the hood
Afaik date-fns doesn't use Intl.DateTimeFormat and support for l10n has to be configured for each language. Besides, it seems to be rather big.
But I don't insist on this in any way. My code solves my problem and I was only thinking that it would be nice for chart.js to be usable without a mandatory dependency for using the time axes.
Guys, I've taken your code and adapted it a bit so that it's now a usable adapter: the project is here: https://github.com/gcollin/chartjs-adapter-date-std
Now if you
npm install chartjs-adapter-date-std
register once the adapter (it's not automatically done) with
_adapters._date.override( StdDateAdapter.chartJsStandardAdapter());
then you get working time axis adapter with no dependencies.