forked from rudovjan/highcharts-tooltip-delay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtooltip-delay.js
34 lines (25 loc) · 987 Bytes
/
tooltip-delay.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function(H) {
var timerId = {};
H.wrap(H.Tooltip.prototype, 'refresh', function(proceed) {
if (this.shared) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
} else {
var seriesName = seriesName = arguments[ 1 ].series.name;
var delayForDisplay = this.chart.options.tooltip.delayForDisplay ? this.chart.options.tooltip.delayForDisplay : 1000;
if (timerId[ seriesName ]) {
clearTimeout(timerId[ seriesName ]);
delete timerId[ seriesName ];
}
timerId[ seriesName ] = window.setTimeout(function() {
var point = this.refreshArguments[ 0 ];
if (point === this.chart.hoverPoint || $.inArray(this.chart.hoverPoint, point) > -1) {
proceed.apply(this.tooltip, this.refreshArguments);
}
}.bind({
refreshArguments: Array.prototype.slice.call(arguments, 1),
chart: this.chart,
tooltip: this
}), delayForDisplay);
}
});
}(Highcharts));