20👍
Yes, you can use chart.js to configure tooltips to get a similiar behavior to the chart that you referenced.
For more information, check out the mode
tooltip config option and hover config options for your needs. Here is an example.
options: {
responsive: true,
title:{
display:true,
text:'Chart.js Line Chart'
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Month'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
},
}]
}
}
Here is a codepen example demonstrating the behavior that matches your example.
- [Chartjs]-Unable to draw method in Chart.js, v2 can't be found
- [Chartjs]-Chart.js – Plot line graph with X , Y coordinates
14👍
For chart version > 3 rename the object tooltips to tooltip and place it inside the plugin object.
options: {
plugins: {
legend: {
display: false
},
tooltip: {
mode: 'index',
intersect: false
}
},
hover: {
mode: 'nearest',
intersect: false
}
}
- [Chartjs]-How to prevent first/last bars from being cut off in a chart with time scale
- [Chartjs]-React-chartjs-2 with chartJs 3: Error "arc" is not a registered element
9👍
tooltips: {
mode: 'x-axis'
},
^^ That will bring up the tooltip when you hover over any y-axis position. If you only want it to show up when you hover over a point on a line, use this:
tooltips: {
mode: 'label'
},
Source:stackexchange.com