Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2012, 01:21 PM   PM User | #1
kunapareddy
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kunapareddy is an unknown quantity at this point
problem

how can I build the code for graphs and pie charts in javascripts
kunapareddy is offline   Reply With Quote
Old 12-04-2012, 03:24 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Old 12-04-2012, 05:55 PM   PM User | #3
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
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..
donna1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:18 PM.


Advertisement
Log in to turn off these ads.