jqPlot Pie Chart Tooltips

瘦欲@ 提交于 2020-01-05 06:37:06

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/15474242/jqplot-pie-chart-tooltips

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