Icon comes with a large number of graphics procedures in its ipl. Unlike
vidgets, these directly draw onto a given window and so do not need to be added
using VInsert
. Also, they do not respond to events.
A bar chart represents data using columns. The barchart implementation here allows for drawing bars in different directions, with various scalings (including logarithmic), and can be updated dynamically to increase the number or value of bars.
The following example is taken from the barchart documentation.
link vidgets link barchart procedure main() win := Window("label=BarChart", "size=500,300") root := Vroot_frame(win) # create the barchart # position is 10, 190 # next bar is 10 pixels to right, 0 pixels up # direction is -5, i.e. growing to smaller 7 values # maximum number of bars is 21 # maximum length is 180 # width of a bar is 8 bc := barchart(win, 10, 190, 10, 0, -5, 21, 180, 8) # create a list of random scores scores := [] every 1 to 100 do put(scores, ?100) # add them to the barchart b := list(21, 0) # histogram bins every n := !scores do { i := n / 5 # bin (and bar) number b[i] +:= 1 # increment bin count setbar(bc, i, b[i]) # update display } GetEvents(root) end