Is there a Chart.js option for increasing the distance from a point at which its tooltip becomes active?
By default, a point is "active" and tooltips are displayed when the mouse is hovering directly over a point. I'd like to give the user a little more area around points to make them "active."
Thanks!
You can achieve this, by setting pointHitRadius
property to a value of hit distance, for your dataset, like so ...
...
datasets: [{
pointHitRadius: 20,
...
}]
...
Working example
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [{
label: 'Rating',
data: [1, 2, 3, 4, 5, 6],
backgroundColor: 'rgba(209, 230, 245, 0.5)',
borderColor: 'rgba(56, 163, 236, 1)',
borderWidth: 1,
pointHitRadius: 20 //set as you wish
}]
},
options: {
responsive: false,
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<canvas id="myChart" height="200"></canvas>
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