4
require 'tkextlib/tcllib/plotchart'
6
###############################
8
c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
9
c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
10
Tk.pack(c1,c2, :fill=>:both, :side=>:top)
12
###############################
13
# Set up a strip chart
14
###############################
15
slipchart = Tk::Tcllib::Plotchart::Stripchart.new(c1, [0.0, 100.0, 10.0],
18
TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object
19
slipchart, xold, xd, yold, yd = obj.return_value
21
ynew = yold + (rand() - 0.5) * yd
22
ynew2 = yold + (rand() - 0.5) * 2.0 * yd
23
slipchart.plot('series1', xnew, ynew)
24
slipchart.plot('series2', xnew, ynew2)
25
obj.stop if xnew >= 200
26
[slipchart, xnew, xd, ynew, yd] # return_value
29
[slipchart, 0.0, 15.0, 50.0, 30.0]
32
slipchart.title "Aha!"
34
###############################
35
# Set up an isometric plot
36
###############################
37
s = Tk::Tcllib::Plotchart::IsometricPlot.new(c2, [0.0, 100.0], [0.0, 200.0],
42
s.plot('rectangle', [10.0, 10.0, 50.0, 50.0], 'green')
43
s.plot('filled-rectangle', [20.0, 20.0, 40.0, 40.0], 'red')
44
s.plot('filled-circle', [70.0, 70.0, 40.0], 'yellow')
45
s.plot('circle', [70.0, 70.0, 42.0])
47
###############################
49
###############################
50
h = TkToplevel.new(:title=>'h')
51
c = TkCanvas.new(h, :bg=>'white', :width=>400, :height=>200).pack(:fill=>:both)
53
s = Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0],
55
s.dataconfig('series1', :colour=>'red', :type=>:symbol)
56
s.dataconfig('series2', :colour=>'green', :type=>:both)
58
s.yconfig(:format=>"%12.2e")
61
%w(plus cross circle up down dot upfilled downfilled).each{|sym|
62
s.dataconfig('series1', :symbol=>sym)
63
s.dataconfig('series2', :symbol=>sym)
64
s.plot('series1', x, 50.0)
65
s.plot('series2', x, 20)
69
##############################