Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module /chartjs.helpers while using chartjs-plugins-datalabels (ReactJS)

I am trying to add datalabels on top of my Bar chart

import { Bar } from 'react-chartjs-2';
import ChartDataLabels from 'chartjs-plugin-datalabels';

<Bar data={chartData} options={opts} plugins={[ChartDataLabels]} />

Reference to this link

Facing the following issue:

Cant resolve chart.js/helpers in /node_modules/chartjs-plugins-datalabels/dist

dependencies attached

Detailed error message

like image 389
Avi solanki Avatar asked Sep 01 '25 20:09

Avi solanki


1 Answers

You are using a mismatch of versions. Version 2 of the datalabels plugin is for chart.js version 3 while you are using chart.js version 2. So you either need to update chart.js and the wrapper which does include breaking changes or you need to install version 1.0.0 of the datalabels plugin

like image 110
LeeLenalee Avatar answered Sep 03 '25 11:09

LeeLenalee