/usr/share/blt2.4/demos/barchart3.tcl is in blt-demo 2.4z-4.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #!/usr/bin/wish
package require BLT
# --------------------------------------------------------------------------
# Starting with Tcl 8.x, the BLT commands are stored in their own
# namespace called "blt". The idea is to prevent name clashes with
# Tcl commands and variables from other packages, such as a "table"
# command in two different packages.
#
# You can access the BLT commands in a couple of ways. You can prefix
# all the BLT commands with the namespace qualifier "blt::"
#
# blt::graph .g
# blt::table . .g -resize both
#
# or you can import all the command into the global namespace.
#
# namespace import blt::*
# graph .g
# table . .g -resize both
#
# --------------------------------------------------------------------------
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
source scripts/demo.tcl
source scripts/stipples.tcl
source scripts/patterns.tcl
option add *graph.xTitle "X Axis Label"
option add *graph.yTitle "Y Axis Label"
option add *graph.title "A Simple Barchart"
option add *graph.xFont *Times-Medium-R*12*
option add *graph.elemBackground white
option add *graph.elemRelief raised
set visual [winfo screenvisual .]
if { $visual != "staticgray" && $visual != "grayscale" } {
option add *print.background yellow
option add *quit.background red
}
htext .header -text {
This is an example of the barchart widget. To create a postscript
file "bar.ps", press the %%
button $htext(widget).print -text {Print} -command {
$graph postscript output bar.ps -maxpect 1
}
$htext(widget) append $htext(widget).print
%% button.}
set graph [barchart .b]
$graph configure \
-invert true \
-baseline 1.2
$graph xaxis configure \
-command FormatLabel \
-descending true
$graph legend configure \
-hide yes
htext .footer -text {Hit the %%
button $htext(widget).quit -text quit -command exit
$htext(widget) append $htext(widget).quit
%% button when you've seen enough.%%
label $htext(widget).logo -bitmap BLT
$htext(widget) append $htext(widget).logo -padx 20
%%}
set names { One Two Three Four Five Six Seven Eight }
if { $visual == "staticgray" || $visual == "grayscale" } {
set fgcolors { white white white white white white white white }
set bgcolors { black black black black black black black black }
} else {
set fgcolors { red green blue purple orange brown cyan navy }
set bgcolors { green blue purple orange brown cyan navy red }
}
set bitmaps {
bdiagonal1 bdiagonal2 checker2 checker3 cross1 cross2 cross3 crossdiag
dot1 dot2 dot3 dot4 fdiagonal1 fdiagonal2 hline1 hline2 lbottom ltop
rbottom rtop vline1 vline2
}
set numColors [llength $names]
for { set i 0} { $i < $numColors } { incr i } {
$graph element create [lindex $names $i] \
-data { $i+1 $i+1 } \
-fg [lindex $fgcolors $i] \
-bg [lindex $bgcolors $i] \
-stipple [lindex $bitmaps $i] \
-relief raised \
-bd 2
}
$graph element create Nine \
-data { 9 -1.0 } \
-fg red \
-relief sunken
$graph element create Ten \
-data { 10 2 } \
-fg seagreen \
-stipple hobbes \
-background palegreen
$graph element create Eleven \
-data { 11 3.3 } \
-fg blue
# -coords { -Inf Inf }
$graph marker create bitmap \
-coords { 11 3.3 } -anchor center \
-bitmap @bitmaps/sharky.xbm \
-name bitmap \
-fill ""
$graph marker create polygon \
-coords { 5 0 7 2 10 10 10 2 } \
-name poly -linewidth 0 -fill ""
table . \
.header 0,0 -padx .25i \
$graph 1,0 -fill both \
.footer 2,0 -padx .25i
table configure . r0 r2 -resize none
wm min . 0 0
proc FormatLabel { w value } {
# Determine the element name from the value
set displaylist [$w element show]
set index [expr round($value)-1]
set name [lindex $displaylist $index]
if { $name == "" } {
return $name
}
# Return the element label
set info [$w element configure $name -label]
return [lindex $info 4]
}
Blt_ZoomStack $graph
Blt_Crosshairs $graph
Blt_ActiveLegend $graph
Blt_ClosestPoint $graph
$graph marker bind all <B3-Motion> {
set coords [%W invtransform %x %y]
catch { %W marker configure [%W marker get current] -coords $coords }
}
$graph marker bind all <Enter> {
set marker [%W marker get current]
catch { %W marker configure $marker -fill green -outline black}
}
$graph marker bind all <Leave> {
set marker [%W marker get current]
catch {
set default [lindex [%W marker configure $marker -fill] 3]
%W marker configure $marker -fill "$default"
}
}
|