% From Window Programming in Mozart by Christian Schulte declare local O=if Tk.isColor then o(fill:wheat) else o(stipple:gray50 fill:black) end D=9 D2=2*D B=10 in class BarCanvas from Tk.canvas meth DrawBars(Ys H X) case Ys of nil then skip [] Y|Yr then {self tk(create rectangle X H X+D H-Y*D2 O)} {self tk(create text X H+D+1 text:Y anchor:w)} {self DrawBars(Yr H X+D2)} end end meth configure(SX SY) {self tk(configure scrollregion:q(B ~B SX+B SY+B))} end meth bars(Ys) WY=D2*({Length Ys}+1) HY=D2*({FoldL Ys Max 0}+1) in {self configure(WY HY)} {self DrawBars(Ys HY D)} end end end W={New Tk.toplevel tkInit(title:'BarGraph')} C={New BarCanvas tkInit(parent:W bg:white width:500 height:200)} H={New Tk.scrollbar tkInit(parent:W orient:horizontal)} V={New Tk.scrollbar tkInit(parent:W orient:vertical)} {Tk.addXScrollbar C H} {Tk.addYScrollbar C V} {Tk.batch [grid(C row:0 column:0) grid(H row:1 column:0 sticky:we) grid(V row:0 column:1 sticky:ns)]} {C bars([1 3 4 5 3 4 2 1 7 2 3 4 2 4 5 6 7 7 8 4 3 5 6 7 7 8 4 3])}