Highcharts – 单击时显示工具提示

我有一个highcharts图,我允许用户动态创建自己的Flags。 现在我希望能够点击标志本身,并能够保持显示整个时间的工具提示,直到我再次点击该标志。 这样做的原因是允许用户为点赋予特殊含义,当他们将图形保存为图像时,我希望它显示他们留下的工具提示信息。

任何人都知道如何做到这一点或去做? 我无法弄清楚如何访问标志工具提示

plotOptions: { series: { allowPointSelect: true, animation: false, dataGrouping: { force: true, smoothed: true } }, line: { allowPointSelect: true, animation: false, point: { events: { click: function () { var thePoint = this; var previousFlag = findFlag(thePoint); if (previousFlag != null) { previousFlag.remove(); } else { createFlagForm(thePoint); } } } } }, flags: { point: { events: { click: function() { //How to access the tooltip? this means the flag point itself } } }, tooltip: { useHTML: true, xDateFormat: "%B-%e-%Y %H:%M" } } }, 

我只是鞭打了这个。 单击某个点时,它将保留工具提示。 它通过克隆工具提示svg元素并将其附加到绘图来实现。

这是一个小提琴 。

 $(function () { cloneToolTip = null; chart = new Highcharts.Chart({ chart: { renderTo: 'container' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, plotOptions: { series: { cursor: 'pointer', point: { events: { click: function() { if (cloneToolTip) { chart.container.firstChild.removeChild(cloneToolTip); } cloneToolTip = this.series.chart.tooltip.label.element.cloneNode(true); chart.container.firstChild.appendChild(cloneToolTip); } } } } }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }] }); });​