Is it possible to have the hover activated when you are not hovering over a specific 'point' in a line graph?
I want that particular tooltip to activate whenever I hover over any part of the chart.
Edit: something like this http://watchstocks.herokuapp.com/
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
}
}
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.
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'
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With