File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes histogram plus lines Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "histogram plus lines" Watch "histogram plus lines" New topic
Author

histogram plus lines

Norazanita Adnan
Ranch Hand

Joined: May 28, 2008
Posts: 44
hi

i dont have any idea how to start my new assignment. i have to draw a histogram and a line chart with a smooth curve just like a distribution graph.. the graph is similar http://support.sas.com/documentation/cdl/en/grstatproc/60786/HTML/default/a003155747.htm " Cholesterol Distribution"

i did want to try sample from the http://www.koders.com/java/fid50A35EBC040865D1ABA605EEDE32F0646A7DEE10.aspx but some of the jar file i couldn't find

hope someone able to help me on this

thanks in advance
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19759
    
  20

I think you'll have some more success in the user interface forum. You should already check out classes java.awt.Graphics and java.awt.Graphics2D. You can then subclass JPanel to do the drawing:

The casting should be done carefully:

Although in general the Graphics object will in fact be a Graphics2D object, technically it doesn't have to be. The instanceof check guards you against that.

You should try to avoid using Graphics2D though; only if you really need one of its methods should you use it. That way your code will work regardless of the Graphics object.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Norazanita Adnan
Ranch Hand

Joined: May 28, 2008
Posts: 44
Thanks for your reply rob...

at first i also wanna use the 2D graphic but my supervisor insist me to use the JFreeChart. The problem with JFreeChart is, i can use the mixture of bar chart and line but the it able to use a time series data set only ...

other than that , the histogram do have a gap between each of them which is wrong as histogram would not have a gap between them. i have also try to remove the gap, it is unsuccessful..

is there any tools or sample of java code that i can study?

thanks and reagrds
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
Indeed, JFreeChart does not have histograms. But googling for "histogram java" yields lots of results. Maybe one of those fits the bill?


Ping & DNS - my free Android networking tools app
Norazanita Adnan
Ranch Hand

Joined: May 28, 2008
Posts: 44
hi..

ive try to Google but i couldn't get something similar with a histogram/bar chart with a smooth curve/distribution graph. ive try to play around with the JFreeChart Code, and i get to know different data set are unable to combine. ive able to combine a bar chart and line chart but the data set is time series which it doesn't match the data set that i have which is integer/decimal.

my supervisor insist me to use the JFreeChart instated of 2D programming.

im totally lost now..any suggestion what shall i start with?

thanks in advance..

Norazanita
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
Check out the various "Overlaid Chart" items in the JFreeChart demo application. It combines line charts and bar charts in the same plot. You can obtain the source code of the demo application (along with extensive documentation) for $50 or so from the JFreeChart author.
Norazanita Adnan
Ranch Hand

Joined: May 28, 2008
Posts: 44
thanks Ulf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: histogram plus lines