【发布时间】:2015-03-04 06:45:17
【问题描述】:
我一直在尝试制作高图工具提示以显示最近的点,以防 x 轴值在不同系列中未对齐。
这就是我目前所得到的
Highcharts.wrap(Highcharts.Tooltip.prototype, 'refresh', function (proceed) {
var args = arguments,
points = args[1],
point = points[0],
chart = point.series.chart;
// Loop over all the series of the chart
Highcharts.each(chart.series, function(series) {
// This one already exist
if (series == point.series) return;
var current,
dist,
distance = Number.MAX_VALUE;
// Loop over all the points
Highcharts.each(series.points, function(p) {
// use the distance in X to determine the closest point
dist = Math.abs(p.x - point.x);
if (dist < distance) {
distance = dist;
current = p;
}
});
// Add the closest point to the array
points.push(current);
});
proceed.apply(this, [].slice.call(args, 1));
});
它似乎在那里工作了一半,但是当您将鼠标悬停在某个位置时,它会显示重复的系列。我花了几个小时试图弄清楚这一点,任何帮助将不胜感激。
【问题讨论】:
标签: javascript jquery charts highcharts