I'm putting together a pie chart using JQPlot being fed via JSON from a MySQL table and am trying to see if there are any gurus out there who might be able to answer a question for me. I have the pie chart working as it's supposed to in that it takes an array, divided it up by percentage of the total amount, and displays the chart. From here, is it possible to feed in another value to become the pie's total value, subtract the total value of the array from that, and show the array items' percentages in relation to the entire pie?
For example, if I give JQPlot this array, [[a,2],[b,4],[c,2]], it would output a chart that shows a=25%, b=50%, c=25% of the total pie. I want to give it another value of 10 to represent the entire pie thus forcing that array to output a=20%, b=40%, c=20% with an extra 20% left over.
The code I'm starting with is the basic pie chart example from the JQPlot site, and my desired total pie value is set up to be fed in from getGrossTotal.php. If it can't be done, it can't be done. I just want to check around for ideas as to how to handle it.
$(document).ready(function(){
$.getJSON('getGrossTop.php', function(grossTop){
var plot1 = jQuery.jqplot ('pieChart', [grossTop],{
seriesDefaults: {
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true
}
},
legend: {
show:true,
location: 'e'
},
});
});
});
Thanks!