home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / demos / barchart2 < prev    next >
Encoding:
Text File  |  1995-07-01  |  4.6 KB  |  142 lines

  1. #!../blt_wish -f
  2.  
  3. if [file exists ../library] {
  4.     set blt_library ../library
  5. }
  6. set graph .graph
  7.  
  8. blt_bitmap define pattern1 { {4 4} {01 02 04 08} }
  9. blt_bitmap define pattern2 { {4 4} {08 04 02 01} }
  10. blt_bitmap define pattern3 { {2 2} {01 02 } }
  11. blt_bitmap define pattern4 { {4 4} {0f 00 00 00} }
  12. blt_bitmap define pattern5 { {4 4} {01 01 01 01} }
  13. blt_bitmap define pattern6 { {2 2} {01 00 } }
  14. blt_bitmap define pattern7 { {4 4} {0f 01 01 01} }
  15. blt_bitmap define pattern8 { {8 8} {ff 00 ff 00 ff 00 ff 00 } }
  16. blt_bitmap define pattern9 { {4 4} {03 03 0c 0c} }
  17. blt_bitmap define hobbes { {25 25} {
  18.    00 00 00 00 00 00 00 00 00 c0 03 00 78 e0 07 00 fc f8 07 00 cc 07 04 00
  19.    0c f0 0b 00 7c 1c 06 00 38 00 00 00 e0 03 10 00 e0 41 11 00 20 40 11 00
  20.    e0 07 10 00 e0 c1 17 00 10 e0 2f 00 20 e0 6f 00 18 e0 2f 00 20 c6 67 00
  21.    18 84 2b 00 20 08 64 00 70 f0 13 00 80 01 08 00 00 fe 07 00 00 00 00 00
  22.    00 00 00 00 }
  23. }
  24.  
  25. option add *Blt_htext.font *Times-Bold-R*14*
  26. option add *Blt_barchart*TagFont *Helvetica-Bold-R*14*
  27. option add *Blt_barchart*xTitle "Simulator"
  28. option add *Blt_barchart*yTitle "Time (hrs)"
  29. option add *Blt_barchart*title "A Simple Barchart"
  30. option add *Blt_barchart*xFont *Times-Bold-R*14*
  31. option add *Blt_barchart.font *Helvetica-Bold-R*14*
  32. option add *Blt_barchart*legendMapped false
  33. option add *Blt_barchart*elemBackground white
  34. option add *Blt_barchart*elemActiveBackground white
  35. option add *Blt_barchart*elemRelief raised
  36.  
  37. set visual [winfo screenvisual .] 
  38. if { $visual != "staticgray" && $visual != "grayscale" } {
  39.     option add *print.background yellow
  40.     option add *quit.background red
  41. }
  42.  
  43. blt_htext .header -text \
  44. {This is an example of the blt_barchart widget.  The barchart has 
  45. many components; x and y axis, legend, crosshairs, elements, etc.  
  46. You can configure any component by pressing this %% 
  47. button $blt_htext(widget).config -text button \
  48.     -command "exec [list ../blt_wish -f ./grconf.tcl [winfo name .] $graph &]"\
  49.     -bg green
  50. $blt_htext(widget) append $blt_htext(widget).config
  51. %%.
  52.  
  53. To create a postscript file "bar.ps", press the %%
  54. button $blt_htext(widget).print -text {Print} -command {
  55.   $graph postscript bar.ps -pagewidth 6.5i -pageheight 9i -landscape true
  56. $blt_htext(widget) append $blt_htext(widget).print
  57. %% button.}
  58.  
  59. blt_barchart $graph 
  60. $graph xaxis configure -rotate 0
  61.  
  62. blt_htext .footer -text {Hit the %%
  63. button $blt_htext(widget).quit -text quit -command {destroy .} 
  64. $blt_htext(widget) append $blt_htext(widget).quit 
  65. %% button when you've seen enough.%%
  66. label $blt_htext(widget).logo -bitmap BLT
  67. $blt_htext(widget) append $blt_htext(widget).logo -padx 20
  68. %%}
  69.  
  70. set names { One Two Three Four Five Six Seven Eight }
  71. if { $visual == "staticgray" || $visual == "grayscale" } {
  72.     set fgcolors { white white white white white white white white }
  73.     set bgcolors { black black black black black black black black }
  74. } else {
  75.     set fgcolors { red green blue purple orange brown cyan navy }
  76.     set bgcolors { green blue purple orange brown cyan navy red }
  77. }
  78. set numColors [llength $names]
  79.  
  80. set labels { { Read In } { Setup } { Load } { Solve } { Other } }
  81. set colors { green orange violet dodgerblue red }
  82. set stipples { 
  83.     pattern1 pattern2 pattern3 pattern4 pattern5 
  84.     pattern6 pattern7 pattern8 pattern9 hobbes
  85. }
  86. set stipples { 
  87.     pattern9 hobbes
  88. }
  89.  
  90. set data { 
  91.     { A1 { 0.729111111 0.003120278 11.534444444 1.015750000 0.022018611 } }
  92.     { B1 { 0.002250000 0.004638889 3.879722222 0.462888889 0.516333333 } }
  93.     { A2 { 0.09108333 0.01113889 4.54444444 0.49394444 0.54772222 } }
  94.     { B2 { 0.006416667 0.048888889 4.460277778 0.429166667 0.177638889 } }
  95.     { C1 { 0.026509167 0.001814722 2.334055556 1.053694444 0.021703889 } }
  96.     { D1 { 0.007027778 0.291388889 1.262194444 0.466111111 0.134305556 } }
  97.     { C2 { 0.1628611 0.0503500 1.8009444 1.4152500 0.5189278 } }
  98.     { A3 { 0.06405278 0.13876389 4.12194444 2.17538889 0.07957222 } }
  99.     { E1 { 0.08786667 0.04513333 3.24527778 2.55294444 0.41155556 } }
  100. }
  101.  
  102.  
  103. set count 1
  104. foreach i $data {
  105.     set name [lindex $i 0]
  106.     set y-values [lindex $i 1]
  107.     $graph element create $name \
  108.     -ydata ${y-values}  \
  109.     -xdata $count \
  110.     -fg $colors \
  111.     -stipple $stipples \
  112.     -stacked true \
  113.     -bd 2 
  114.     set label {}
  115.     incr count
  116. }
  117.  
  118. set count 0
  119. foreach i $labels {
  120.     set name [lindex $i 0]
  121.     set y-values [lindex $i 1]
  122.     set tag [$graph tag create text "Inf 8+$count" ] 
  123.     $graph tag configure $tag \
  124.     -text $i \
  125.     -bg [lindex $colors $count ] \
  126.     -fg black \
  127.     -xoffset -10 \
  128.     -anchor e
  129.     incr count
  130. }
  131.  
  132. pack append . \
  133.     .header { padx 20 pady 10 }  \
  134.     .graph {} \
  135.     .footer { padx 20 pady 10 }
  136.     
  137. wm min . 0 0
  138.  
  139. source features.tcl
  140. SetClosestPoint .graph
  141.