Using Google Charts (haven\'t migrated to the Material ones yet), one can make tooltips require a click by using the {trigger: \'selection\'}
option. However, u
You could attach a click
event handler for the body
element to clear the chart's selection as demonstrated below:
Example
google.setOnLoadCallback(drawChart);
var chart;
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Fixations'],
['2015', 80],
['2016', 90],
['2017', 100],
['2018', 90],
['2019', 80], ]);
var options = {
tooltip: {
isHtml: true,
trigger: 'selection'
},
legend: {
position: 'none'
},
bar: {
groupWidth: '90%'
},
colors: ['#A61D4C'],
enableInteractivity: true
};
chart = new google.visualization.ColumnChart(document.getElementById('tooltip_rotated'));
chart.draw(data, options);
addEvent(document.querySelector('body'),'click',clearSelection);
}
function clearSelection (e) {
if (!document.querySelector('#tooltip_rotated').contains(e.srcElement)) {
chart.setSelection();
}
}
function addEvent(element, evnt, funct){
if (element.attachEvent)
return element.attachEvent('on'+evnt, funct);
else
return element.addEventListener(evnt, funct, false);
}