javascript - Programmatically open and close Chart.js tooltip -


chart.js 2.2.1

any idea how trigger code runs when hover on datapoint, , runs when move mouse off? need programmatically show , hide chart's tooltip.

opentip(ochart, datasetindex, pointindex){    // how open specific tooltip? } closetip(ochart, datasetindex, pointindex){    // how close same tooltip? } 

i show sample code if could, don't know start. chart method docs haven't helped.

jsfiddle

the code below handle 1 or more tooltips.

function opentip(ochart,datasetindex,pointindex){    if(window.ochart.tooltip._active == undefined)       window.ochart.tooltip._active = []    var activeelements = window.ochart.tooltip._active;    var requestedelem = window.ochart.getdatasetmeta(datasetindex).data[pointindex];    for(var = 0; < activeelements.length; i++) {        if(requestedelem._index == activeelements[i]._index)             return;    }    activeelements.push(requestedelem);    //window.ochart.tooltip._view.body = window.ochart.getdatasetmeta(datasetindex).data;    window.ochart.tooltip._active = activeelements;    window.ochart.tooltip.update(true);    window.ochart.draw(); }  function closetip(ochart,datasetindex,pointindex){    var activeelements = window.ochart.tooltip._active;    if(activeelements == undefined || activeelements.length == 0)      return;    var requestedelem = window.ochart.getdatasetmeta(datasetindex).data[pointindex];    for(var = 0; < activeelements.length; i++) {        if(requestedelem._index == activeelements[i]._index)  {           activeelements.splice(i, 1);           break;        }    }    window.ochart.tooltip._active = activeelements;    window.ochart.tooltip.update(true);    window.ochart.draw(); } 

complete solution provided @beetlejuice - https://jsfiddle.net/ucvvvnm4/5/


Comments