jqPlot Pie Chart Tooltips

2019-07-25 18:21发布

Am I right in thinking that the Hightlighter class in jqPlot does not handle tooltips for the PieRenderer? I've spent quite a while trying to get them to work however I can't seem to get it to show the tooltip.

If I am right, is there a way to handle the rollover of a segment and pass the data to a third party jQuery tooltip?

Thanks.

2条回答
趁早两清
2楼-- · 2019-07-25 18:42

Looking through the issues for jqplot, it would seem that there have been a few requests for this functionality, but it has not yet been implemented.

Based on this question How to display tooltips on jqplot pie chart, you could wire up the jqplotDataHighlight and jqplotDataUnhighlight events:

$("#chartId").bind('jqplotDataHighlight', function(ev, seriesIndex, pointIndex, data) {

}); 

$("#chartId").bind('jqplotDataUnhighlight', function(ev, seriesIndex, pointIndex, data) {

});

There is a good example of using this technique to create custom tooltips here. Although it is dealing with bubble charts, it should point you in the right direction.

You could also try out the jqplot-highlighter plugin, which allows tooltips for pie charts.

查看更多
我命由我不由天
3楼-- · 2019-07-25 18:49

if you are using the Highlighter plugin, remember to set useAxesFormatters: false or it don't work.

highlighter: {
    show: true,
    useAxesFormatters: false, // must be false for piechart   
    tooltipLocation: 'w',
    formatString:'%s, %P',
}

It don't follow the mouse but it's set in the top left corner.

查看更多
登录 后发表回答