Home › Forums › Chart Support › tooltip for stripline › Reply To: tooltip for stripline
Showing tooltip to stripline is not available as an inbuilt feature as of now. However, you can show tooltip with few lines of code by adding a div on mouse-move as shown in the code-snippet below.
chart.container.addEventListener("mousemove", function(e) {
var xPos = e.pageX - this.offsetLeft,
yPos = e.pageY - this.offsetTop,
bounds = stripLine.bounds,
index = stripLine._index;
if((bounds.x1 <= xPos && xPos <= bounds.x2) && (bounds.y1 <= yPos && yPos <= bounds.y2)) {
if(document.getElementById("striplineTooltip" + index)) {
document.getElementById("striplineTooltip" + index).style.display = "block";
document.getElementById("striplineTooltip" + index).style.left = xPos + "px";
document.getElementById("striplineTooltip" + index).style.top = yPos + "px";
}
else {
var tooltip = document.createElement("div");
tooltip.setAttribute("id", "striplineTooltip" + index);
tooltip.setAttribute("class", "tooltip");
tooltip.innerHTML = "<div class='tooltiptext'>" + toolTipContent + "</div>";
this.appendChild(tooltip);
}
}
else {
if(document.getElementById("striplineTooltip" + index)) {
document.getElementById("striplineTooltip" + index).style.display = "none";
}
}
});
Please take a look at this JSFiddle for a working example on the same.
—
Vishwas R
Team CanvasJS