Google pie Chart wrapping legend label - Javascript Google Chart

Javascript examples for Google Chart:Pie Chart

Description

Google pie Chart wrapping legend label

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="height: 500px;"></div> 
      <script type="text/javascript">
      google.charts.load('current', {
        'packages': ['corechart']
      });/*from w  w  w .  j  a va  2  s.c o  m*/
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work, askdfhasjdh', 11],
          ['Eat, lhafdjkashdjasd', 2],
          ['Commute, jsabdahsdashdb', 2],
          ['Watch TV, asudhasudgsaydgsaygd', 2],
          ['Sleep, sadbgsauidgsayudgaysd', 7]
        ]);
        var options = {
          width: 600,
          title: 'My Daily Activities',
          legend: {
            position: 'right',
            alignment: 'center'
          },
          chartArea: {
            left: 20,
            right: 30
          }
        };
        var chart = new google.visualization.PieChart(document.getElementById('piechart'));
        chart.draw(data, options);
      }

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

Related Tutorials