score:11
As @PawelFus states, it's not officially supported but you can fudge this in by taking control of the visiblity of the tooltip.
First on chart load, hide it:
chart: {
events: {
load: function(){
$('.highcharts-tooltip').hide();
}
}
},
Disable sticky tracking, and on mouseout hide it, on click show it:
plotOptions: {
series: {
stickyTracking: false,
events: {
click: function() {
$('.highcharts-tooltip').show();
},
mouseOut: function() {
$('.highcharts-tooltip').hide();
}
}
}
},
Here's a fiddle example.
First attempt only worked in chrome, here's another:
Disable the default tooltip:
tooltip: {
enabled: false
},
In the chart load event, create your own:
chart: {
events: {
load: function(){
this.myTooltip = new Highcharts.Tooltip(this, this.options.tooltip);
}
}
},
In the click and mouseout control it:
plotOptions: {
series: {
stickyTracking: false,
events: {
click: function(evt) {
this.chart.myTooltip.refresh(evt.point, evt);
},
mouseOut: function() {
this.chart.myTooltip.hide();
}
}
}
},
I tested this in IE and Chrome, I won't install Firefox anymore.
Update to code 9/7/2017 with new stack snippet:
$(function () {
$('#container').highcharts({
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
tooltip: {
valueSuffix: '°C',
enabled: false
},
chart: {
events: {
load: function(){
this.myTooltip = new Highcharts.Tooltip(this, this.options.tooltip);
}
}
},
plotOptions: {
series: {
stickyTracking: false,
events: {
click: function(evt) {
this.chart.myTooltip.options.enabled = true;
this.chart.myTooltip.refresh(evt.point, evt);
},
mouseOut: function() {
this.chart.myTooltip.hide();
this.chart.myTooltip.options.enabled = false;
}
}
}
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
score:-1
Here is the fix for "Cannot read category of undefined". I just take hovered points of chart and pass them to refresh.
point: {
events: {
mouseOver: function(evt) {
var hoveredPoints = a.hoverPoints;
a.tooltip.refresh(hoveredPoints);
},
mouseOut: function() {
a.tooltip.hide();
}
}
}
Sample fiddle here: http://jsfiddle.net/2swEQ/153/
score:0
Just add for those who has the same problems as myself (see comment from @kevinandrada just after correct answer, i can't comment): if you call tooltip.refresh
when your tooltip.shared = true
you'll get an exception Uncaught TypeError: Cannot read property 'category' of undefined
.
You should provide an array of points as a first argument:
plotOptions: {
series: {
stickyTracking: false,
events: {
click: function(evt) {
var points = this.chart.series.map(function(d) {
return d.searchPoint(evt, true)
});
this.chart.myTooltip.refresh(points, evt);
},
mouseOut: function() {
this.chart.myTooltip.hide();
}
}
}
},
score:0
The problem of first mouse-over tooltip showing in Alexandra Espichán excellent fiddle can be solved via css and the mouseover event omit by replacing his invisibility class with:
.highcharts-tooltip:not(.clone){
visibility: hidden !important;
}
score:2
Adding for those who have problems like me with useHTML: true
and wants to display tooltip only on click and not on hover.
tooltip: {
useHTML: true
}
Here is a fiddle.
Source: stackoverflow.com
Related Query
- Highcharts - Show tooltip on points click instead mouseover
- Highcharts - show custom tooltip on mouseOver and on mouse Click
- Highcharts - Show tooltip onClick instead of hover
- Change the legend in highcharts heatmap to show instead of a color bar, a set of fixed icons with hide and show on click
- How to show values in Highcharts tooltip other than x and y when data points are too high?
- Highcharts - Highstock chart showing double line on hovering data points to show tooltip
- Highcharts (column, candlestick) show mouseover tooltip anywhere on chart similar to line or area
- React Highcharts piechart show tooltip on click outside of highcharts container
- Tooltip for line segments instead of points in highcharts
- highcharts show tooltip on point click
- customize Highcharts tooltip on marker points and show default tooltip on the other points
- customize highcharts tooltip to show datetime
- Disable tooltip on certain points in Highcharts
- Highcharts - Keep tooltip showing on click
- Highcharts - only show tooltip when hovering directly on point
- Highcharts - Draw Crosshairs / Tooltip on Mouse Position Instead of Snapping to Data Point
- Show value of last point as label or tooltip on Highcharts Stock Chart
- Show HighCharts tooltip when chart loads
- HighCharts - Show tooltip on column where value is 0 or null
- Click event not fire in highcharts tooltip
- HighCharts area graph - show tooltip only on hover of marker
- Highcharts: tooltip Click instead of hover
- Getting HighCharts to show fewer data points
- highcharts change rendered image source on click
- highcharts show additional custom data in tooltip
- Highcharts - show only selected points
- Show tootip and select pie slice on legend click of pie chart in HighCharts
- Show multiple Tooltips in highcharts on overlapping points
- Compare two data points inside the tooltip in a Highcharts combination chart
- How to edit tooltip in Highcharts C# code
More Query from same tag
- Highcharts : Change opacity of a column chart
- Highchart: Tickmark placement for datetime axis
- making title in highcharts clickable and work with bootstrap popover?
- Categories are skipped in highcharts on xAxis
- Avoid overlap of tick length with label in Highchart gauge
- HighCharts rest zoom fails on xy
- Disable the UTC timezone
- Highcharts gauge chart size
- Highcharts - Pie inner circle size
- Highcharts, get point index when shared tooltip is shows/hides
- Highcharts: generate blank chart
- How to make x-axis tickmarks span the entire bar chart?
- Mulitple data points at single point of time highcharts
- Is there a way of implementing shades of colors in treemap for childs of specific parent
- Displaying Persian dates in highchart from its corresponding Georgian date
- Hightcharts: reset the graph
- Fire a bootstrap modal when i click on a stacked bar of highcharts
- HighCharts in AngularJS with dynamic data
- threshold between 3 color in line charts of highcharts
- Highcharts pattern plugin and wkhtmltopdf
- How to show No Data Available Message in highcharts
- Highcharts Gantt - data labels in top row are not respecting y offset positioning
- Pass JSON Response to Highcharts Basic Line graph
- How to update Highcharts with React JS via input fields
- highcharts: yyy.animate doesn't work correctly when objects are replaced each other more than once
- color in legend with range highcharts
- Can we stack a 2 columns in a single column in basic column Highchart and let the other columns let it be?
- how to import highcharts sub modules in React app
- Nested table yields unexpected columns for a basic column graph using high charts with 'Data defined in a HTML table'
- How to create pie chart with only 1 series data and have background be a circle