Create pie chart with Json value - Javascript Chart.js

Javascript examples for Chart.js:Pie Chart

Description

Create pie chart with Json value

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://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from  w ww. j  a v  a2s  .  co m
var context = document.getElementById('skills').getContext('2d');
var pieData = [
   {
      value: 25,
      label: 'Java',
      color: '#811BD6'
   },
   {
      value: 10,
      label: 'Scala',
      color: '#9CBABA'
   },
   {
      value: 30,
      label: 'PHP',
      color: '#D18177'
   },
   {
      value : 35,
      label: 'HTML',
      color: '#6AE128'
   }
];
var skillsChart = new Chart(context).Pie(pieData);
    }

      </script> 
   </head> 
   <body>  
      <canvas id="skills" width="300" height="300"></canvas>   
   </body>
</html>

Related Tutorials