0.0.3 • Published 5 years ago

chartjs-adapter-date-fns2 v0.0.3

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

chartjs-adapter-date-fns

release travis awesome

Overview

This adapter allows the use of date-fns with Chart.js.

Requires Chart.js 2.8.0 or later and date-fns 2.0.0-alpha.27 or later.

Note: once loaded, this adapter overrides the default date-adapter provided in Chart.js (as a side-effect).

Installation

npm

npm install date-fns@next chartjs-adapter-date-fns2 --save
import Chart from 'chart.js';
import 'chartjs-adapter-date-fns';

Configuration

Locale support via scale options

date-fns requires a date-fns locale object to be tagged on to each format() call, which requires the locale to be explicitly set via the adapters.date option: Chart.js documentation on adapters.date

For example:

// import date-fns locale:
import {de} from 'date-fns/locale';

// scale options:
{
    adapters: {
        date: {
            locale: de
        }
    }
}

Further, read the Chart.js documentation for other possible date/time related options. For example, the time scale time.* options can be overridden using the date-fns tokens.

Development

You first need to install node dependencies (requires Node.js):

> npm install

The following commands will then be available from the repository root:

> gulp build            // build dist files
> gulp build --watch    // build and watch for changes
> gulp lint             // perform code linting

License

chartjs-adapter-date-fns is available under the MIT license.

0.0.3

5 years ago

0.0.2

5 years ago