I am trying to get the time scale (x-axis) using chartjs-adapter-date-fns
adapter and getting this error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\chart\node_modules\chart.js\package.json when using "import 'chartjs-adapter-date-fns" in Next.js'.
This is an issue that currently exists with the chartjs-adapter-date-fns
adapter in combination with chart.js@4.0.1
. The Luxon adapter has already released a fix for this issue which makes it work with chart.js@4.0.1
.
Until it is fixed, you could use the Luxon adapter instead:
npm install luxon chartjs-adapter-luxon --save
import {Chart} from 'chart.js';
import 'chartjs-adapter-luxon';