NAME
Tk::Graph - A graphical Chartmaker at Canvas (Realtime). This is a real Canvaswidget, also you can draw with the standart routuines in this canvas object. In an example, you can draw a line with $chart->line(x,y,...). Is importand for you when you will add a logo or write a text in your created Chart.
SYNOPSIS
use Tk; use Tk::Graph;
my $mw = MainWindow->new;
my $data = { sleep => 51, Work => 135, Access => 124, MySQL => 5 };
my $ca = $mw->Graph( -type => 'BARS', )->pack( -expand => 1, -fill => 'both', );
$ca->configure(-variable => $data); # bind to data
# or ...
$ca->set($data); # set data
MainLoop;
WIDGET-SPECIFIC OPTIONS
-debug [0|1]
This is the Switch for debug output at the normal console (STDOUT)
-type (Automatic, Line, Bars, HBars, Circle)
This if the type to display the data.
Automatic - analyze the datahash and choice a Chart:
Hash with values -> CircleChart Hash with keys with hashes or values (not all) -> Barchart pro Key Hash with keys with arrays -> Linechart pro Key Array -> Linechart
Line - Linechart,
Bars - Barchart with vertical Bars,
HBars - Barchart with horizontal bars,
Circle - Circlechart
-foreground (black)
Color from the Axis, Legend and Labels.
-title -titlecolor (brown)
Message top at the Widget
-headroom (20)
The Headroom in percent.
-max
Maximum Value at the axis, this make the axis not dynamicaly redraw to the next maximums value from the highest value in the data. If only with function in Lines and Bars!
-sortnames ('alpha' | 'num') -sortreverse (0, 1)
sort the keys from the datahash.
-config (\%cfghash)
A confighash with optional added parameters for more flexibility. The first is the name of the key from youre datahash, following from a confighash with parameters. example:
-config => {
'fr' => {
-title => 'Free',
-color => 'green',
},
'sl' => {
-title => 'Sleep',
-color => 'yellow',
},
...
},
-title
Here you can write a other Name to display
-color
key only display in this color
-fill ('both')
The same we in perl/tk pack, the redraw only new in x,y direction or both
-xlabel -ylabel (text)
This display a Description for x and y axis
-xtick -ytick (5)
How many ticks at the x or y axis?
-xformat ('%s') -yformat ('%g')
This if the sprintf format for dislplay value or key at the axis. example:
-xformat => '%d%%' # This will i.e. Display '50%'
-yformat => '%s host' # This will i.e. Display 'first host'
-padding ([15,20,20,50])
Margin display from the widgetborder, in this direction top, right, bottom, left
-linewidth (1)
The weight from the Border at the dots, circle, lines
-printvalue
This if the sprintf format for display value and a switch for the last values from the datahash
-maxmin
Draw Max/Average/Min values Lines in the Bars and Line charts
-legend [0|1]
Switch on/off the legend in Circle or Lines
-colors (red, green, ...)
A comma-separated list with the allows colors
-shadow ('gray50') -shadowdeep (0)
You can add a shadow to all Charts, the switch is -shadowdeep. This is also the deep in Pixel from the shadow. -shadow is the color from the Shadow.
-wire ('white')
Switch on/off to draw a wire in background from Line and bars chart.
-reference ('name', 'value')
This give a Referencevalue for the keys in datahash. example:
-reference => 'Free, 1024', # Free space at host
-look ('count')
A Count to follow the values in linechart, when you refresh the datahash then this will display ex. 50 values from the keys only in linechart. example:
-look => 50, # 50 values to display pro key
-dots ('width')
The width and switch on from the Dots in linechart
-barwidth (30)
The width from Bars in Barcharts
-ballon (0|1)
Switch on/off a BallonHelp to segementes or lines. The Text is use from the -printvalue option.
-font ('-*-Helvetica-Medium-R-Normal--*-100-*-*-*-*-*-*')
Draw text in font
-lineheight (15)
The Lineheight in pixel from text in the legend
METHODS
Here come the Methodes that can you use for this Widget.
$chart->set($data);
Set the datahash to display.
$chart->variable($data);
bind the datahash to display the data, write to $data will redraw the widget.
$chart->redraw();
Redraw chart
$chart->redraw();
Clear the canvas
AUTHOR
Frank Herrmann xpix@xpix.de http://www.xpix.de
SEE ALSO
Tk, Tk::Trace, Tk::Canvas,