Results 1 to 3 of 3

Thread: Bar graphs, any way to make fill rec, go from bottom to top rather then top to bottom

  1. #1

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290

    Bar graphs, any way to make fill rec, go from bottom to top rather then top to bottom

    Hello everyone, i'm writing a graphing application (vertical bars). My problem is, when I do the following:
    Code:
    g.fillRect(115,300,20,30);
    it will draw the bar, but its upside down. Because its using 300 as the y axis, and 115 as the x axis then the 30 will make it grow downwards from the orginal point, (115,300);

    My x axis line is at 300, I used drawLine to draw the x and y axis.
    so i'm getting somthing like this:

    -------------------------------------------------- x axis
    | |
    | |
    | |
    ----

    ANy idea how i can make it right side up?


    Or maybe i'm approaching this totally wrong


    Thanks for listening
    Last edited by voidflux; Oct 10th, 2004 at 12:30 PM.
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The y axis goes from top to bottom, that's just the way computers work, I'm afraid. You have to do the calculations somewhere.
    There are a few ways. For example, I think it's possible to flip and offset the coordinate system of a Graphics so that you can use a proper mathematical system. Or you could just do the calculations on the coordinates yourself.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290
    Thanks for the responce, I checked out the Graphics class, and I couldn't find anything, i did find translate, but I think that just centers your graph if you resize the screen. Did you know of the function name off the top of your head to invert and offest the coordinate system?

    Thanks!
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

Posting Permissions

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



Click Here to Expand Forum to Full Width