Vikram Anand Bhushan
Vikram Anand Bhushan

Reputation: 4896

How to plot a half pie chart in Jqplot

I have a form something like this

<form>
<table>
<tr><th colspan="2">Table1 Content</th></tr>
<tr><td><div align="left">International Services</div></td><td><input type="text" name="expenditure[]"/></td></tr>
<tr><td><div align="left">Public sector debt interest</div></td><td><input type="text" name="expenditure[]"/></td></tr>
<tr><td><div align="left">Defence</div></td><td><input type="text" name="expenditure[]"/></td></tr>
</table>
<table>
<tr>
        <th colspan="2">
         Table2 content
        </th></tr>
      <tr><td><div align="left">VAT</div></td><td><input type="text" name="revenue[]"/></td></tr>
      <tr>
        <td><div align="left">Other taxes, royalties & adjustments</div></td><td><input type="text" name="revenue[]"/></td></tr>

      <tr>
        <td><div align="left">Interest and dividends</div></td><td><input type="text" name="revenue[]"/></td></tr>
      <tr>
</table>
</form>

The user will input numbers into the different text box , I have to plot a pie chart using JqPlot where half of the pie chart should show table 1 content and the other half will show table2 content

The basic script for Jqplot is as follow

<script>
$(document).ready(function(){
  var data = [
    ['Heavy Industry', <?php echo $_POST['q_1']?>],['Retail',<?php echo $_POST['q_2']?>], ['Light Industry', <?php echo $_POST['q_3']?>],
    ['Out of home', <?php echo $_POST['q_4']?>],
  ];
  var plot1 = jQuery.jqplot ('chart1', [data],
    {
      seriesDefaults: {
        // Make this a pie chart.
        renderer: jQuery.jqplot.PieRenderer,
        rendererOptions: {
          // Put data labels on the pie slices.
          // By default, labels show the percentage of the slice.
          showDataLabels: true
        }
      },
      legend: { show:true, location: 'e' }
    }
  );
});
</script>

Can any one help me out with this

I just want to know how i will use the values to plot in 180 degree chart instead of 360 degree

Thanks in advance

Upvotes: 0

Views: 446

Answers (1)

usr30911
usr30911

Reputation: 2791

Check this out,

its a kind of hacked solution but should get you the expected result of plotting a half pie chart

startAngle: 180

https://jsfiddle.net/96vog3h1/5/

Upvotes: 1

Related Questions