score:2
You should implement the onHover callback inside the hover options so you can specify your options. The event hover is fire for every other event because they have a hover in them, i.e. the event click, has a hover and then a click.
var chart = new Chart(document.getElementById('chart').getContext('2d'), {
options: {
hover: {
mode: 'nearest',
intersect: false,
onHover: function (e, item) {
if (item.length) {
const data = item[0]._chart.config.data.datasets[0].data[item[0]._index];
console.log(item, data);
}
}
}
}
});
Source: stackoverflow.com
Related Query
- Implementing hover callback in Chart.js
- How to clear a chart from a canvas so that hover events cannot be triggered?
- chartjs show dot point on hover over line chart
- Detecting hover events over parts of a chart using Chart.js
- Changing cursor to pointer on Chart.js bar chart when hover (mousemove) event is disabled?
- Chart js v2 tooltip callback line breaks
- Chart.js tooltip hover customization for mixed chart
- Draw a horizontal and vertical line on mouse hover in chart js
- Chartjs - show elements in all datasets on hover using bar chart
- Chart Js Show the old data on mouse hover
- ChartJs line chart - display permanent icon above some data points with text on hover
- Chart js shows old data on mouse hover
- Callback after line chart rendered
- ChartJs Bubble chart - on hover bubble becomes too big
- How can I trigger the hover mode from outside the chart with charts.js 2?
- Add beforeDraw callback on chart JS v3
- ChartJS Doughnout Chart Pie Offset on Hover
- Chart JS not showing On hover with small data
- Chart js shows old chart data when hover
- Implementing a choropleth chart using chartjs-chart-geo plugin with react-chartjs-2
- Chart.js v3: Tooltip callback doesn't identify clicked dataset of stacked bar chart
- Chartjs numbers on bar chart flash on hover
- ChartJS bar chart - trigger hover even when the cursor is outside of the bar
- Chart.js bar chart label gets hidden on hover
- How to filter hover on a chart in ChartJS?
- How can I change the cursor on pie chart segment hover in ChartJS 3?
- How to customize tooltip on mouse hover of a polar area chart of Angular Charts
- Chartjs : Can I overwrite bar value on hover for every bar chart
- ChartJS/High Charts Radar chart - Different radial axis labels for each category that appear on hover
- Chart js scatter - display label on hover
More Query from same tag
- Create a prop for a chart.js pie chart
- Is it possible to maintain two different font size in Chart.JS based on screen size?
- Vue.js access variable from method
- Chart.js Example Isn't working
- (Lifecycle problem?) React Chart js-2 not updating data from componentDidMount
- Trying to access key in JSON array
- How to reduce the gap between bars on bar chart
- Create Line Chart and populate with database information
- Chartjs Legend Styling
- Chart.js unable to render the chart with data reactjs
- increase the label size of a line chart in chart.js
- Add data to dynamically created Chart.js dataset
- Chart.js stacked bar ordering depending on value
- How Can customize chartjs doughnut chart border and tooltip
- How to add a dataset toggle to Chart.js?
- how to change the label color and set y-axis values 1k intervals and hide y-axis?
- CHART.JS How can I offset/move/adjust the labels on the y-axis to be in the middle of the gridlines instead of centered on the gridlines?
- Creating multiple charts based on dictionary length
- Chart.js two categorical scales
- Time Series Line chart js in react not working
- How to create vertical arbitrary line in financial chart?
- How to set start value as “0” in Chart.js Laravel
- display various chart value and tool tip
- Set labels from array
- Add Gridlines using ChartKick in Rails
- Chart JS attempt to stacked bar chart tooltip for only one dataset
- Chart is disappearing during # link
- How to make ng2-Chart Scrollable for large amount of data sets?
- How can I style ChartJS to always be at the bottom of a div?
- Email a chartjs graph in laravel