File: testneedle.tcl

package info (click to toggle)
tklib 0.6%2B20190108-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,008 kB
  • sloc: tcl: 75,757; sh: 5,789; ansic: 792; pascal: 359; makefile: 70; sed: 53; exp: 21
file content (37 lines) | stat: -rwxr-xr-x 747 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
#!/usr/bin/env tclsh
## -*- tcl -*-

# testneedle.tcl --
#     Introduce a new plot method: draw a "needle" for each data point
#
package require Plotchart

pack [canvas .c]
set p [::Plotchart::createXYPlot .c {0.0 100.0 20.0} {-10.0 10.0 5.0}]

$p dataconfig data -symbol dot -type symbol

#
# Register a new plot method
#
proc DrawNeedle {p w type x y} {
    #
    # Draw the line from (x,0) to (x,y)
    #
    $p plot needle $x {}   ;# Cause a break
    $p plot needle $x 0.0
    $p plot needle $x $y
}

::Plotchart::plotmethod xyplot needle DrawNeedle

#
# Draw the y-axis
#
$p plot axis   0.0 0.0
$p plot axis 100.0 0.0

foreach {x y} {5.0 3.0   6.0 -1.0   40.0 4.2   53.0 6.0   80.0 -7.0} {
    $p plot data $x $y
    $p needle data $x $y
}