How to download and try this example
Usage: pl -gif students.htm This example can take a variable number of data fields. It uses a loop to iterate across fields 3 .. N (fields 1 and 2 are identifiers). The first record of data contains field names. These names are accessed using the $fieldname() function and added to the legend.
#set COLORLIST = red,yellow,blue,green,orange,pink,black,white // added scg 8/4/04.. allows spaces to be represented using underscores.. #proc settings encodenames: yes #proc page pagesize: 7 4 #if @DEVICE in gif,png scale: 0.6 #endif #proc getdata fieldnameheader: yes #intrailer // get data from end of this file #endproc //necessary in order to do the following computation involving NRECORDS // compute XMAX (number of records+1 for bar graphs) #set XMAX = $arith(@NRECORDS+1) // set up area #proc areadef title: Student exam scores rectangle: 1 1 6 3 xrange: 0 @XMAX yrange: 0 100 // no way currently to do autorange on variable # of fields xaxis.stubs: datafield=1 xaxis.label: Student yaxis.stubs: inc 10 yaxis.label: Score // initialize loop variables #set I = 3 #set NCLUST = $arith(@NFIELDS-2) // start loop #loop // set vars for this iteration #set FNAME = $fieldname(@I) // this function is new #set ICLUST = $arith(@I-2) #set COLOR = $nmember(@ICLUST,@COLORLIST) // do bars #proc bars lenfield: @I cluster: @ICLUST / @NCLUST color: @COLOR #hideund legendlabel: @FNAME #showund barwidth: 0.1 // update I and see if time to stop.. #set I = $arith(@I+1) #if @I > @NFIELDS #break #endif #endloop // slap on the legend #proc legend format: singleline location: 1 0.5 sep: 0.5 // here's the data #proc trailer data: id group Exam_a Exam_b Exam_c Exam_d 01001 N 44 45 71 89 01002 N 56 44 54 36 01003 B 46 63 28 87 01004 B 42 28 39 49 01005 B 52 74 84 66