By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,564 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,564 IT Pros & Developers. It's quick & easy.

Drawing graph charts using swings

P: 86
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

.
Oct 31 '07 #1
Share this Question
Share on Google+
11 Replies


10K+
P: 13,264
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.
Oct 31 '07 #2

P: 86
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
Oct 31 '07 #3

10K+
P: 13,264
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?
Oct 31 '07 #4

P: 86
Did you read the specs for that method then?
The method goes like this

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

public abstract void drawPolyline(int[] 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?
Oct 31 '07 #5

10K+
P: 13,264
The method goes like this

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

public abstract void drawPolyline(int[] 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.
Oct 31 '07 #6

Expert 10K+
P: 11,448
Don't reinvent the wheel: use JFreeChart (or similar packages) instead.
It uses just Swing for the actual rendering.

kind regards,

Jos
Oct 31 '07 #7

P: 86
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.
Oct 31 '07 #8

10K+
P: 13,264
Ok thank you.
i will do that.
You should also consider the JFreeChart option suggested above. You are allowed to use it, right?
Oct 31 '07 #9

Expert 10K+
P: 11,448
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
Oct 31 '07 #10

P: 86
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.
Oct 31 '07 #11

10K+
P: 13,264
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?
Nov 1 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.