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.7 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@3.3.2"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1.9.7"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-dayjs@1.2.0"></script>
Read more about jsDelivr versioning on their website.
Configuration
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
> npm install
Yarn
> yarn add
License
chartjs-adapter-dayjs
is available under the MIT license.
Credits
Moment Adapter source && README template
Ben McCann
Evert Timberg
stockiNail