I am working on the latest version of Chart.js, i.e., v3.7.1. However, I notice that most of the configurations have been changed from those of version 2.x. My problem is that I would like to draw a vertical line everytime there is a mouseover the chart, but not necessary having the mouse on the data points, but can be above or below, as long as the mouse point is in line with a data point, a verical line is drawn. This is clearly illustrated by this code on JSFiddle. I tried this Solution on this platform but it fails to work since it is based on ChartJS v2.6.0. Anyone with an idea of doing this? Here are my codes:
LineChart.js
import React from "react";
import Chart from 'chart.js/auto';
import { Line } from "react-chartjs-2";
import 'chartjs-adapter-moment';
const newOptions = {
responsive: true,
plugins: {
responsive: true,
title: {
display: true,
text: 'Weekly Logs'
},
},
scales: {
x: {
type: "time",
time: {
displayFormats: {
'day': 'dddd'
}
}
}
},
interaction: {
mode: "index",
axis: 'y'
}
};
const LineChart = ({ dataChart }) => {
return <Line
data={dataChart} options={newOptions}
/>;
};
export default LineChart;