Created
March 7, 2013 13:31
-
-
Save faboo03/5108080 to your computer and use it in GitHub Desktop.
Add Tooltip to Donuts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var plot1 = $.jqplot('plotId', [data], { | |
seriesDefaults: { | |
renderer:$.jqplot.DonutRenderer, | |
rendererOptions:{ | |
highlightMouseDown : false, | |
highlightMouseOver: true, | |
sliceMargin: 0, | |
innerDiameter: 165, | |
startAngle: -90, | |
shadow: false | |
} | |
}, | |
grid: { | |
drawGridlines: false, | |
backgroundColor: "#ffffff", | |
borderColor: "#ffffff", | |
borderWidth: 0, | |
shadow: false | |
}, | |
seriesColors: [ "#98C73D", "#00A9E0", "#67CDDC", "#01A4A4","#D70060", "#E54028", "#F18D05", "#61AE24", "#D0D102", "#32742C", "#616161", "#3B3B3D", "#98C73D", "#00A9E0", "#67CDDC", "#01A4A4","#D70060", "#E54028", "#F18D05", "#61AE24", "#D0D102", "#32742C", "#616161", "#3B3B3D"], | |
legend: { | |
show: true, | |
location: 'e', | |
placement: 'outside' , | |
renderer: $.jqplot.EnhancedLegendRenderer, | |
rendererOptions: { } | |
} | |
}); | |
$("#plotId").bind('jqplotDataHighlight', function(ev, seriesIndex, pointIndex, data) { | |
var total = <?php echo $total?>; | |
var percent = 0; | |
if(total != 0) | |
{ | |
percent = Math.round((data[1]/total)*100); | |
} | |
var $this = $(this); | |
$this.find('.tooltip').remove(); | |
$this.append($('<div class="tooltip jqplot-highlighter-tooltip" ></div>').text(data[0]+' : '+data[1]+' ('+ percent +'%)').css('opacity',1)); | |
}); | |
$("#plotId").bind('jqplotDataUnhighlight', function(ev, seriesIndex, pointIndex, data) { | |
var $this = $(this); | |
$this.find('.tooltip').remove(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment