1. chartjs-adapter-moment
Chart.js adapter to use Moment.js for time functionalities
chartjs-adapter-moment
Package: chartjs-adapter-moment
Created by: chartjs
Last modified: Mon, 21 Nov 2022 14:19:05 GMT
Version: 1.0.1
License: MIT
Downloads: 439,560
Repository: https://github.com/chartjs/chartjs-adapter-moment

Install

npm install chartjs-adapter-moment
yarn add chartjs-adapter-moment

chartjs-adapter-moment

release travis awesome

Overview

This adapter allows the use of Moment.js with Chart.js. Moment.js is a very heavy library and thus not recommended for client-side development. However, it was previously the only library supported by Chart.js and so continues to be supported. You may prefer chartjs-adapter-date-fns for a minimal bundle size or chartjs-adapter-luxon for larger bundle size with additional functionality included such as i18n and time zone support.

Requires Chart.js 3.0.0 or later and Moment.js 2.0.0 or later. To use Chart.js v2.x, utilize v0.1.2 of the adapter.

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

Installation

npm

npm install moment chartjs-adapter-moment --save
 import { Chart } from 'chart.js';
import 'chartjs-adapter-moment';

CDN

By default, https://cdn.jsdelivr.net/npm/chartjs-adapter-moment 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"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@^2"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@^1"></script>

Read more about jsDelivr versioning on their website.

Configuration

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

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-moment is available under the MIT license.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin