Highcharts Demo
author(s):
Torstein Hønsi
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
JavaScript
$(function () {
(function (H) {
var VISIBLE = 'visible',
pick = H.pick,
splat = H.splat,
each = H.each,
log2lin = H.log2lin;
H.wrap(H.Tooltip.prototype, 'refresh', function (fn, points) {
var val,
tooltip = this,
chart = tooltip.chart,
options = tooltip.options,
crosshairsOptions = options.crosshairs ? splat(options.crosshairs) : null,
vertiCross = crosshairsOptions[0] ? crosshairsOptions[0] : false,
horizCross = crosshairsOptions[1] ? crosshairsOptions[1] : false;
fn.apply(this, Array.prototype.slice.call(arguments, 1));
//add vertical crosshairs
if (vertiCross && tooltip.shared) {
val = points[0].x;
manageCrossHair(tooltip, points[0], vertiCross, val, 0, points[0].series.xAxis);
}
// add horizontal crossharis
if (horizCross && tooltip.shared) {
each(points, function (point, i) {
val = pick(point.stackY, point.y);
manageCrossHair(tooltip, point, horizCross, val, i + 1, point.series.yAxis);
});
}
});
function manageCrossHair(tp, point, cross, val, index, axis) {
var path,
attribs,
series = point.series;
if (axis.isLog) { // #1671
val = log2lin(val);
}
if (series.modifyValue) { // #1205, #2316
val = series.modifyValue(val);
}
path = axis.getPlotLinePath(val, 1);
if (tp.crosshairs[index]) {
tp.crosshairs[index].attr({
d: path,
visibility: VISIBLE
});
} else {
attribs = {
'stroke-width': cross.width || 1,
...