Change position of labels in Doughnut chart - Javascript Chart.js

Javascript examples for Chart.js:Doughnut Chart

Description

Change position of labels in Doughnut chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script> 
      <style id="compiled-css" type="text/css">

.chart-container {/*  w  w w.  jav  a2 s.  c  o  m*/
   width: 280px;
   height: 280px;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
$(document).ready(function() {
   var ctx = document.getElementById('mycanvas').getContext('2d');
   var chart = new Chart(ctx, {
      type: 'doughnut',
      data: {
         labels: ["CL", "ML", "Spl.L", "PD", "Other Permissions"],
         datasets: [{
            label: "My First dataset",
            backgroundColor: ['#F0CB8C', '#EE97A1', '#A9D5D4', '#E8A3D7', '#CFA3FD'],
            data: [7, 3, 3, 4, 8],
         }]
      },
      options: {
         legend: {
            position: 'right'
         }
      }
   });
})
    }

      </script> 
   </head> 
   <body> 
      <div class="chart-container"> 
         <canvas id="mycanvas"></canvas> 
      </div>  
   </body>
</html>

Related Tutorials