Skip to content

Instantly share code, notes, and snippets.

@malaproping
Forked from ricardoferreira1980/touch-tooltip-fix.js
Last active March 9, 2016 06:39
Show Gist options
  • Select an option

  • Save malaproping/6083417 to your computer and use it in GitHub Desktop.

Select an option

Save malaproping/6083417 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) {
// let the system handle multitouch operations like two finger scroll
// and pinching
if (e && e.touches && e.touches.length > 1) {
return;
}
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;
});
@shernade
Copy link
Copy Markdown

how can i use this?

@malaproping
Copy link
Copy Markdown
Author

@shernade Just load this code after loading the highcharts library. No need to implement anything else.

@SuchyTheMaster
Copy link
Copy Markdown

Unfortunatelly chart zooming doesn't works. I use highcharts 3.0.9 (i can update to 4.x) and settings chart: {type: 'scatter', zoomType: 'xy'} and zooming by pinch doesn't work. Without this fix - works. Tested in newest Chrome on Android (multitouch detected)

@sehv
Copy link
Copy Markdown

sehv commented May 5, 2015

In v4.x (only tested with 4.1.4 on Android), pinch zooming doesn't work correctly. Fix for 4.x is in the following gist:
https://gist.github.com/sehv/928f356afd6b68eb28e2

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