I have the following chart :
Which was obtained with this code:
import React, {Component} from 'react';
import { Line } from 'react-chartjs-2';
const data = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'First ',
fill: false,
lineTension: 0.1,
backgroundColor: 'rgba(75,192,192,0.4)',
borderColor: 'rgba(75,192,192,1)',
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: 'rgba(75,192,192,1)',
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: 'rgba(75,192,192,1)',
pointHoverBorderColor: 'rgba(220,220,220,1)',
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: [65, 59, 80, 81, 56, 55, 40]
}
]
};
const options = {
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var label = data.datasets[tooltipItem.datasetIndex].label || '';
if (label) {
label += '-->';
}
return [2, 4, 1, 5, 4, 4, 3];
}
}
}
}
export default class LineDemo extends Component {
render() {
return (
<div>
<h2>Line Example</h2>
<Line ref="chart" data={data} options={options}/>
</div>
);
}
}
My problem is that I would like to add some data to the points when it is hovered. I have an additional array like this : [2, 4, 1, 5, 4, 4, 3] representing the age of the object and I would also like this to be seen when I hover on the a dot.
Please checkout the picture below for a better explanation.
I looked through the chartjs documentation but I could not seem to find an explanation. Any help would be grately appreciated!