Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: problem

  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem

    how can I build the code for graphs and pie charts in javascripts

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by kunapareddy View Post
    how can I build the code for graphs and pie charts in javascripts
    Google is your friend! Have you searched?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New Coder donna1's Avatar
    Join Date
    Nov 2012
    Location
    london
    Posts
    99
    Thanks
    9
    Thanked 4 Times in 4 Posts
    do you want to write it from scratch or use a library?
    I have got the hang of canvas, line and arc so can make a small demo if u want?
    Here's a starter which draws a segment of a pie chart

    Code:
    <!DOCTYPE HTML>
    <html>
    <body>
    <canvas id="myCanvas" width="800" height="600">>Your browser does not support the canvas tag.</canvas>
    <script>
    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext('2d');
    
    function pieSeg(x,y,r,angleRad,col){
     ctx.fillStyle = col;
     ctx.beginPath();
     ctx.moveTo(x,y);
     ctx.arc(x,y,r,0,angleRad, true);
     ctx.lineTo(x,y); 
     ctx.closePath();
     ctx.fill();
    }
    
    pieSeg(300,300,200,4,"red");
    </script>
    </body>
    Last edited by donna1; 12-04-2012 at 06:31 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •