File: plotchart.rb

# plotchart.rb

Path: | tk/lib/tkextlib/tcllib/plotchart.rb
Last Update: | Mon Oct 24 20:15:36 AUS Eastern Standard Time 2005

     tkextlib/tcllib/plotchart.rb
                                  by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

      * Part of tcllib extension
      * Simple plotting and charting package

(The following is the original description of the library.)

Plotchart is a Tcl-only package that focuses on the easy creation of xy-plots, barcharts and other common types of graphical presentations. The emphasis is on ease of use, rather than flexibility. The procedures that create a plot use the entire canvas window, making the layout of the plot completely automatic.

This results in the creation of an xy-plot in, say, ten lines of code:

       package require Plotchart

       canvas .c -background white -width 400 -height 200
       pack   .c -fill both

       #
       # Create the plot with its x- and y-axes
       #
       set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]

       foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
           $s plot series1 $x $y
       }

       $s title "Data series"

A drawback of the package might be that it does not do any data management. So if the canvas that holds the plot is to be resized, the whole plot must be redrawn. The advantage, though, is that it offers a number of plot and chart types:

       * XY-plots like the one shown above with any number of data series.
       * Stripcharts, a kind of XY-plots where the horizontal axis is adjusted
         automatically. The result is a kind of sliding window on the data
         series.
       * Polar plots, where the coordinates are polar instead of cartesian.
       * Isometric plots, where the scale of the coordinates in the two
         directions is always the same, i.e. a circle in world coordinates
         appears as a circle on the screen.
         You can zoom in and out, as well as pan with these plots (Note: this
         works best if no axes are drawn, the zooming and panning routines do
         not distinguish the axes), using the mouse buttons with the control
         key and the arrow keys with the control key.
       * Piecharts, with automatic scaling to indicate the proportions.
       * Barcharts, with either vertical or horizontal bars, stacked bars or
         bars side by side.
       * Timecharts, where bars indicate a time period and milestones or other
         important moments in time are represented by triangles.
       * 3D plots (both for displaying surfaces and 3D bars)

### Required files

tk tkextlib/tcllib.rb Plotchart Plotchart widget::panelframe

[Validate]