1SVG::TT::Graph::BarLineU(s3e)r Contributed Perl DocumentaStViGo:n:TT::Graph::BarLine(3)
2
3
4

NAME

6       SVG::TT::Graph::BarLine - Create presentation quality SVG bar-line
7       graphs easily
8

SYNOPSIS

10         use SVG::TT::Graph::BarLine;
11
12         my @fields = qw(Jan Feb Mar);
13         my @data_sales_02 = qw(12 45 21);
14         my @data_sales_03 = (24, 55, 61);
15
16         my $graph = SVG::TT::Graph::BarLine->new({
17           'height' => '500',
18           'width'  => '300',
19           'fields' => \@fields,
20         });
21
22         $graph->add_data({
23           'data'  => \@data_sales_02,
24           'title' => 'Sales 2002',
25         });
26
27         $graph->add_data({
28           'data'  => \@data_sales_03,
29           'title' => 'Sales 2003',
30         });
31
32         print "Content-type: image/svg+xml\n\n";
33         print $graph->burn();
34

DESCRIPTION

36       This object aims to allow you to easily create high quality SVG bar
37       graphs. You can either use the default style sheet or supply your own.
38       Either way there are many options which can be configured to give you
39       control over how the graph is generated - with or without a key, data
40       elements at each point, title, subtitle etc.
41

METHODS

