• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

applets - pie charts

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everybody,
i'm facing some problem with java.awt package. here,
i 'm having some numbers(say, 20,30,40,50) using which
i need to draw a pie chart using applets.
i couldn't get the logic as well as the methods to draw
the arc's in the pie chart with different colours.
i want the pie chart to be in such a way that, the area
of each number in the circle would have a different color.
for example, the arc in the circle with value 20 shall
have a green color, the arc with value 30 have a blue
color and so on.
hope u got my problem, so i request u to give up the
solution ( if possible, the necessary code required).
with warm regards,
sreedhar m
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sreedhar
Nothing much to the logic of a pie chart. It is normally
a circle with sectors.If it is a circle it must go all of 360 degrees and thats it.
Here's the code for a simple pie chart in 4 colors as you wanted.

Here, am maintaining a constant sweep angle and only changing the start angle.
Regards
Suneel

[This message has been edited by Suneel Setlur (edited February 02, 2001).]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sreedhar
u r problem is to convert degrees in coordinates.
if u r having four values say 20,30,40,50
their sum is 140.each ark will have a angle of
degree=(number/140)*360
suppose centre of pi circle is 100,100 and refrance line is
g.DrawLine(100,100,150,100);
then other line having angle with this line will be
g.DrawLine(100,100,100+50*(Math.sin(double (deg*3.1415/180)),100+50*(Math.sin(doubl(deg*pi/180)),
100+50*(Math.cos(double (deg*pi/180)))
here 50 is radius of pi chart
and value of pi=3.1415926535897932384636433832792
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by kaustubh ram:
hi sreedhar
u r problem is to convert degrees in coordinates.
if u r having four values say 20,30,40,50
their sum is 140.each ark will have a angle of
degree=(number/140)*360
suppose centre of pi circle is 100,100 and refrance line is
g.DrawLine(100,100,150,100);
then other line having angle with this line will be
g.DrawLine(100,100,100+50*(Math.sin(double (deg*3.1415/180)),100+50*(Math.sin(doubl(deg*pi/180)),
100+50*(Math.cos(double (deg*pi/180)))
here 50 is radius of pi chart
and value of pi=3.1415926535897932384636433832792


Hello,
How do you conver this applet so that it retrieves sales data as parameters and display the data on a pie chart.
The format of the parameters is the following:
<param name=categories value="cat1..... catn ">
<param name=cat1 value="amount1 ">
<param name=catn value="amountn ">
The amount for each category is represented as an integer. For example, the following are sample sales data for a software superstore.
<param name=categories value="education utility entertainment reference"
<param name=education value=10000>
<param name=utility value=12000>
<param name=entertainment value=30000>
<param name=reference value=9000>
I should add methods to my pie chart
applet so that it meets the Canonical Form of Public Classes.
Thanks,
Chris.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for all the info. Does anyone have the code that draws a SIMPLE line graph in an applet ??
Please help ASAP its urgent !
Thanks in advance.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write a program that will read a data file that contains a title and a series of numbers, and plots this as a
coloured pie chart in a window.
The data file should consist of a single line of text containing the label for the chart. Each subsequent line
should consist of a numeric data point (which may be either an integer or a floating point value), and there
may be any number of data points. The program should create a window, write the label of the chart into
that window and draw the pie chart. Each segment of the pie chart should be a different colour. Two
sample data files together with the output produced is shown below.
First Data Set
14
12
37
62
The second data set
0.3
0.2
0.07
0.07
0.09
0.5
0.3
G6DOOS
Optional Features:
1. Add a set of menus to the program window, and allow it to read the data file by selecting a
�File/Open� menu command.
2. Add labels for the segments to the data file, and draw theses on the chart on top of (or next to) pie
segments.
thanks in advance a source code would be grately appreciated.
 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheryl Irwin,
Your post was moved to a https://coderanch.com:80/t/596269";" target="_new" rel="nofollow">new topic.
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic