chartjs-adapter-dayjs-3

Allows the use of dayjs with chart.js

Usage no npm install needed!

<script type="module">
  import chartjsAdapterDayjs3 from 'https://cdn.skypack.dev/chartjs-adapter-dayjs-3';
</script>

README

chartjs-adapter-dayjs

Overview

This adapter allows the use of day.js with Chart.js time scale.

Requires Chart.js 2.8.0 or later and dayjs 1.9.6 or later.

NOTE: This adapter was designed for Chart.js v3 (which requires a separate date adapter for time scales to work properly), using this adapter in any version prior to 3 will override the default date-adapter

Installation

npm

npm install dayjs chartjs-adapter-dayjs --save
import Chart from 'chart.js';
import 'chartjs-adapter-dayjs';

CDN

By default, https://cdn.jsdelivr.net/npm/chartjs-adapter-dayjs returns the latest (minified) version, however it's highly recommended to always specify a version in order to avoid breaking changes. This can be achieved by appending @{version} to the URL:

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1.96.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-dayjs@1.0.0"></script>

Read more about jsDelivr versioning on their website.

Configuration

v2 Chart.js documention

Read the Chart.js documention v2 | v3 for possible date/time related options. For example, the time scale time.* options v2 | v3 can be overridden using the Day.js formats.

Development

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

> npm install

License

chartjs-adapter-dayjs is available under the MIT license.

Credits


Moment Adapter source && README template

Ben McCann

Evert Timberg

stockiNail