The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Tk::ForDummies::Graph::FAQ - Frequently Asked Questions about Tk::ForDummies::Graph.

SYNOPSIS

This is the Frequently Asked Questions list for Tk::ForDummies::Graph.

DESCRIPTION

How to save graph in postscript, jpeg, png, gif format file ?

You can use the postscript method canvas (see Tk::Canvas) to create postscript file of your image.

  $GraphDummies->postscript( -file => "MyFile.ps");

If you want to convert it in gif, jpeg format file for example, you can install Image::Magick module and Ghostscript (http://pages.cs.wisc.edu/~ghost/).

Then, that is an example code to convert your postscript file.

  use Image::Magick;
  my $Magick = new Image::Magick;
  $Magick->Read("MyFile.ps");
  $Magick->Write("MyFile.png");

How to zoom the graph in canvas widget ?

To zoom your graph, use zoom, zoomx or zoomy methods. You can create a menu zoom on the canvas. You have an example code in "EXAMPLES" in Tk::ForDummies::Graph::Lines

Warning or fatal error messages

You must have at least 2 arrays

  eg:
  my @data = (
       [ '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th' ],
  );
  $PieGraphDummies->plot(\@data);
  # => you will get warning message

You must have 2 arrays in data array

You will have this warning if you use Tk::ForDummies::Graph::Pie and if you use plot method with bad data.

  eg:
  my @data = (
       [ '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th' ],
       [     1,     2,    52,    6,      3,  17.5,     1,    43,    10 ],
       [    11,    20,     2,    5,      3,     1,    12,     3,     0 ], 
  );
  $PieGraphDummies->plot(\@data);
  
  # => you will get warning message

  my @data = (
       [ '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th' ],
       [     1,     2,    52,    6,      3,  17.5,     1,    43,    10 ], 
  );
  $PieGraphDummies->plot(\@data);
  # OK

Make sure that every array has the same size in plot data method

  eg:
  my @data = (
    [ 'Europe', 'Asia', 'Africa', 'Oceania', 'Americas' ], # <= 5 data 
    [ 97,       33,     3,        6,         61, 1100 ],   # <= 6 data , wrong
  );
  $PieGraphDummies->plot(\@data);

Data not defined

  $PieGraphDummies->plot(); # wrong

Can't set -data in set_legend method. May be you forgot to set the value

  $GraphDummies->set_legend(
    -data        => undef,     # wrong
  );

  $GraphDummies->set_legend(); # wrong

  $GraphDummies->set_legend(
    -data        => \@Legends,     # OK
  );

Legend and array size data are different

  my @data = (
    [ '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th' ],
    [ 1,     2,     5,     6,     3,     1,     1,     3,     4 ],  # legend 1
    [ 4,     2,     5,     2,     3,     5,     7,     9,     12 ], # legend 2
    [ 1,     2,     12,    6,     3,     5,     1,     23,    5 ]   # legend 3
  );
  
  my @Legends = ( 'legend 1', 'legend 2', 'legend 3', 'legend 4' ); # Wrong, 
  # too much legend

  my @Legends = ( 'legend 1', 'legend 2' ); # Wrong, not enough  legend

  my @Legends = ( 'legend 1', 'legend 2', 'legend 3' ); # OK

SEE ALSO

Tk::ForDummies::Graph

COPYRIGHT & LICENSE

Copyright 2009 Djibril Ousmanou, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.