File: crosshairs_for_multixyplot.tcl

package info (click to toggle)
tklib 0.8~20230222-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 20,904 kB
  • sloc: tcl: 97,356; sh: 5,823; ansic: 792; pascal: 359; makefile: 70; sed: 53; exp: 21
file content (55 lines) | stat: -rw-r--r-- 1,788 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env tclsh
## -*- tcl -*-

package require Tk

# test_txplot.tcl --
#     Test the -box options for time-x-plots

package require crosshair
package require Plotchart

pack [canvas .c -width 600 -height 410 -bg white]

::Plotchart::plotstyle configure default xyplot bottomaxis subtextcolor blue
::Plotchart::plotstyle configure default xyplot bottomaxis font         "Helvetica 14"
::Plotchart::plotstyle configure default xyplot bottomaxis subtextfont  "Helvetica 12 bold"
::Plotchart::plotstyle configure default xyplot leftaxis   font         "Helvetica 14"
::Plotchart::plotstyle configure default xyplot leftaxis   subtextfont  "Helvetica 12 bold"
::Plotchart::plotstyle configure default xyplot leftaxis   subtextcolor red
::Plotchart::plotstyle configure default xyplot leftaxis   usesubtext   1

set p1 [::Plotchart::createXYPlot .c {0 100 30} {0 20 5} -box {0 0 400 200}]
set p2 [::Plotchart::createXYPlot .c {0 100 30} {0 20 5} -box {100 210 400 200}]

#.c create rectangle 0 210 400 410

$p1 plot data 0 10
$p1 plot data 100 15

$p1 xtext    Aha
#$p1 xsubtext "1, 2, 3"
$p1 ytext    "Same spot?"

$p2 plot data 0 10
$p2 plot data 100 15
$p2 ytext    "Higher up"
#$p2 ysubtext "Lower down"
$p2 vtext    "To the left"
#$p2 vsubtext "To the right"


.c configure -cursor tcross
crosshair::crosshair .c -dash {.} -fill blue
#crosshair::track on  .c put_coords

set bbox_ll [::Plotchart::coordsToPixel [$p1 canvas] 0 0 ]
set bbox_ur [::Plotchart::coordsToPixel [$p1 canvas] 100 20]
set bbox_p1 [concat $bbox_ll $bbox_ur]
crosshair::bbox_add .c "$bbox_p1"
set bbox_ll [::Plotchart::coordsToPixel [$p2 canvas] 0 0 ]
set bbox_ur [::Plotchart::coordsToPixel [$p2 canvas] 100 20]
set bbox_p2 [concat $bbox_ll $bbox_ur]
crosshair::bbox_add .c "$bbox_p2"

catch { console show }