source: trunk/kitgen/8.x/blt/vertical_axis.tcl@ 175

Last change on this file since 175 was 175, checked in by demin, 12 years ago

initial commit

File size: 1.1 KB
Line 
1package require BLT
2
3pack [blt::graph .g]
4
5# Proc passed as a callback to BLT to draw custom tick labels.
6#
7proc format_yAxis_tick {win value} {
8 if {$value == [$win axis cget y -max]} {
9 set yAxisHeightPixels [expr {abs (
10 [$win axis transform y [$win axis cget y -max]] -
11 [$win axis transform y [$win axis cget y -min]])}]
12
13 set font [$win axis cget y -tickfont]
14
15 set yAxisHeightLines [expr {$yAxisHeightPixels /
16 [font metrics $font -linespace]}]
17
18 set v [string repeat "\n" [expr {$yAxisHeightLines / 2}]]
19 set h [string repeat " " [expr {
20 [font measure $font "$::y_title "] /
21 [font measure $font " "]}]]
22 return "$v$h$value$v$::y_title"
23 } else {
24 return $value
25 }
26}
27
28# The following global is used by the callback "format_yAxis_tick".
29set y_title "Y axis title"
30
31# Configure the vertical axis.
32.g axis configure y -min 0 -max 100 -majorticks \
33 {0 10 20 30 40 50 60 70 80 90 100}
34
35# Need to force the graph to be drawn before distances can be
36# measured.
37update
38
39.g axis configure y -command format_yAxis_tick
Note: See TracBrowser for help on using the repository browser.