source: FOIAVistA/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDUG1.m@ 1639

Last change on this file since 1639 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.4 KB
Line 
1KMPDUG1 ;OAK/RAK - CM Tools Graph Utility ;2/17/04 09:58
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;;Mar 22, 2002
3 ;
4DRAW ;-- draw graph
5 W @IOF,!,IOG1 S DY=2
6 ; draw top line
7 F I=1:1:27 S DX=41+I X IOXY W IOHL S DX=43-I X IOXY W IOHL
8 ; draw top left and right corners
9 S DX=15 X IOXY W IOTLC S DX=68 X IOXY W IOTRC,!
10 ; draw sides
11 F DY=(DY+1):1:BOTTOM F DX=15,68 X IOXY W IOVL,!
12 ; draw bottom left and right corners
13 S DY=BOTTOM,DX=15 X IOXY W IOBLC S DX=68 X IOXY W IOBRC,!
14 ; draw bottom line
15 F I=1:1:27 S DX=15+I X IOXY W IOHL S DX=68-I X IOXY W IOHL
16 ; draw 'hash marks' on bottom line for relative values
17 S DX=15 X IOXY W IOLT,!
18 F DX=20:5:65 X IOXY W IOMT,!
19 ; print grid
20 I KMPUOPT["G" D
21 .S DY=2 F DX=20:5:65 X IOXY W IOTT,!
22 . F DX=20:5:65 F DY=3:1:(BOTTOM-1) X IOXY W IOVL,!
23 W IOG0
24 Q
25INIT ;-- initialize required variables.
26 D GSET^%ZISS S X="IOECH;IORVOFF;IORVON;IOUOFF;IOUON" D ENDR^%ZISS
27 ; actual bars representing data
28 S BAR(0)="IORVON,"" "",IORVOFF"
29 S BAR(1)="IOG1,""a"",IOG0"
30 S (DEC,DNUM,MAX,MIN,SCALE,YNUM)=0,GWIDTH=$S(KMPUOPT["V":10,1:50)
31 S TITLE=$P($G(KMPUTI),U,1,2)
32 S XTITLE=$P($G(KMPUTI),U,3)
33 S YTITLE=$P($G(KMPUTI),U,4)
34 ; determine maximum and minimum number and decimals (if any).
35 S (I,MAX,MIN)=""
36 F S I=$O(@KMPUAR@(I)) Q:I="" I $D(@KMPUAR@(I,0)) S YNUM=YNUM+1 D
37 .I $P(@KMPUAR@(I,0),U,2)>MAX S MAX=$P(@KMPUAR@(I,0),U,2)
38 .I $P(@KMPUAR@(I,0),U,2)<MIN S MIN=$P(@KMPUAR@(I,0),U,2)
39 .; determine number of decimal places (if any).
40 .S DNUM=$P($P(@KMPUAR@(I,0),U,2),".",2) Q:'DNUM
41 .I $L(DNUM)>DEC S DEC=$L(DNUM)
42 Q:MAX'>0
43 ; get maximum number for graph.
44 D MAX
45 ; determine if there are decimal places when printed at end of graph
46 S I="" F S I=$O(@KMPUAR@(I)) Q:I="" I $D(@KMPUAR@(I,0)) D
47 .S Z=$L($P($P(@KMPUAR@(I,0),U,2)/DIV,".",2)) Q:'Z
48 .I Z>DEC S DEC=$S(Z>2:2,1:1)
49 S BOTTOM=$S(KMPUOPT["D":(YNUM*2+2),1:(YNUM+3))
50 S SCALE=((MAX-KMPUSTRT)/10),STEP=((MAX-KMPUSTRT)/GWIDTH)
51 S NUM=(SCALE+KMPUSTRT)
52 ; determine if relative values have decimal
53 S DEC1=0 F I=20:5:65 I $L($P((NUM/DIV),".",2)) D
54 .S DEC1=$S($L($P((NUM/DIV),".",2))>2:2,1:1)
55 Q
56 ;
57MAX ;-- determine 'max' or largest number for graph.
58 ;
59 S:$G(KMPUMAX) MAX=KMPUMAX
60 S DIV=1,MAX=$FN(MAX,"",0)
61 I MAX<2 S MAX=1 Q
62 S X=1 F I=1:1:$L(MAX)-1 S X=X*10 I MAX=X S X=X/10
63 S MAX=$E(MAX-1)+1*X
64 I $L(MAX)>4 D
65 .F I=1:1:($L(MAX)-1) S DIV=DIV_"0"
66 .I $L(DIV)<7 S DIVT=$S(KMPUOPT["S":"10^"_I,1:(DIV/1000)_"k") Q
67 .S DIVT=$S(KMPUOPT["S":"10^"_I,1:(DIV/1000000)_"m")
68 Q
69 ;
70TITLES ;-- print graph titles.
71 W IOG0
72 ; print first and second line of title
73 S DX=(IOM-$L($P(TITLE,U))\2+1),DY=0 X IOXY W $P(TITLE,U),!
74 S DX=(IOM-$L($P(TITLE,U,2))\2+1),DY=1 X IOXY W $P(TITLE,U,2),!
75 ; print y title
76 S DX=(14-$L(YTITLE)) X IOXY W IOUON,YTITLE,IOUOFF,!
77 ; print relative values under hash marks
78 S NUM=(SCALE+KMPUSTRT)
79 S DY=BOTTOM+1,DX=15-$S($L($FN((KMPUSTRT/DIV),"",DEC1))=1:0,1:$L($FN((KMPUSTRT/DIV),"",DEC1))-2) X IOXY W $FN((KMPUSTRT/DIV),"",DEC1),!
80 F I=20:5:65 D
81 .I $L($FN((NUM/DIV),"",DEC1))=1 S DX=(I-$L($FN((NUM/DIV),"",DEC1))+1)
82 .E S DX=(I-($L($FN((NUM/DIV),"",DEC1))-2))
83 .X IOXY W $FN((NUM/DIV),"",DEC1),! S NUM=NUM+SCALE
84 ; if div>1 write (x div)
85 I DIV>1 S DX=69 X IOXY W "<x",DIVT,">",!
86 ; print x title at bottom
87 S DX=(IOM-$L(XTITLE)\2+1),DY=BOTTOM+2 X IOXY W IOUON,XTITLE,IOUOFF,!
88 ; print data titles
89 S DY=3,I=0 F S I=$O(@KMPUAR@(I)) Q:'I I $D(@KMPUAR@(I,0)) D
90 .S YTITLE=$E($P(@KMPUAR@(I,0),U),1,14)
91 .S DX=(14-$L(YTITLE)) X IOXY W YTITLE,!
92 .S DY=DY+$S(KMPUOPT["D":2,1:1)
93 Q
Note: See TracBrowser for help on using the repository browser.