Hi All,
I am new to Java 2D.. I have a set of data(number of drugs sold in a pharmacy per month) for which I want to draw a simple Vertical bar with each bar having a different colour, can someone help please, I am seriously stuck!!!!
thanks
Printable View
Hi All,
I am new to Java 2D.. I have a set of data(number of drugs sold in a pharmacy per month) for which I want to draw a simple Vertical bar with each bar having a different colour, can someone help please, I am seriously stuck!!!!
thanks
What part specifically are you stuck on?
Well, I went through an online tutorial for drawing graphs in Java, but I am still confused what i need to do to draw a simple graph in java, I am trying to read a bunch of data from a Database (MYSQL) and draw a vertical bar graph for it. I don’t know how to write a class which does that!!!
Can you please provide me with a simple example of a Java class which creates a bar graph?( as I said I need to read data from a database or a text file and draw the graph for it)
Thanks a lot
Much appreciated
Robert
Take a look at JFreeChart (search the net)
db
The general approach is to subclass JComponent, and then override the 'paintComponent' method. You then use 'getBounds' to determine the size of your component (I do this within the paintComponent method). Cast the Graphics that is passed into paintComponent toa Graphics2D. Then you use the various draw and fill methods of Graphics/Graphics2D to achieve what you want.
A vertical bar is just a rectangle.