问题
Tooltips work okay when entering piechart 'from outside' but the transition between slices causes the tooltip to disappear & the new one is not created.
Here is my jsfiddle snippet, closely based on helpful advice from this SO answer.
I know that how to get tooltips working for pie as a whole as have see another jsfiddle doing just that but I want the tooltip on top of the specific slice.
I have seen the bubble plots example on http://www.jqplot.com but since it uses plot1b.axes.xaxis etc I dont think it applies easily to pies or donuts?
$(document).ready(function () {
var data = [
['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14],
['Out of home', 16],['Commuting', 7], ['Orientation', 9]
];
plot2 = jQuery.jqplot('chart2', [ data ], {
seriesDefaults: {
shadow: false,
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
padding: 2,
sliceMargin: 2,
showDataLabels: true,
highlightMouseOver: true
},
highlighter: {
show: true,
formatString: '%s',
tooltipLocation: 'sw',
useAxesFormatters: false
}
}
});
$('#chart2').bind('jqplotDataHighlight',
function (ev, seriesIndex, pointIndex, data) {
console.log("jqplotDataHighlight for " + data)
var $this = $(this);
$this.attr('title', data[0] + ": " + data[1]);
});
$("#chart2").bind('jqplotDataUnhighlight', function (ev, seriesIndex, pointIndex, data) {
console.log("jqplotDataUnhighlight for " + data)
var $this = $(this);
$this.attr('title', "");
});
});
来源:https://stackoverflow.com/questions/21918656/tooltips-working-when-entering-jqplot-pie-but-not-when-moving-from-slice-to-slic