This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes applets - pie charts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "applets - pie charts" Watch "applets - pie charts" New topic
Author

applets - pie charts

sreedhar meda
Greenhorn

Joined: Dec 09, 2000
Posts: 7
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
Suneel Setlur
Ranch Hand

Joined: Nov 26, 2000
Posts: 202
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).]


Suneel
kaustubh ram
Greenhorn

Joined: Feb 06, 2001
Posts: 5
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
christopson
Greenhorn

Joined: Sep 02, 2001
Posts: 6
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.
Kamran Hanif
Greenhorn

Joined: Sep 25, 2001
Posts: 6
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.
Rafiq Delawala
Greenhorn

Joined: Nov 21, 2001
Posts: 3
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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Cheryl Irwin,
Your post was moved to a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: applets - pie charts
 
Similar Threads
refreshing JFreeCharts
piechart using SVG
EventHandling on pi-chart
Using XSL to draw a pie chart
HOW to draw an ARC on a Frame / Panel