GoDB Developer Network
Tuesday, December 06, 2005
  Plotting charts with GoDB
With GoDB you can construct graphs and charts- both static and dynamic quite easily and pep up your data presentation. This article will touch the shallow waters of charting with static data. End of the article there is a link to download the source code for this charting application.

First some definitions:

''*****************************************************************
''''SOME VARIABLES THAT CAN BE INCLUDED IN THE QUERY STRING ARE

'XMargin = 20 MARGIN WIDTH BETWEEN COORDINATES IN X LEGEND
'XOrigin = 5 STARTING X1 POSITION OF RECTANGLE
'XRange = 190 X2-530, XRANGE IS DIFF OF X1 AND X2
'XDiv = 5 NO. OF DIVISIONS IN X AXIS

'YMargin = 20 MARGIN WIDTH BETWEEN COORDINATES IN Y LEGEND
'YOrigin = 210 STARTING Y1 POSITION OF RECTANGLE
'YRange = 200 YRANGE IS DIFF OF Y1 AND Y2
'YDiv = 5 NO. OF DIVISIONS IN Y AXIS


'ShowData = 1 TO DISPLAY DATA, WHILE PLOTTING POINTS

'Type = 1 LINE CHART
'Type = 2 BAR CHART
''*****************************************************************


'XAXIS$ = LIST OF X COORDINATES
'YAXIS$ = LIST OF Y COORDINATES

'SAMPLE COORDINATES
'XAxis$ = "1999,2000,2001,2002,2003,2004,2005,2006,2007,2008, 2009"
'YAxis$ = "50.340,83,737,90.50,400,300,200,200,400, 200, 300"



Bar Chart: Drawing the rectangle bar

to draw the rectangle bar, use drawrect function

ex: drawrect(XOrigin-10,YOrigin,XRange+30,-YRange,2,0,46815,46815)

For Color coding the bar use Fillrect function

ex: fillrect(XOrigin,YOrigin,XRange,-YRange,46815)




Line charts:

Line charts invovle two basic components. Plotting the data and drawing line.

PLOTTING DATA

If ubound(Str$) > 0 Then
For Count = 0 to ubound(Str$)
If Count=0 Then
m1=split(arrY$,Str$(Count),",")
ElseIf Count = 1 Then
m1=split(arrY$,Str$(Count),",")
End If

for i = 0 to NoOfPoints - 1
DataX = atol(arrX$(i))
NewX = TransX(DataX, XMax, XMin)
DataY = atol(arrY$(i))
NewY = TransY(DataY, YMax, YMin)
If Request$("Type") = "1" Then
iff i>0 then drawline(NewX,NewY,OldX,OldY,1,1)
iff ShowData>0 then textout(NewX,NewY,arrY$(i),0,63504, 5)
drawrect(NewX,NewY,2,2,2,1,63488,0)
ElseIf Request$("Type") = "2" Then
iff showData>0 then textout(NewX-5,NewY-20,arrY$(i),0,63504, 5)
drawrect(NewX-5,NewY,10,YOrigin-NewY,2,1,1,255)
End If
OldX = NewX
OldY = NewY
next
Next
Else
for i = 0 to NoOfPoints - 1
DataX = atol(arrX$(i))
NewX = TransX(DataX, XMax, XMin)
DataY = atol(arrY$(i))
NewY = TransY(DataY, YMax, YMin)
If Request$("Type") = "1" Then
iff i>0 then drawline(NewX,NewY,OldX,OldY,1,1)
iff ShowData>0 then textout(NewX,NewY,arrY$(i),0,63504, 5)
drawrect(NewX,NewY,2,2,2,1,63488,0)
ElseIf Request$("Type") = "2" Then
iff showData>0 then textout(NewX-5,NewY-20,arrY$(i),0,63504, 5)
drawrect(NewX-5,NewY,10,YOrigin-NewY,2,1,1,255)
End If
OldX = NewX
OldY = NewY
next
End If

Plotting charts from dynamic data or from database shall be dealt in future articles. So expect a sequel.




charts.zip

 
Comments:
is there a way to draw a circle using godb
 
Post a Comment

Links to this post:

Create a Link



<< Home
Welcome to the unofficial GoDB Developer Network. This blog is completely dedicated to GoDB platform -- a multi platform Mobile RAD tool for developing handheld and wireless applications for Windows Mobile (Pocket PC,Win CE, Smartphones), Palm, Symbian, Embedded Linux, Linux, Win 32, etc. Fellow GoDB developers can find sample codes, contribute to the blog and Mobility related news for the benefit of the mobile development community as a whole.

ARCHIVES
2005-11-20 / 2005-11-27 / 2005-12-04 / 2005-12-11 / 2006-11-05 /


Powered by Blogger