Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: KMPDUG

KMPDUG.m

Go to the documentation of this file.
  1. KMPDUG ;OAK/RAK - CM Tools Graph Utility ;2/17/04 09:57
  1. ;;3.0;KMPD;;Jan 22, 2009;Build 42
  1. ;
  1. EN(KMPUAR,KMPUTI,KMPUOPT,KMPUSTRT,KMPUTAR,KMPUXIT,KMPUMAX) ;entry point
  1. ;-----------------------------------------------------------------------
  1. ; KMPUAR.. Local or global array (passed by value) that contains graph
  1. ; information in the format:
  1. ;
  1. ; KMPUAR(...,0)=DataTitle^DataValue
  1. ; piece 1 - the title of the data
  1. ; piece 2 - the actual value of the data
  1. ;
  1. ; KMPUTI.. graph titles in 4 up-arrow pieces
  1. ; piece 1 - title of the graph
  1. ; piece 2 - second title of graph (if any)
  1. ; piece 3 - x axis title
  1. ; piece 4 - y axis title
  1. ;
  1. ; KMPUOPT. (optional) A string of one or more letters representing
  1. ; desired options.
  1. ; "A" - angle titles (only for vertical graph)
  1. ; "D" - double space
  1. ; "G" - print grid across graph
  1. ; "S" - display entries with MAX>9999 in scientific notation
  1. ; "V" - display 'vertical' graph
  1. ;
  1. ; KMPUSTRT (optional). Number to start graph.
  1. ; if KMPUSTRT=0 first hash mark of graph will equal 0
  1. ;
  1. ; KMPUTAR. (optional) Text array. Local or global array that
  1. ; contains text to be displayed with the graph.
  1. ;
  1. ; Example: KMPUTAR="UTIL($J,"
  1. ; KMPUTAR="^ASK(999999,23,10,"
  1. ; KMPUTAR="^TMP($J,""TEXT"","
  1. ;
  1. ; KMPUXIT. (optional) Exit without 'continue' text. This allows the
  1. ; programmer to use their own display for continuing
  1. ; 0 - do not exit - display 'continue' text
  1. ; 1 - exit
  1. ;
  1. ; KMPUMAX. (optional) Maximum scale - if not defined, the maximum value
  1. ; is determined from the data passed. If KMPUMAX is defined,
  1. ; scale will be adjusted accordingly.
  1. ;-----------------------------------------------------------------------
  1. ;
  1. I '$D(KMPUAR) W !!?7,"...no array data...",!! D CONT Q
  1. S KMPUSTRT=+$G(KMPUSTRT),KMPUOPT=$$UP^XLFSTR($G(KMPUOPT))
  1. S KMPUXIT=+$G(KMPUXIT),KMPUMAX=+$G(KMPUMAX)
  1. K:$G(KMPUTAR)="" KMPUTAR
  1. I '$D(@KMPUAR) D Q
  1. .W *7,!!?7,"...no information to graph...",!!
  1. .D CONT
  1. S DTIME=$S($D(DTIME):DTIME,1:600)
  1. ;
  1. N BAR,BOTTOM,DATA,DEC,DEC1,DIV,DIVT,DNUM,DX,DY,END,GWIDTH,I,I1,LABEL,MAX
  1. N MIN,NUM,OFFSET,SCALE,STEP,TEXT,TITLE,X,XCOORD,XTITLE,YNUM,YTITLE,Z
  1. N IOBLC,IOBRC,IOBT,IOG1,IOG0,IOHL,IOLT,IOMT,IORT,IOTLC,IOTRC,IOTT,IOVL
  1. N IOINHI,IOINLOW,IORVOFF,IORVON,IOUOFF,IOUON
  1. ;
  1. D INIT^KMPDUG1 I KMPUOPT["D",(KMPUOPT'["V"),(YNUM>8) D Q
  1. .W *7,!!?7,"...too many data elements to double space on a terminal"
  1. .W !?7," for a Horizontal Graph..."
  1. .W !!! D CONT
  1. I KMPUOPT["D",(KMPUOPT["V"),(YNUM>34) D Q
  1. .W *7,!!?7,"...too many data elements to double space on a terminal"
  1. .W !?7," for a Vertical Graph..."
  1. .W !!! D CONT
  1. ; if not a terminal do printer routine
  1. I $E(IOST)'="C" Q ;D EN^KMPUGP Q
  1. I $G(IOG1)']""!($G(IOG0)']"") D Q
  1. .W *7,!!?7,"...unable to place terminal in graphics mode...",!!
  1. .D CONT
  1. I 'MAX D Q
  1. .W *7,!!?7,"...unable to determine any data to graph or data all zeros...",!!
  1. .D CONT
  1. ; if 'vertical' graph
  1. I KMPUOPT["V" D EN^KMPDUGV Q
  1. ; draw graph - display titles - display data
  1. D DRAW^KMPDUG1,TITLES^KMPDUG1,DATA
  1. ; if text to display.
  1. I $D(KMPUTAR) D WP^KMPDU11(KMPUTAR,(BOTTOM+5),24) Q
  1. D:'KMPUXIT CONT
  1. Q
  1. ;
  1. CONT ;-- hold screen
  1. S DX=(IOM-23\2),DY=(IOSL-1) X IOXY
  1. R "Press <RET> to continue",X:DTIME
  1. Q
  1. ;
  1. DATA ;-- display data in graph.
  1. W IOG0 S DY=$S(KMPUOPT["D":1,1:2),BAR=0,I=""
  1. F S I=$O(@KMPUAR@(I)) Q:I="" I $D(@KMPUAR@(I,0)) S DATA=@KMPUAR@(I,0) D
  1. .S XCOORD=$P(DATA,U,2),END=(XCOORD-KMPUSTRT-STEP)
  1. .S DX=16,DY=DY+$S(KMPUOPT["D":2,1:1)
  1. .; if no data quit
  1. .Q:$P(@KMPUAR@(I,0),U,2)']""
  1. .F I1=0:STEP:END X IOXY W @BAR(BAR),! S DX=DX+1 Q:DX=68
  1. .; print value in parenthesis
  1. .S DX=69 X IOXY W "<",$J((XCOORD/DIV),$L($FN((MAX/DIV),"",DEC)),DEC),">"
  1. .S BAR=$S(BAR=1:0,1:1)
  1. Q