43   new()
44         use SVG::TT::Graph::BarLine;
45
46         # Field names along the X axis
47         my @fields = qw(Jan Feb Mar);
48
49         my $graph = SVG::TT::Graph::BarLine->new({
50           # Required
51           'fields'                           => \@fields,
52
53           # Optional - defaults shown
54           'height'                           => '500',
55           'width'                            => '300',
56
57           'show_data_values'                 => 1,
58
59           'scale_divisions'                  => '',
60           'min_scale_value'                  => '0',
61           'bar_gap'                          => 1,
62
63           'show_x_labels'                    => 1,
64           'stagger_x_labels'                 => 0,
65           'rotate_x_labels'                  => 0,
66           'show_y_labels'                    => 1,
67           'scale_integers'                   => 0,
68           'show_secondary_y_labels'          => 1,
69
70           'show_x_title'                     => 0,
71           'x_title'                          => 'X Field names',
72
73           'show_y_title'                     => 0,
74           'show_secondary_y_title'           => 0,
75           'y_title_text_direction'           => 'bt',
76           'secondary_y_title_text_direction' => 'bt',
77           'y_title'                          => 'Y Scale',
78           'secondary_y_title'                => 'Y Scale 2',
79
80           'show_graph_title'                 => 0,
81           'graph_title'                      => 'Graph Title',
82           'show_graph_subtitle'              => 0,
83           'graph_subtitle'                   => 'Graph Sub Title',
84
85           'key'                              => 0,
86           'key_position'                     => 'right',
87
88           # Stylesheet defaults
89           'style_sheet'                      => '/includes/graph.css', # internal stylesheet
90           'random_colors'                    => 0,
91         });
92
93       The constructor takes a hash reference, fields (the names for each
94       field on the X axis) MUST be set, all other values are defaulted to
95       those shown above - with the exception of style_sheet which defaults to
96       using the internal style sheet.
97
98   add_data()
99         my @data_sales_02 = qw(12 45 21);
100
101         $graph->add_data({
102           'data' => \@data_sales_02,
103           'title' => 'Sales 2002',
104         });
105
106       This method allows you to add data to the graph object.  It can be
107       called several times to add more data sets in, but the likelihood is
108       you should be using SVG::TT::Graph::Line as it won't look great!
109
110   clear_data()
111         my $graph->clear_data();
112
113       This method removes all data from the object so that you can reuse it
114       to create a new graph but with the same config options.
115
116   burn()
117         print $graph->burn();
118
119       This method processes the template with the data and config which has
120       been set and returns the resulting SVG.
121
122       This method will croak unless at least one data set has been added to
123       the graph object.
124
125   config methods
126         my $value = $graph->method();
127         my $confirmed_new_value = $graph->method($value);
128
129       The following is a list of the methods which are available to change
130       the config of the graph object after it has been created.
131
132       height()
133           Set the height of the graph box, this is the total height of the
134           SVG box created - not the graph it self which auto scales to fix
135           the space.
136
137       width()
138           Set the width of the graph box, this is the total width of the SVG
139           box created - not the graph it self which auto scales to fix the
140           space.
141
142       compress()
143           Whether or not to compress the content of the SVG file
144           (Compress::Zlib required).
145
146       tidy()
147           Whether or not to tidy the content of the SVG file (XML::Tidy
148           required).
149
150       style_sheet() =item style_sheet()
151           Set the path to an external stylesheet, set to '' if you want to
152           revert back to using the defaut internal version.
153
154           The default stylesheet handles up to 12 data sets. All data series
155           over the 12th will have no style and be in black. If you have over
156           12 data sets you can assign them all random colors (see the
157           random_color() method) or create your own stylesheet and add the
158           additional settings for the extra data sets.
159
160           To create an external stylesheet create a graph using the default
161           internal version and copy the stylesheet section to an external
162           file and edit from there.
163
164       random_colors()
165           Use random colors in the internal stylesheet
166
167       show_data_values()
168           Show the value of each element of data on the graph
169
170       bar_gap()
171           Whether to have a gap between the bars or not, default is '1', set
172           to '0' if you don't want gaps.
173
174       show_x_labels()
175           Whether to show labels on the X axis or not, defaults to 1, set to
176           '0' if you want to turn them off.
177
178       stagger_x_labels()
179           This puts the labels at alternative levels so if they are long
180           field names they will not overlap so easily.  Default it '0', to
181           turn on set to '1'.
182
183       rotate_x_labels()
184           This turns the X axis labels by 90 degrees.  Default it '0', to
185           turn on set to '1'.
186
187       show_y_labels()
188           Whether to show labels on the Y axis or not, defaults to 1, set to
189           '0' if you want to turn them off.
190
191       scale_integers()
192           Ensures only whole numbers are used as the scale divisions.
193           Default it '0', to turn on set to '1'. This has no effect if scale
194           divisions are less than 1.
195
196       show_secondary_y_labels()
197           Whether to show labels on the right hand side Y axis or not,
198           defaults to 1, set to '0' if you want to turn them off.
199
200       min_scale_value()
201           The point at which the Y axis starts, defaults to '0', if set to ''
202           it will default to the minimum data value.
203
204       scale_divisions()
205           This defines the gap between markers on the Y axis, default is a
206           10th of the max_value, e.g. you will have 10 markers on the Y axis.
207           NOTE: do not set this too low - you are limited to 999 markers,
208           after that the graph won't generate.
209
210       show_x_title()
211           Whether to show the title under the X axis labels, default is 0,
212           set to '1' to show.
213
214       x_title()
215           What the title under X axis should be, e.g. 'Months'.
216
217       show_y_title()
218           Whether to show the title on the left hand side Y axis, default is
219           0, set to '1' to show.
220
221       show_secondary_y_title()
222           Whether to show the title on the right hand side Y axis, default is
223           0, set to '1' to show.
224
225       y_title_text_direction()
226           Aligns writing mode for Y axis label. Defaults to 'bt' (Bottom to
227           Top).  Change to 'tb' (Top to Bottom) to reverse.
228
229       secondary_y_title_text_direction()
230           Aligns writing mode for right hand Y axis label. Defaults to 'bt'
231           (Bottom to Top).  Change to 'tb' (Top to Bottom) to reverse.
232
233       y_title()
234           What the title under Y axis should be, e.g. 'Sales in thousands'.
235
236       secondary_y_title()
237           What the title on the right hand side Y axis should be, e.g.
238           'Number of deals'.
239
240       show_graph_title()
241           Whether to show a title on the graph, defaults to 0, set to '1' to
242           show.
243
244       graph_title()
245           What the title on the graph should be.
246
247       show_graph_subtitle()
248           Whether to show a subtitle on the graph, defaults to 0, set to '1'
249           to show.
250
251       graph_subtitle()
252           What the subtitle on the graph should be.
253
254       key()
255           Whether to show a key, defaults to 0, set to '1' if you want to
256           show it.
257
258       key_position()
259           Where the key should be positioned, defaults to 'right', set to
260           'bottom' if you want to move it.
261

EXAMPLES

263       For examples look at the project home page
264       http://leo.cuckoo.org/projects/SVG-TT-Graph/
265

EXPORT

267       None by default.
268

ACKNOWLEDGEMENTS

270       Stephen Morgan for creating the TT template and SVG.
271

AUTHOR

273       Leo Lapworth (LLAP@cuckoo.org)
274

SEE ALSO

276       SVG::TT::Graph, SVG::TT::Graph::Line, SVG::TT::Graph::Bar,
277       SVG::TT::Graph::BarHorizontal, SVG::TT::Graph::Pie,
278       SVG::TT::Graph::TimeSeries, Compress::Zlib, XML::Tidy
279
280
281
282perl v5.12.0                      2010-04-17        SVG::TT::Graph::BarLine(3)
Impressum