4👍
✅
You can set the hover intersect property to achieve this. Here is a fiddle for you -> http://jsfiddle.net/6n3w0qkh/5/.
Hope it helps!
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['A', 'B', 'C', 'D', 'E', 'F'],
datasets: [{
label: "Sales",
data: [2000, 1200, 3000, 5000, 1000, 1300],
pointHoverBackgroundColor: 'rgb(255, 99, 132)',
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
},
{
label: "gross sales",
data: [1500, 2200, 3000, 2800, 1122, 2345],
pointHoverBackgroundColor: 'rgb(66, 133, 244)',
backgroundColor: [
'rgb(66, 133, 244, 0.2)',
],
borderColor: [
'rgb(66, 133, 244)',
],
borderWidth: 1
}]
},
options: {
title:{
display: "true",
text: "Sales Reports",
fontSize: "22"
},
tooltips: {
mode: 'index',
intersect: false
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
Source:stackexchange.com