[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Description: Draw an XY chart
Mapped Command: DRAW XY CHART AT
FUNCTION __DrawXYChart(Pos1,Pos2,dbf,field,label,width,height,division,filter,solid,dotted,dashed,box,col)
local n, maxvalue, divisions, scalefact, increment
local amode := solid + dotted + dashed + box // calculate the axis mode
local select_ := select() // save the current area
local color := 1 // establish acolor increment
local xlabeltxt := "" // establish the xlabel text memvar
local ylabeltxt := "" // establish the ylabel text memvar
label := if(label == NIL,"",label) // establish X axes label default
width := if(width == NIL,BarChartWidth,width) // establish chart width
height := if(height == NIL,BarChartHeight,height) // establish chart height
use &dbf new // open the plot database
datareset() // clear the dGE data array
if filter != NIL // are we filtering the dbf?
set filter to &filter // establish a filter
go top // reset the database pointer
endif // if filter != nil
maxvalue := &field // start with the first value
n := 1 // establish a bar counter
do while .not. eof() // loop through all the valid records
maxvalue := if(&field > maxvalue,&field,maxvalue) // get the max value
skip // next valid record
n ++ // increment the bar counter
enddo
maxvalue := 1.10 * maxvalue // increase the max by 10%
division := if(division == NIL,maxvalue/4,division)
divisions := int(maxvalue/division) // establish default dependent value
scalefact := __YdGE_(height+2)/maxvalue
for n := 1 to divisions - 1 // create the y label text
ylabeltxt := ylabeltxt + str(division * n,5)
next
n := 1 // establish a bar counter
go top
do while .not. eof() // loop through all the valid records
datastore(scalefact * &field,0,0,0)
color := if(color == 20,1,if(color == 7,color+2,color+1))
if len(label) > 0
xlabeltxt := xlabeltxt + &label // accumulate the label string
endif
n ++ // increment the bar counter
skip // next valid record
enddo
increment := __XdGE(width)/n // calculate the increment
xyaxes(__XdGE(Pos2-2),__YdGE(Pos1+.5),__XdGE_(width),__YdGE_(height+2),n,divisions,amode,__DgeColor(setcolor()))
labelx(__XdGE(Pos2+.75),__YdGE(Pos1+2),increment,if(len(label)>0,len(&label),0),0,BarXLabels,__DgeColor(setcolor()),xlabeltxt)
labely(__XdGE(Pos2-(5 + 2.5)),__YdGE(Pos1-1),__YdGE_(height+2)/divisions,5,0,0,__DgeColor(setcolor()),ylabeltxt)
xygraph(__XdGE(Pos2),__YdGE(Pos1),increment,0,__DgeColor(setcolor())) // display the bar chart
use // close plot database
select(select_) // restore area
RETURN(Void)
See Also:
DRAW XY CHART AT
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson