score:13
Accepted answer
use mouseleave to detect when the mouse is out of the container:
$('#container').bind('mouseleave', function(e) {
use hide method to hide the tooltip and hide Crosshair method to hide the crosshair:
chart.tooltip.hide(point);
chart.xAxis[0].hideCrosshair();
Check the example (jsfiddle):
$(function() {
$('#container').bind('mouseleave', function(e) {
var chart,
point,
i,
event;
for (i = 0; i < Highcharts.charts.length; i = i + 1) {
chart = Highcharts.charts[i];
event = chart.pointer.normalize(e.originalEvent);
point = chart.series[0].searchPoint(event, true);
point.onMouseOut();
chart.tooltip.hide(point);
chart.xAxis[0].hideCrosshair();
}
});
$('#container').bind('mousemove touchmove touchstart', function(e) {
var chart,
point,
i,
event;
for (i = 0; i < Highcharts.charts.length; i = i + 1) {
chart = Highcharts.charts[i];
event = chart.pointer.normalize(e.originalEvent); // Find coordinates within the chart
point = chart.series[0].searchPoint(event, true); // Get the hovered point
if (point) {
point.onMouseOver(); // Show the hover marker
chart.tooltip.refresh(point); // Show the tooltip
chart.xAxis[0].drawCrosshair(event, point); // Show the crosshair
}
}
});
/**
* Override the reset function, we don't need to hide the tooltips and crosshairs.
*/
Highcharts.Pointer.prototype.reset = function() {
return undefined;
};
/**
* Synchronize zooming through the setExtremes event handler.
*/
function syncExtremes(e) {
var thisChart = this.chart;
if (e.trigger !== 'syncExtremes') { // Prevent feedback loop
Highcharts.each(Highcharts.charts, function(chart) {
if (chart !== thisChart) {
if (chart.xAxis[0].setExtremes) { // It is null while updating
chart.xAxis[0].setExtremes(e.min, e.max, undefined, false, {
trigger: 'syncExtremes'
});
}
}
});
}
}
// Get the data. The contents of the data file can be viewed at
// https://github.com/highcharts/highcharts/blob/master/samples/data/activity.json
$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=activity.json&callback=?', function(activity) {
$.each(activity.datasets, function(i, dataset) {
// Add X values
dataset.data = Highcharts.map(dataset.data, function(val, j) {
return [activity.xData[j], val];
});
$('<div class="chart">')
.appendTo('#container')
.highcharts({
chart: {
marginLeft: 40, // Keep all charts left aligned
spacingTop: 20,
spacingBottom: 20
},
title: {
text: dataset.name,
align: 'left',
margin: 0,
x: 30
},
credits: {
enabled: false
},
legend: {
enabled: false
},
xAxis: {
crosshair: true,
events: {
setExtremes: syncExtremes
},
labels: {
format: '{value} km'
}
},
yAxis: {
title: {
text: null
}
},
tooltip: {
positioner: function() {
return {
x: this.chart.chartWidth - this.label.width, // right aligned
y: -1 // align to title
};
},
borderWidth: 0,
backgroundColor: 'none',
pointFormat: '{point.y}',
headerFormat: '',
shadow: false,
style: {
fontSize: '18px'
},
valueDecimals: dataset.valueDecimals
},
series: [{
data: dataset.data,
name: dataset.name,
type: dataset.type,
color: Highcharts.getOptions().colors[i],
fillOpacity: 0.3,
tooltip: {
valueSuffix: ' ' + dataset.unit
}
}]
});
});
});
});
Source: stackoverflow.com
Related Query
- Remove Tooltip in Synchronized Charts, When user leaves the chart area
- Not all Tooltips and crosshairs not fading from synchronised charts when the mouse leaves a chart
- Highcharts stock chart - Technical Indicators - Stock price is missing in the tooltip when selecting the 'All' range
- How to show open, close, high and low in tooltip when the chart type is 'line' in highstocks?
- Remove line dots from the area spline chart
- Remove the border around the pie chart in high charts
- Highstock - How can i display the open, high, low, close in the line or area charts tooltip
- remove gap below highcharts area chart when all values are zero
- How can I reveal my chart tooltip programatically when the tooltip combines data from multiple series? (sync charts)
- How do I update an external DIV when a user swipes the finger along an Highcharts Area graph?
- Highchart changes chart width when user hides the graph lines
- Is it possible to trigger tooltip in highchart of a line chart ONLY when the mouse hovers over the point?
- Remove series from chart when user clicks on legend?
- React Highchart: Synchronized chart and tooltip is not highlighting the points
- Highstock chart tooltip activation only when inside the chart
- highstock. Can I add one line of tooltip when the point is in the area of plotbands?
- High charts bar chart label overlaps with the graph when labels are long
- Highcharts showing points on hovering over the line which are outside the chart area when the chart is zoomed in
- How to append dynamic values to the area chart in High charts or convert the data to arrays?
- How to use the tooltip formatter and still display chart color (like it does by default)?
- High charts remove dots from the line graph
- Highcharts => Getting the id of a point when clicking on a line chart
- Highcharts area fillOpacity do not work when changing the color
- Highchart Area Range chart with gradient that follows the line
- Highstock: When legend under the chart has many items, the chart height is small. How can I fix the height?
- Using Highcharts and displaying a message over or on the chart when there is no data
- Highcharts - How can I remove starting and ending padding from area chart
- Highcharts Synchronized charts display tooltip
- Show gridLines when the chart is empty(no series) in highstock
- Show HighCharts tooltip when chart loads
More Query from same tag
- Problematically highlight(hover) a serie ,highcharts
- Remove [Object] label in highchart
- Extra Labels on Stacked Column After Label Toggle and Resize
- How to get a summary from current navigator series of highcharts?
- Line not show properly while exporting HTML to PDF using wkhtmltopdf
- HighCharts is undefined because multiple Html pages in Javascript file
- HighCharts Data and Legend Ordering
- If statement for line colours
- HighStocks series does not show line on Black Colors
- How do I use dates from a LinkedHashMap for the x-axis on a Highcharts line graph (using Thymeleaf)?
- Spacing between horizontal bars in Highcharts
- Highcharts: how to update shapeOptions for arrow-segment annotation?
- Add Data text on top of Bars (vertical) - Highcharts Bar charts
- Implement slider in highcharts
- How to add an array to an existing two-dimensional array (for use in Highcharts)
- Erb array not updated after ajax post
- How do I make highcharter use colorIndex number from tidy dataframe
- HighChart response for time on yaxis and text on xaxis
- Highcharts Highstock How do I change the label on top of tooltip for OHLC series data?
- How do you add specific hyperlinks to highcharts line charts?
- radar chart with boxplot/ Violin plot
- How can I restore original point symbols to highcharts?
- How to set scrollbar in highchart tooltip?
- highcharts - how to controle slice pie from bottom
- Highcharts line segments and data point?
- How to show only weekday on xAxis with Highcharts?
- HighCharts: show alla y axis on tooltip
- How can I identify whether or not a HighChart is displayed on screen?
- How do I configure the options in Highcharts to allow multiple drilldowns asynchronously?
- Legend order for proximate layout