home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
plotter.zip
/
PCMAG.SBP
< prev
Wrap
Text File
|
1990-07-11
|
10KB
|
417 lines
SBP
╜ *** Written by: Mark C. Johnson
╜ ** on: Jul 10, 1990
╜ * Setup Windows SDK Calls and Variables
ç
Γ e
╦ e
¼ à
ε à
ε"User","GetActiveWindow","I"
ε"User","GetDC","II"
ε"User","ReleaseDC","III"
ε"GDI","CreatePen","IIIJ"
ε"GDI","SelectObject","III"
ε"GDI","DeleteObject","II"
ε"GDI","CreateSolidBrush","IJ"
ε"GDI","MoveTo","IIII"
ε"GDI","LineTo","AIII"
ε"GDI","Rectangle","AIIIII"
ε"Kernel","GetTempFileName","IDFIF"
ε"GDI","Pie","AIIIIIIIII"
╜ *** Ask User What File They Want
Start:
fln$ "*.SBD"
┬"Select Database to Graph:","",18,n%,fln$
ín% 0 p Æ
í J(fln$) 0 p ┬"Can't find database",fln$,100: wStart
╜ *** Build array full of Numeric, Date, and Time fields so user can choose
╜ ** which one they want to report on. Build array for all fields at
╜ * same time (for X axis).
¼1,0,1,"Reading"
¼2,0,1,"File..."
¼ │a%,b%
x%% â("GetTempFileName","C",a$,0,tf$)
òXopt$,Yopt$
fl$ σroot(fln$)
┤ Ö α,4fl$
┤tf$ ¢ ╢
{ ╦ Öfl$
å ╢
┤tf$ ¢ ñ
╪ O(a$ "*Field Count*")
ñ ca$
┘
numfld% 0( ,(a$,39))
╫Xopt$(numfld% 1),Yopt$(numfld% 1)
nc% 0:xc% 0
╪ O(a$ "Formu*")
ñ ca$
┘
ñ ca$
ñ ca$
╪xc% numfld%
xc% xc% 1
╔ µ ,(a$,17,3)
µ"NMI","NUM","NML"
Yopt$(nc%) F( +(a$,16))
nc% nc% 1
µ"VNU","VNI","VNL"
Yopt$(nc%) F( +(a$,16))
nc% nc% 1
µ"TXT","VTX"
Xopt$(xz%) F( +(a$,16))
xz% xz% 1
Æ ╔
a$ ""
╪( +(a$,1) " " /(a$)
1)
í B("*") wDone
ñ ca$
┘
┘
Done:
å ñ
ìtf$
¼ à
ínc% 0 p ┬"No Numeric field to Graph on!","",100: wStart
╜ *** Now get what kind of graph the user wants
╜ ** Line = 1
╜ * Bar = 2
╜ Pie = 3
╜ (Other types could easily be supported)
GetGraphType:
ë £"GrphSlct"
╩ £ ╓0,0
╩ £ ╤9
╩ £ ╥9
╩ £ o"Helv,24,0"
╩ £ s0
| £1,0,0,750,950
╩ £ ╤0
| £5,23,10,"Select Desired Graph Type:"
╩ £ ╓7,22
╩ £ ╤10,1
╩ £ ╥8
╩ £ o"Tms Rmn,14,0"
| £8,52,15,50,10,bt1$,0,"drawflag%=1:GOTO DoPlot"
| £8,52,30,50,10,bt2$,0,"drawflag%=2:GOTO DoPlot"
| £8,52,45,50,10,bt3$,0,"drawflag%=3:GOTO DoPlot"
╩ £ o"Tmns Rmn,24,0"
╩ £ ╤0,1
| £8,42,75,70,15,bt4$,0,"GOTO QuitIt"
bt1$ "&Line Graph"
bt2$ "&Bar Chart"
bt3$ "&Pie Chart"
bt4$ "&Quit"
£1
GetOpt:
╧ ▀ Ñ
¥g$
íg$ (27) pg$ "Q"
g% ?("LBPQ", >(g$))
íg% 4 wQuitIt
drawflag% g%
íg% wDoPlot
wGetOpt
QuitIt:
Γ │
╦ │
å t
ε à
ç
Æ
DoPlot:
╜ *** Now we know what kind of plot to do, let's ask the user what field
╜ ** they want for the X and Y axis.
íagn% pagn% 0: wPlotData
plotdata$ ""
┬"Select Field to Chart:","",20,n%,plotdata$,16,Yopt$
ín% 0 wQuitIt
¢x% 0 qnc% 1
í >(Yopt$(x%)) >(plotdata$) wGetX
▒x%
wDoPlot
GetX:
against$ ""
┬"Plotted against what field:","",20,n%,against$,16,Xopt$
ín% 0 wDoPlot
¢x% 0 qxc% 1
í >(Xopt$(x%)) >(against$) wFindMinMax
▒x%
wGetX
FindMinMax:
╜ *** Got the axis fields, now find all unique X's and corresponding
╜ ** plot (y) values. If there are duplicate X's, this plot routine
╜ * takes the total of all Y values. This can easily be modified.
å £
í >(against$) >(plotdata$) p ┬"Cannot plot field against itself!","",100: wDoPlot
numunique% 0
│ _ wNotIndex
úagainst$$
│ _
FMM1:
¼1,0,1,"Collecting"
¼2,0,1,"Data..."
¼ │a%,b%
ç
╔ `
rc% 1
old$ "[[[["
╪old$ against$$
old$ against$$
numunique% numunique% 1
{&4.0(numunique%);against$$; (13);
╔ Ñagainst$$ " !"
┘
ç
òplot$,amt%
¼1,0,1,"Processing"
¼2,0,1,"Data..."
¼ │a%,b%
div% 1
ínumunique% 50 pdiv% (numunique% 50):numunique% 50
cnt% div%:stp% 0:arr% 1
╫plot$(numunique%),amt%(numunique%)
╔ `
╪ B("") 0
stp% stp% 1
ístp% (cnt%) p
plot$(arr%) against$$
cnt% cnt% div%
╪plot$(arr%) against$$ B("") 0
amt%(arr%) amt%(arr%) plotdata$$
╔ ▒
┘
{&2.0(arr%);plot$(arr%); '(80); (13);
arr% arr% 1
^
z$ against$$
╪z$ against$$ B("") 0
╔ ▒
┘
Æ í
┘
╜ *** Draw Axis routine. This routine can be skipped for Pie Charts
╜ ** First plot hi and low vals, then step vals, title, then find
╜ * num fields on bottom and scale bottom to fit.
PlotData:
¼1,0,1,"Plotting"
¼2,0,1,"Graph..."
¼ │a%,b%
ídrawflag% 3 wDoPie
sc:
hi% ô(amt%)
lo% ┌(amt%)
ílo% hi% p ┬"No information to plot!","",100: wStart
ë £"PlotScrn"
╩ £ ╓0,0
╩ £ ╤9
╩ £ ╥9
| £1,0,0,750,950
╩ £ ╤0
╩ £ o"Tms Rmn,18,0"
title$ plotdata$ " vs. " against$ ":"
x% 60 ( /(title$) 2)
| £5,x%,6,title$
╩ £ o"Helv,8,0"
╩ £ s0
| £3,10,10,1,70
| £3,10,80,150,1
ct% 11
╩ £ ╓17,2
stp% ((hi% lo%) 10)
¢x% lo% q(hi% (stp% .5)) kstp%
| £5,1,(7 (ct% 1)) 11, F( (x%,"9999.9"))
| £3,9,(7 (ct% 1)) 10,2,1
ct% ct% 1
▒x%
xdiv% 150 numunique%
hWND%% â("GetActiveWindow")
hDC%% â("GetDC",hWND%%)
╜ Set color of lines here (RED=default). Format = 8 bits each for Blue, Green, and Red.
clr% 255
xloc% 10
Xorg% 40
Xstep% (( σsys(6) Xorg%) 35) numunique%
Yorg% .63 σsys(7)
Yscale% (hi% 250)
¢x% 1 qnumunique%
| £3,xloc% (xdiv% 2),79,1,2
x$ plot$(x%)
vAddDown
xloc% xloc% xdiv%
▒x%
£1
xloc% 10
¢x% 1 qnumunique%
x1%% Xorg% ((x% 1) Xstep%)
y1%% Yorg% (amt%(x%) Yscale%)
ídrawflag% 1 p
x1%% x1%% (.5 Xstep%)
pr%% â("CreatePen",0,0,clr%)
ob%% â("SelectObject",hDC%%,pr%%)
íx% 1 p
err%% â("MoveTo",hDC%%,x1%%,y1%%)
^
err%% â("LineTo",hDC%%,x1%%,y1%%)
Æ í
br%% â("SelectObject",hDC%%,ob%%)
err%% â("DeleteObject",br%%)
^
pr%% â("CreatePen",0,0,clr%)
br%% â("CreateSolidBrush",16777215 (1))
ob1%% â("SelectObject",hDC%%,pr%%)
ob%% â("SelectObject",hDC%%,br%%)
x2%% (Xorg% (x% Xstep%))
err%% â("Rectangle",hDC%%,x1%%,y1%%,x2%%,Yorg%)
br%% â("SelectObject",hDC%%,ob%%)
err%% â("DeleteObject",br%%)
br%% â("SelectObject",hDC%%,pr%%)
err%% â("DeleteObject",br%%)
Æ í
▒x%
err%% â("ReleaseDC",hWND%%,hDC%%)
EndPlot:
¼1,0,1,"{Any"
¼2,0,1,"key"
¼3,0,1,"to"
¼4,0,1,"Continue...}"
¼ │a%,b%
╧ Ña$
¼ à
┬"Another Plot?","",135,n%
ín% 0 p
ε à
ç
å t
Æ
Æ í
┬"Same Data?","",135,n%
ín% 0 p ─
agn% 9
wGetGraphType
DoPie:
hWND%% â("GetActiveWindow")
hDC%% â("GetDC",hWND%%)
tot% l(amt%)
òprct%
╫prct%(numunique%)
¢x% 1 qnumunique%
prct%(x%) (amt%(x%) tot%) 100
▒x%
ë £"PlotScrn"
╩ £ ╓0,0
╩ £ ╤9
╩ £ ╥9
| £1,0,0,750,950
╩ £ ╤0
╩ £ o"Tms Rmn,18,0"
title$ plotdata$ " vs. " against$ ":"
x% 60 ( /(title$) 2)
| £5,x%,6,title$
╩ £ o"Helv,8,0"
╩ £ s0
╩ £ ╓17,2
╜ Determine whether titles should go on left or right, then store
╜ in array of points.
òXtitle%,Ytitle%
╫Xtitle%(numunique%),Ytitle%(numunique%)
pie% 0
¢x% 1 qnumunique%
piepos% pie% ((prct%(x%) 100) P)
pie% pie% ((prct%(x%) 100) (2 P))
ípiepos%
P p ▒x%
╜ (Just found the Start of the left hand side)
left% x%
╜ Now find spacing of titles down left and right sides
nr% 90 (left% 1)
ns% 10
Xsc% σsys(6) 170
Ysc% σsys(7) 130
¢x% 1 qleft% 1
Xtitle%(x%) 140
Ytitle%(x%) ns% ((left% x%) nr%)
| £5,Xtitle%(x%),Ytitle%(x%),plot$(x%)
Xtitle%(x%) (Xtitle%(x%) Xsc%) 3
Ytitle%(x%) Ytitle%(x%) Ysc%
▒x%
nr1% 90 (numunique% left%)
¢x% left% qnumunique%
Xtitle%(x%) 1
Ytitle%(x%) ns% ((x% left%) nr1%)
| £5,Xtitle%(x%),Ytitle%(x%), +(plot$(x%),13)
Xtitle%(x%) (20 Xsc%) 3
Ytitle%(x%) Ytitle%(x%) Ysc%
▒x%
£1
XCent% σsys(6) 2
YCent% σsys(7) 2
pie% 0
xlow% σsys(6) 7
ylow% σsys(7) 10
xhi% σsys(6) (1.5 xlow%)
yhi% σsys(7) (1.5 ylow%)
clr% 1
xrad% ((xhi% xlow%) 2) 1.12
yrad% ((yhi% ylow%) 2) .98
¢x% 1 qnumunique%
pr%% â("CreatePen",0,0,16777215)
red% (clr% 3 0) {0:(clr% 3 1) {127:255
blu% ( (clr% 3) 3 0) {0:( (clr% 3) 3 1) {127:255
grn% ( (clr% 9) 3 0) {0:( (clr% 9) 3 1) {127:255
clr% (clr% 1) 26
colr% (blu% 65536) (grn% 256) red%
br%% â("CreateSolidBrush",colr%)
ob1%% â("SelectObject",hDC%%,pr%%)
ob%% â("SelectObject",hDC%%,br%%)
x1% (xrad% (pie%)) XCent%
y1% (yrad% (pie%)) YCent%
xh% (xrad% (pie% ((prct%(x%) 100) P))) XCent%
yh% (yrad% (pie% ((prct%(x%) 100) P))) YCent%
pie% pie% ((prct%(x%) 100) (2 P))
x2% ((xrad% (pie%))) XCent%
y2% ((yrad% (pie%))) YCent%
íx1% x2% y1% y2% wNextOne
err%% â("Pie",hDC%%,xlow%,ylow%,xhi%,yhi%,x1%,y1%,x2%,y2%)
NextOne:
err%% â("Rectangle",hDC%%,Xtitle%(x%) 4,Ytitle%(x%) 4,Xtitle%(x%) 4,Ytitle%(x%) 4)
br%% â("SelectObject",hDC%%,ob%%)
err%% â("DeleteObject",br%%)
br%% â("SelectObject",hDC%%,pr%%)
err%% â("DeleteObject",br%%)
▒x%
err%% â("ReleaseDC",hWND%%,hDC%%)
wEndPlot
AddDown:
¢zz% 1 q /(x$)
| £5,xloc% 1,81 (zz% 3), ,(x$,zz%,1)
▒zz%
├
NotIndex:
¼1,0,1,"Creating"
¼2,0,1,"Index..."
¼ │a%,b%
ë ú │against$$
yFMM1