Drawing graph charts using swings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ravindarjobs
    New Member
    • May 2007
    • 86

    Drawing graph charts using swings

    hi friends, i have just moved from vba to java. i am quite new to java. but unexpectedly i was given a task to build a chart for a table stored in oracle database.

    we have to use only swings technology.
    and now my task is,

    There will be a table in oracle database.
    i have to draw a line chart for that table and show to user.

    can any body place me in the correct track towards the solution.


    thank you

    .
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by ravindarjobs
    hi friends, i have just moved from vba to java. i am quite new to java. but unexpectedly i was given a task to build a chart for a table stored in oracle database.

    we have to use only swings technology.
    and now my task is,

    There will be a table in oracle database.
    i have to draw a line chart for that table and show to user.

    can any body place me in the correct track towards the solution.


    thank you

    .
    By line chart you mean a line graph?
    Have a look at the g.drawPolyLine method in the Graphics class.

    Comment

    • ravindarjobs
      New Member
      • May 2007
      • 86

      #3
      Originally posted by r035198x
      By line chart you mean a line graph?
      Have a look at the g.drawPolyLine method in the Graphics class.


      Yes line graph(infact i have to draw line and bar graph).
      i have table with two columns.
      i have to draw line and bar graphs.

      how can i make this using that method?


      Thank you

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by ravindarjobs
        Yes line graph(infact i have to draw line and bar graph).
        i have table with two columns.
        i have to draw line and bar graphs.

        how can i make this using that method?


        Thank you
        Did you read the specs for that method then?

        Comment

        • ravindarjobs
          New Member
          • May 2007
          • 86

          #5
          Originally posted by r035198x
          Did you read the specs for that method then?
          The method goes like this

          *************** *************** *************** *********

          public abstract void drawPolyline(in t[] xPoints,
          int[] yPoints,
          int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. The figure is not closed if the first point differs from the last point.

          Parameters:
          xPoints - an array of x points
          yPoints - an array of y points
          nPoints - the total number of points
          *************** *************** *************** *************** ********

          now, do you mean that i have to put my first column values into xPoints, and second column values into yPoints?
          also what is nPoints?

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by ravindarjobs
            The method goes like this

            *************** *************** *************** *********

            public abstract void drawPolyline(in t[] xPoints,
            int[] yPoints,
            int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. The figure is not closed if the first point differs from the last point.

            Parameters:
            xPoints - an array of x points
            yPoints - an array of y points
            nPoints - the total number of points
            *************** *************** *************** *************** ********

            now, do you mean that i have to put my first column values into xPoints, and second column values into yPoints?
            also what is nPoints?
            The last line of the text you posted above says
            nPoints - the total number of points
            You have to set up somewhere to draw this of course, perhaps a Canvas (look it up) and then use it's graphics object to do the painting.

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Don't reinvent the wheel: use JFreeChart (or similar packages) instead.
              It uses just Swing for the actual rendering.

              kind regards,

              Jos

              Comment

              • ravindarjobs
                New Member
                • May 2007
                • 86

                #8
                Originally posted by r035198x
                The last line of the text you posted above says


                You have to set up somewhere to draw this of course, perhaps a Canvas (look it up) and then use it's graphics object to do the painting.

                Ok thank you.
                i will do that.

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by ravindarjobs
                  Ok thank you.
                  i will do that.
                  You should also consider the JFreeChart option suggested above. You are allowed to use it, right?

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by r035198x
                    You have to set up somewhere to draw this of course, perhaps a Canvas (look it up) and then use it's graphics object to do the painting.
                    For Swing, better use a JPanel

                    kind regards,

                    Jos

                    Comment

                    • ravindarjobs
                      New Member
                      • May 2007
                      • 86

                      #11
                      Originally posted by r035198x
                      You should also consider the JFreeChart option suggested above. You are allowed to use it, right?

                      JFreeChart?

                      is that a external application? (please dont mind, i dont know)
                      i have searched for it in google and could find only demo version.
                      demo version allowed me to view charts but not the code.

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #12
                        Originally posted by ravindarjobs
                        JFreeChart?

                        is that a external application? (please dont mind, i dont know)
                        i have searched for it in google and could find only demo version.
                        demo version allowed me to view charts but not the code.
                        Did you open the link posted by Jos above?

                        Comment

                        Working...