Show tooltip of a column chart programmatically in StockChart (highchart)

岁酱吖の 提交于 2019-12-06 02:13:41

问题


I've a Highstock chart (Line with markers and shadow) and would like to show a highstock tooltip programmatically, i.e. when i select, for example, a row on some table (that contains chart data) i would like to show the corresponding highstock tooltip.

Is that possible?


回答1:


For StockChart this solution doesn't work:

In this example you have to replace this:

chart.tooltip.refresh(chart.series[0].data[i]);

to this:

chart.tooltip.refresh([chart.series[0].points[i]]);

The solution is available here.




回答2:


If what you want is to trigger tooltip on the plot near ith data point, then probaly you can use this answer, which suggest to do something like

chart.series[0].data[i].setState('hover');

where chart is the result of your new Highcharts.Chart. (jsfiddle from the comments to that answer).

I guess that if you want to do it on <tr> click, than your js could finally look like this

var chart = new Highcharts.Chart({ <your options> });
$('#yourTableId tr').click(function(){
   var i = $(this).index(); // `this` points to <tr>, get its index
   chart.series[0].data[i].setState('hover');
});


来源:https://stackoverflow.com/questions/14645780/show-tooltip-of-a-column-chart-programmatically-in-stockchart-highchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!