Skip to content

Instantly share code, notes, and snippets.

@ricardoferreira1980
Forked from slawekkolodziej/touch-tooltip-fix.js
Last active December 15, 2015 22:48
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ricardoferreira1980/5335186 to your computer and use it in GitHub Desktop.
Save ricardoferreira1980/5335186 to your computer and use it in GitHub Desktop.
Highcharts.Chart.prototype.callbacks.push(function(chart) {
var hasTouch = document.documentElement.ontouchstart !== undefined,
mouseTracker = chart.pointer,
container = chart.container,
mouseMove;
mouseMove = function (e) {
if (hasTouch) {
if (e && e.touches && e.touches.length > 1) {
mouseTracker.onContainerTouchMove(e);
} else {
return;
}
} else {
mouseTracker.onContainerMouseMove(e);
}
};
click = function (e) {
if (hasTouch) {
mouseTracker.onContainerMouseMove(e);
}
mouseTracker.onContainerClick(e);
}
container.onmousemove = container.ontouchstart = container.ontouchmove = mouseMove;
container.onclick = click;
});
@ricardoferreira1980
Copy link
Author

This version works correctly with Highcharts 3.0. Line tooltips are shown, and you can bind click events to certain datapoints.

@geoffp
Copy link

geoffp commented Apr 8, 2013

Thanks for this! Exactly what I was looking for.

@nicholasklick
Copy link

This version let's the system handle multitouch operations like two finger scroll and pinching:
https://gist.github.com/nicholasklick/6083417

I am using Highcharts JS v3.0Beta (2013-02-21)

@gschoppe
Copy link

just tested this on Android Jelly Bean and IOS 7. Normal operations work well, but zoomable charts have issues. The primary issue is that I can't swipe to scroll across a graph, once I've zoomed in. I know that might cause weird issues with website navigation, but my webapp doesn't scroll horizontally.

Is there a way to feed swipes to both highcharts AND the browser?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment