Circle div bar for rating - Javascript Canvas

Javascript examples for Canvas:Circle

Description

Circle div bar for rating

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-1.7.js"></script> 
      <script type="text/javascript">
    $(function(){//from  w w w. j a va2  s.c  o m
window.onload = function() {
        canvas  = $('#timer'),
        percent = +canvas.data('completeness'),
        ctx     = canvas.get(0).getContext('2d'),
    ctx.lineWidth = 9;
    ctx.strokeStyle = ctx.fillStyle = "#00EE00";
    var endAngle = (Math.PI * percent * 2 / 100);
    ctx.arc(50, 50, 35, -(Math.PI/180*90), endAngle - (Math.PI/180*90), false);
    ctx.stroke();
    ctx.font = "bold 13px Arial";
    ctx.fillText(percent + "%", 40, 53);
}
    });

      </script> 
   </head> 
   <body>    
      <title>Canvas timer</title>   
      <div> 
         <canvas id="timer" width="100" height="100" data-completeness="75"></canvas> 
      </div>    
   </body>
</html>

Related Tutorials