create pie chart - Javascript Chart.js

Javascript examples for Chart.js:Pie Chart

Description

create pie chart

Demo Code

ResultView the demo in separate window

<!--//from   w w w  .  j  a  v  a 2 s.  co m
Created using JS Bin
http://jsbin.com
Released under the MIT license: http://jsbin.mit-license.org
-->
<html>
   <head> 
      <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/0.2.0/Chart.min.js" type="text/javascript"></script> 
   </head> 
   <body> 
      <script>
    
      </script> 
      <h1>Chart.js Sample</h1> 
      <canvas id="countries" width="600" height="400"></canvas> 
      <script>
        var pieData = [
            {
                value: 20,
                color:"#878BB6"
            },
            {
                value : 40,
                color : "#4ACAB4"
            },
            {
                value : 10,
                color : "#FF8153"
            },
            {
                value : 30,
                color : "#FFEA88"
            }
        ];
        // Get the context of the canvas element we want to select
        var countries= document.getElementById("countries").getContext("2d");
        new Chart(countries).Pie(pieData);

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

Related Tutorials