Categories in google pie chart - Javascript Google Chart

Javascript examples for Google Chart:Pie Chart

Description

Categories in google pie chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Pie Chart Example</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <div id="piechart" style="width: 900px; height: 500px;"></div> 
      <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {//from  w  ww .  j  a  v  a  2  s .  c om
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     1],
          ['Eat',      0.8],
          ['Commute',  0.7],
          ['Run', 0.1],
          ['Study', 5],
          ['Read', 8],
          ['Watch TV', 0.5],
          ['Sleep', 7]
        ]);
        var options = {
          title: 'My Daily Activities',
          fontSize: 11,
             backgroundColor: 'transparent',
             width: "100%",
             sliceVisibilityThreshold: 0,
            legend: { textStyle: { fontSize: 12 } },
           height: 400,
        };
        var chart = new google.visualization.PieChart(document.getElementById('piechart'));
        chart.draw(data, options);
      }

      </script>  
   </body>
</html>

Related Tutorials