如何在圆环图中添加带图例的列

时间:2013-12-12 11:51:57

标签: html donut-chart

您好我参考了谷歌api的圆环图并且一切正常。

但我有两个疑问:

一个。如何使用图例

中显示的图例为值添加一列

enter image description here

湾当专注于特定领域时如何增加图像的大小如图所示。

enter image description here

这是代码

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Total Expenses in percentage'],
          ['Home Loan', 28],
          ['Rent', 23],
          ['Other EMI',  11],
          ['Utilities', 7],
          ['Childrens Education', 6],
          ['Recreation', 25]
        ]);

        var options = {
          title: 'Total Annual Expenses',
          colors:['#CCCCCC','#D95B43','#C02942','#542437','#53777A','#ECD078'],
          pieHole: 0.5,
          pieSliceText: 'Annual Expenses',

          pieSliceTextStyle: {color: 'Annual Expenses', fontName: 'Century Gothic', fontSize: 14}
        };

        var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
      <div>
    <div id="donutchart" style="width: 700px; height: 400px;"></div>
    <div id="pieholetext" style="position:relative; width: 50px; height: 30px; margin-top: 20px;  bottom:235px;
       left:230px;">Annual Expenses</div>
    </div>
  </body>
</html>

,参考链接为reference

请建议如何操作。

提前致谢。

0 个答案:

没有答案