Version 8 of barchart

Updated 2002-07-19 16:49:58

Along with all the slick widget packages--BLT, ClassyTcl, and so on--which build in canvas-oriented barcharting, there's a dead-simple but too-little-known pure-Tcl technique for generating barcharts for Web applications.

[Show picture of example output [L1 ]. Show sample code. Discuss axes and legends. Explain alternatives for generation of color image. Refer to color codes.] [Probably written up 23 April 2002.]

A different way to roughly the same visual content is by way of JavaScript. This is interesting simply for its architectural distinctiveness. [L2 ] provides examples.

"Web special effects" has related information.


It's easy enough to whip together a simple barchart on a canvas without any extension. Here's an example:

    pack [canvas .c]
    set y_origin 100
    set x_origin 20
    set heights {11 30 15 16 77 5 14 12 8 33 9}
    foreach height $heights {
        set x_next [expr $x_origin + 5]
        .c create rectangle \
                  $x_origin $y_origin $x_next [expr $y_origin - $height]
        set x_origin $x_next
    }