File: plothist.test

package info (click to toggle)
tklib 0.5-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 7,136 kB
  • ctags: 1,658
  • sloc: tcl: 36,353; sh: 3,045; ansic: 792; makefile: 105; exp: 21; sed: 16
file content (40 lines) | stat: -rwxr-xr-x 904 bytes parent folder | download | duplicates (5)
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
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

package require Tcl 8.4
package require Tk
package require Plotchart

# plothist.test --
#     Testing histograms
#
    canvas .c -width 600 -height 400 -bg white
    pack   .c -fill both
    .c delete all

    set s [::Plotchart::createHistogram .c {0.0 100.0 10.0} {0.0 100.0 20.0}]

    $s dataconfig series1 -colour green

    set xd    5.0
    set yd   20.0
    set xold  0.0
    set yold 50.0

    for { set i 0 } { $i < 20 } { incr i } {
	set xnew [expr {$xold+$xd}]
	set ynew [expr {$yold+(rand()-0.5)*$yd}]
	$s plot series1 $xnew $ynew
	set xold $xnew
	set yold $ynew
    }

    $s balloonconfig -background green -rimwidth 3 -arrowsize 10 -font "Times 14"
    $s balloon 50 50 "Here it is!"  south-east

    $s balloonconfig -background red
    $s balloonconfig -margin 10
    $s balloon 50 100 "No, here!"  north-east

    $s title "Aha!"