GeeCON Prague 2014*
The moose likes Applets and the fly likes getting coordinants for a bar graph Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "getting coordinants for a bar graph" Watch "getting coordinants for a bar graph" New topic
Author

getting coordinants for a bar graph

ritu mahajan
Greenhorn

Joined: Apr 12, 2002
Posts: 5
Hi,
I need to generate 2 applets to display bar graphs. One an aligned bar graph and the other a stacked bar graph comparing three values in each. I am able to get the drawing coordinants for one value, but then I'm stuck.
I'm confused as to how to display the graph showing all the three values.
thanks,
Ritu
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Sounds like something someone here could help you out with. If I may make a suggestion/request...
Just to clarify what you are trying to do, maybe you could provide a little "text picture" of what you are trying to do and the code that you have so far. For example:

Good Luck.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
ritu mahajan
Greenhorn

Joined: Apr 12, 2002
Posts: 5
Originally posted by Dirk Schreckmann:
Sounds like something someone here could help you out with. If I may make a suggestion/request...
Just to clarify what you are trying to do, maybe you could provide a little "text picture" of what you are trying to do and the code that you have so far. For example:

Good Luck.

Dirk,
Thanks for the response.
I am trying to develop a multiseries bar graph applet.

|
y |
| h
| h v
| l h v l
| hl vh vhl
| vhl vh vhl
| vhl vhl vhl
| vhl vhl vhl
| vhl vhl vhl
--------------------
x
One bar for each item.
I appreciate your help.
Thanks,
Ritu
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Ritu,
Not exactly sure what your problem is. But I can try and explain how to get stacked bars.
1. Assume: same number of points in each series
2. Figure out how many pixels we have for the height -> maxPixels
3. For each point:
Add up all series values at that point to get maximum value (100%) -> maxValue[i]
4. For each series at point i:
Number of pixels to draw it will be (maxPixels * seriesValue[i]) / maxValue[i]
5. Start at lowest point and use answer to 4 and keep adding to ylocation until all series have been drawn.
6. Return to 3 and keep going until all series and points are complete.
For horizontal size just figure out how many pixels you are dealing with in the horizontal direction. Divide by the number of points and draw your bars with some small gap between them.
Below is some code that kind-of shows what I mean.

Regards,
Manfred.
[ April 15, 2002: Message edited by: Manfred Leonhardt ]
[ April 15, 2002: Message edited by: Manfred Leonhardt ]
 
GeeCON Prague 2014
 
subject: getting coordinants for a bar graph