troubleshooting Question

Semi circle donut using Google visualization

Avatar of Steynsk
SteynskFlag for Netherlands asked on
GoogleJavaScript* chart
5 Comments1 Solution940 ViewsLast Modified:
Hi Experts,

I'm building a reservation site for a nonprofit organisation. And I'd like to add a chart in the management section.
I try to create a semi circle donut chart that shows the status of occupation in percentage and numbers of chairs in a theater.
The maximum amount of  chairs that can be occupied is 400. The data we have available is the amount of chairs occupied.

Can someone please help me to adapt the sample below so that it shows number of chairs and percentage of occupied and free chairs in this semi circle donut chart?



<html>
  <head>
   <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
   <script type="text/javascript">
 
google.charts.load('current', {
  callback: function () {
    var data = [
      ['Task', 'Hours'],
      ['Occupied',  19.2],
      ['Free',  30.8],
      [null, 50.0]
    ];

    var total = 0;
    for (var i = 1; i < data.length; i++) {
      if (data[i][0] !== null) {
        total += data[i][1];
      }
    }

    var numberFormat = new google.visualization.NumberFormat({
      pattern: '#,##0.0',
      suffix: '%'
    });

    var dataTable = google.visualization.arrayToDataTable(data);
    for (var i = 0; i < dataTable.getNumberOfRows(); i++) {
      if (dataTable.getValue(i, 0) !== null) {
        dataTable.setFormattedValue(i, 1);
      }
    }

    var chart = new google.visualization.PieChart(document.getElementById('chart_div'));

    var options = {
	  title: 'Status of chairs',
      height: 400,
      chartArea: {
        top: 24
      },
      colors: ['#8BC34A', '#64B5F6'],
      pieHole: 0.4,
      pieStartAngle: 270,
      pieSliceText: 'label',
      slices: {
        2: {
          color: 'transparent'
        }
      },
      theme: 'maximized',
      width: 400
    };

    chart.draw(dataTable, options);
  },
  packages: ['corechart']
});

    </script>
  </head>
  <body>

    <div id="chart_div" style="width: 400px; height: 120px;"></div>
  </body>
</html>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros