Results 1 to 5 of 5
  1. #1
    Robert_85 is offline Member
    Join Date
    Mar 2009
    Posts
    27
    Rep Power
    0

    Default VERTICAL BAR GRAPH in JAVA

    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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What part specifically are you stuck on?

  3. #3
    Robert_85 is offline Member
    Join Date
    Mar 2009
    Posts
    27
    Rep Power
    0

    Default

    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

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    Take a look at JFreeChart (search the net)

    db

  5. #5
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    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.

Similar Threads

  1. Collapsible Vertical Menu
    By ccvid in forum Java Applets
    Replies: 4
    Last Post: 01-27-2009, 05:40 AM
  2. Replies: 0
    Last Post: 07-02-2008, 08:06 PM
  3. How to draw a VERTICAL BAR GRAPH in JAVA
    By sacr83 in forum Java 2D
    Replies: 3
    Last Post: 04-30-2008, 08:09 AM
  4. Java chart & graph lib
    By saturdaybugs in forum Java 2D
    Replies: 1
    Last Post: 04-24-2008, 01:59 PM
  5. what layout to use for vertical alignment?
    By dim_ath in forum AWT / Swing
    Replies: 6
    Last Post: 01-20-2008, 05:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •