6👍
Just add "click"
to your tooltipEvents
list when specifying the options for the chart
...
tooltipEvents: ["mousemove", "touchstart", "touchmove", "click"],
});
In the fiddle below, I’ve removed all other events from the list except for click
to give you an idea of how it will be like on a mobile
Fiddle – http://jsfiddle.net/8uobybv3/
8👍
For Chart.js v2, you can specify those events at the root level of chart options.
options: {
events: ['click']
}
1👍
For ChartJS version 2.8.0, you will need to add both the click
and mouseout
events to make the tooltip behave the desired way.
The click
event would make the tooltip to appear when point is clicked and the mouseout
event would hide the tooltip when the mouse pointer is moved outside of the chart canvas area which is the desired behavior.
Note: Without adding the mouseout
event the tooltip would not hide even when the mouse is moved or clicked outside the chart canvas area.
Code:
options: {
events: ["click", "mouseout"],
....
...