Tooltips working when entering jqplot pie but not when moving from slice to slice (Firefox only affected)

大兔子大兔子 提交于 2019-12-12 18:41:30

问题


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

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