如何在Jqplot中绘制半饼图

时间:2015-01-28 20:48:57

标签: php jquery charts jqplot

我有一个像这样的表格

<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>

用户将在不同的文本框中输入数字,我必须使用JqPlot绘制饼图,其中一半饼图应显示表1内容,另一半将显示table2内容

Jqplot的基本脚本如下

<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>

任何人都可以帮我解决这个问题

我只是想知道我将如何使用这些值在180度图表而不是360度

中绘图

提前致谢

1 个答案:

答案 0 :(得分:0)

检查一下,

它是一种被黑客攻击的解决方案,但应该能够获得绘制半饼图的预期结果

startAngle: 180

<强> https://jsfiddle.net/96vog3h1/5/