Is it possible in Chart.js to detect event when mouse is over a line in the chart? I also need to know the index of the dataset.
HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.bundle.min.js"></script>
<canvas id="myChart" width="300px" height="100px"></canvas>
JAVASCRIPT
var fruits = ['Apples', 'Oranges', 'Tomotoes']
var datasets = fruits.map(function(a) {
return {
label: a,
data: new Array(10).fill(0).map(Math.random),
fill: false,
}
})
var canvas = document.getElementById("myChart");
var ctx = canvas.getContext("2d");
var myChart = window.myChart = new Chart(ctx, {
type: 'line',
data: {
//labels: labels,
labels: new Array(10),
datasets: datasets,
},
options: {
}
});