你可以结合你提到的东西来实现你想要的。使用插件中的部分代码,您可以为图例设置初始值,在加载时设置 plotLine 并在 mousemove 时将其删除。
渲染初始值:
function renderInitLegendValues() {
var chart = this,
point = chart.series[0].data[2],
point2 = chart.series[1].data[2],
point3 = chart.series[2].data[2],
hoverPoints = chart.hoverPoints = [point, point2, point3],
legendOptions = chart.legend.options;
Highcharts.each(hoverPoints, function(point) {
point.series.point = point;
point.setState('hover');
});
Highcharts.each(chart.legend.allItems, function(item) {
item.legendItem.attr({
text: legendOptions.labelFormat ?
Highcharts.format(legendOptions.labelFormat, item) : legendOptions.labelFormatter.call(item)
});
});
chart.legend.render();
}
处理绘图线(如果鼠标移出绘图区域,第一个函数不会让十字准线隐藏):
Highcharts.Pointer.prototype.reset = function() {
return undefined;
};
function removeInitCrosshair(e) {
var normE = chart.pointer.normalize(e.originalEvent);
if (chart.isInsidePlot(normE.chartX - chart.plotLeft, normE.chartY - chart.plotTop)) {
chart.xAxis[0].removePlotLine('initial-crosshair');
$(this).off('mousemove', removeInitCrosshair);
}
}
示例:http://jsfiddle.net/y58w4u9j/1/
至于导出,您可以在导出之前动态定义绘图线、悬停时设置点的状态以及图例的值,因此图像将包含这些更改。