Reputation: 375
I have tooltips having a list of data in it. I want each data to be a link which redirects to the page for that particular data. Now the problem with Highcharts tooltip is that it changes with respective to the x-axis. As soon as x-axis changes, the tooltip changes to the respective component on the x-axis. So in case i get my tooltip working with links, as soon as i move to click the link, the tooltip changes. To tackle this I figured out a way to fix the tooltip as soon as you click on the tooltip. Here is the code for that.
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function() {
if (cloneToolTip)
{
chart.container.firstChild.removeChild(cloneToolTip);
}
cloneToolTip = this.series.chart.tooltip.label.element.cloneNode(true);
chart.container.firstChild.appendChild(cloneToolTip);
}
}
}
}
},
But even then i need to make the links in the tooltip which are clickable. I saw some threads on stackoverflow where they have done it, but its not working there also. It shows them as links but they're not clickable. Posting a working example here.
Any help would be appreciated.
Edit 1:- These are all the series that i have. May be the tooltip is getting hidden because of some other graph.
series: [{
type: 'column',
name: 'Success',
color: '#7deda2',
yAxis: 1,
tooltip: {
pointFormatter: function(){
return "Success: " + this.y + "%" + "<br />" + "Success docs: " + toolTipSuccess[this.series.data.indexOf( this )] + "<br />";
}
},
data: [{{barSuccess}}]
},
{
type: 'scatter',
name: 'Incidents',
yAxis: 1,
data: scatterData,
color: '#FFAE19',
tooltip: {
pointFormatter: function() {
var string = '';
Highcharts.each(toolTip[this.series.data.indexOf(this)], function(p) {
string += '<a href="http://www.google.com">' + p + '</a><br>'
});
return string + "<br />";
}
},
},
{
type: 'spline',
name: 'Failure',
tooltip: {
pointFormatter: function(){
return "Failure: " + this.y + "%" + "<br />" + "Failure docs: " + toolTipFailure[this.series.data.indexOf( this )] + "<br />";
}
},
data: [{{barFailure}}],
marker: {
lineWidth: 3,
lineColor: Highcharts.getOptions().colors[8],
fillColor: 'red'
}
},
{{#if lu}}
{
type: 'spline',
name: 'Unknown',
tooltip: {
pointFormatter: function(){
return "Unknown: " + this.y + "%" + "<br />" + "Unknown docs: " + toolTipUnknown[this.series.data.indexOf( this )] + "<br />";
}
},
data: [{{barUnknown}}],
marker: {
lineWidth: 3,
lineColor: 'blue',
fillColor: '#87CEFA'
}
}
{{/if}}
Upvotes: 3
Views: 6832
Reputation: 12472
Tooltip's useHTML property should be defined in the global tooltip property - but for <a>
is not sufficient. Changing pointerEvents attribute is necessary - you can see the issue here: https://github.com/highcharts/highcharts/issues/5722
tooltip: {
useHTML: true,
style: {
pointerEvents: 'auto'
}
},
Example: http://jsfiddle.net/SeCAB/216/
Upvotes: 3