Tech Tip Tuesday: HTML Donut Charts and Apache Web Server on Mac OSX

UntitledQuick tech tip for today, how to create HTML donut charts like the one below and use Apache Web Server on Mac OSX.  Hats off to the BI Happy Blog and Coolest Guy on the Planet Tech blog.   I wanted to quickly generate some mockup donut charts by using HTML – and being lazy, figured I would just borrow some code.

For starters, I needed to get Apache Web server started on my Mac OSX Mountain Lion – fortunately, the instructions are already provided – so here’s the link: Install and configure Apache, MySQL, PHP and phpMyAdmin on OSX 10.8 Mountain Lion.

The BI Happy Blog has a great one that allowed me to create a HTML donut chart with relative ease.   The original source code for this can be found at:

I have modified the code slightly so it can be run locally on my Mac OSX Mountain Lion web server – below is my version of it for your usage.

<script type="text/javascript" src=""></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
function drawChart() {
       var data = new google.visualization.DataTable();
       data.addColumn('string', 'Task');
       data.addColumn('number', 'Hours per Day');
       ['web',    roundNumber(11*Math.random(),2)],
       ['XML',      roundNumber(2*Math.random(),2)],
       ['json',  roundNumber(2*Math.random(),2)],
       ['avro', roundNumber(2*Math.random(),2)],
       ['protobuf',    roundNumber(7*Math.random(),2)]
var options = {
width: 450, height: 300,
legend: {position: 'none'},
   pieHole: 0.5
//   animation:{
//       duration: 800,
//       easing: 'in'
//     }
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
function roundNumber(num, dec) {
 var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
 return result;
<div id="link_div" style="z-index: 3; position: absolute; left: 180px; top: 30px;">
<a href="javascript:drawChart()">Change Data</a>
<div id="chart_div" style="z-index: 1; position: absolute; left: 0px; top: 20px;"></div>
<div id="circle_div" style="z-index: 2; position: absolute; left: 180px; top: 127px;">
<!-- <img src="circle.png"></div> -->
<img src=""></div>



  1. Thanks for the reference Denny. Best regards. – Ron

    1. By all means! It’s your code! 🙂

  2. Thank you so much Denny!!! great help.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s