• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

histogram plus lines

 
Norazanita Adnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Norazanita Adnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed, JFreeChart does not have histograms. But googling for "histogram java" yields lots of results. Maybe one of those fits the bill?
 
Norazanita Adnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Ulf
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic