首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> Tools SDK >> 文章正文
Plotting charts with GoDB
作者:佚名    文章来源:不详    更新时间:2006-5-7 11:24:38

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 involve 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

Download

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

Charts.zip
相关文章:
Plotting charts with GoDB
Plotting charts with GoDB
Plotting charts with GoDB
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号