1 Copyright 2000, Anthony Cook. All rights reserved.
2 This program is free software, you can redistribute it and/or
3 modify it under the same terms as Perl itself.
9 Imager::Graph is intended to produce good looking graphs with a
10 minimum effort on the part of the user. Hopefully I've managed that.
12 Currently only the pie graph class, Imager::Graph::Pie, is provided.
18 Imager::Graph can push the limits of the capabilities that Imager
19 provides, the default "style" will work with Imager 0.38, but the
20 other default styles require current CVS or Imager 0.39 when it is
21 released. Note that current CVS includes bug fixes that may have an
22 effect on the appearance of the final output.
24 Once you have Imager installed, and an appropriate font, Imager::Graph
25 should just work, there are no other dependencies.
31 For best results you will need one or more attractive fonts, and one
32 of the outline font libraries that Imager supports. The ImUgly font
33 is supplied with Imager::Graph, but it is fairly ugly, so probably
34 isn't useful if you want nice output.
40 Imager::Graph follows the normal perl module installation process:
47 Please Note: don't be too suprised if you get test failures,
48 unfortunately minor changes in the image can result in large changes
49 in the measure I use to check the results. If you get test failures
50 please check the results in testout/
52 The tests require PNG file format and TrueType font format support.
57 The aim is to make things as simple as possible, if you have some data
58 you can create a pie chart with:
60 use Imager::Graph::Pie;
62 my $font = Imager::Font->new(file=>$fontfile)
63 or die "Cannot create font: ",Imager->errstr;
64 my $pie_graph = Imager::Graph::Pie->new();
65 my $img = $pie_graph->draw(data=>\@data);
67 If you want to add a legend, you need to provide some descriptive text
70 my $img = $pie_graph->draw(data=>\@data, labels=>\@labels, font=>$font,
73 You might want to add a title instead:
75 my $img = $pie_graph->draw(data=>\@data, font=>$font, title=>'MyGraph');
77 or instead of a legend, use callouts to annotate each segment:
79 my $img = $pie_graph->draw(data=>\@data, labels=>\@labels,
80 features=>'allcallouts', font=>$font);
82 (The following graphs use features introduce after Imager 0.38.)
84 If you want draw a monochrome pie graph, using hatched fills, specify
87 my $img = $pie_graph->draw(data=>\@data, style=>'mono');
89 The 'mono' style produces a 1 channel image by default, so if you want
90 to add some color you need to reset the number of channels, for
91 example, you could change the drawing color to red:
93 my $img = $pie_graph->draw(data=>\@data, style=>'mono',
94 fg=>'FF0000', channels=>3);
97 If you're feeling particularly adventurous, you could create a graph
98 with a transparent background, suitable for compositing onto another
101 my $img = $pie_graph->draw(data=>\@data, style=>'mono',
102 bg=>'00000000', channels=>4);
104 If you only want the background of the graph to be transparent, while leaving other parts of the chart opaque, use the back option:
106 my $img = $pie_graph->draw(data=>\@data, style=>'mono',
107 back=>'00000000', channels=>4);
109 or you could make the background an image based fill:
111 my $img = $pie_graph->draw(data=>\@data, style=>'mono', channels=>4,
112 back=>{ image=>$otherimage } );
114 If you want a "prettier" image, you could use one of the fountain fill
117 my $img = $pie_graph->draw(data=>\@data, style=>'fount_lin');
119 The image you receive from Imager::Graph is a normal Imager image,
120 typically an 8-bit/sample direct color image, though options to extend
121 that may be introduced in the future.
127 Imager::Graph should work on any system that Imager works on.
133 If you have queries about Imager::Graph, please email me at
134 tony@develop-help.com.
136 A PPM compatible version of this module should be available from
137 http://ppd.develop-help.com/.
139 Thanks go to Addi for Imager.