1SVG::TT::Graph::Bubble(U3s)er Contributed Perl DocumentatSiVoGn::TT::Graph::Bubble(3)
2
3
4

NAME

6       SVG::TT::Graph::Bubble - Create presentation quality SVG Bubble plot
7

SYNOPSIS

9       use SVG::TT::Graph::Bubble;
10
11       my @data = ( 2, 15, 18.10, 6, 19, 0.10, 12, 17, 12.92, 17, 10, 17.97 );
12
13       my $graph = SVG::TT::Graph::Bubble->new( { 'height' => '500',
14                                                  'width'  => '300',
15                                                } );
16
17       $graph->add_data( { 'data'  => \@data_cpu,
18                           'title' => 'CPU',
19                         } );
20
21       print "Content-type: image/svg+xml\n\n"; print $graph->burn();
22

DESCRIPTION

24       This object aims to allow you to easily create high quality SVG Bubble
25       plot graphs using xyz data. You can either use the default style sheet
26       or supply your own. Either way there are many options which can be
27       configured to give you control over how the graph is generated - with
28       or without a key, data elements at each point, title, subtitle etc.
29

METHODS

31   new()
32         use SVG::TT::Graph::Bubble;
33
34         my $graph = SVG::TT::Graph::Bubble->new({
35
36           # Optional - defaults shown
37           'height'              => 500,
38           'width'               => 300,
39
40           'show_y_labels'       => 1,
41           'yscale_divisions'    => '',
42           'min_yscale_value'    => 0,
43           'max_yscale_value'    => '',
44
45           'show_x_labels'       => 1,
46           'xscale_divisions'    => '',
47           'min_xscale_value'    => '',
48           'max_xscale_value'    => '',
49           'stagger_x_labels'    => 0,
50           'rotate_x_labels'     => 0,
51           'y_label_formatter'   => sub { return @_ },
52           'x_label_formatter'   => sub { return @_ },
53
54           'show_data_values'    => 1,
55           'rollover_values'     => 0,
56
57           'area_fill'           => 0,
58
59           'show_x_title'        => 0,
60           'x_title'             => 'X Field names',
61
62           'show_y_title'        => 0,
63           'y_title'             => 'Y Scale',
64
65           'show_graph_title'    => 0,
66           'graph_title'         => 'Graph Title',
67           'show_graph_subtitle' => 0,
68           'graph_subtitle'      => 'Graph Sub Title',
69           'key'                 => 0,
70           'key_position'        => 'right',
71
72           # Stylesheet defaults
73           'style_sheet'         => '/includes/graph.css', # internal stylesheet
74           'random_colors'       => 0,
75           'bubble_fill'   => 0.4,
76           'bubble_border_stroke'   => 0,
77         });
78
79       The constructor takes a hash reference with values defaulted to those
80       shown above - with the exception of style_sheet which defaults to using
81       the internal style sheet.
82
83   add_data()
84         my @data = ( 2,  15, 18.10,
85                      6,  19, 0.10,
86                      12, 17, 12.92,
87                      17, 10, 17.97 );
88         or
89         my @data = ( [2, 15, 18.10] , [6, 19, 0.10],
90                      [12, 17, 12.92], [17, 10, 17.97], );
91         or
92         my @data = ( { x => 2,  y => 15, z => 18.10 },
93                      { x => 6,  y => 19, z => 0.10 },
94                      { x => 12, y => 17, z => 12.92 },
95                      { x => 17, y => 10, z => 17.97 },
96                    )
97
98
99         $graph->add_data({
100           'data' => \@data_cpu,
101           'title' => 'CPU',
102         });
103
104       This method allows you to add data to the graph object.  The data are
105       expected to be either a list of scalars (in which case pairs of
106       elements are taken to be X,Y pairs) or a list of array references.  In
107       the latter case, the first two elements in each referenced array are
108       taken to be X and Y, and the optional third element (if present) is
109       used as the text to display for that point for show_data_values and
110       rollover_values; otherwise the Y value itself is displayed.  It can be
111       called several times to add more data sets in.
112
113   clear_data()
114         my $graph->clear_data();
115
116       This method removes all data from the object so that you can reuse it
117       to create a new graph but with the same config options.
118
119   burn()
120         print $graph->burn();
121
122       This method processes the template with the data and config which has
123       been set and returns the resulting SVG.
124
125       This method will croak unless at least one data set has been added to
126       the graph object.
127
128   config methods
129         my $value = $graph->method();
130         my $confirmed_new_value = $graph->method($value);
131
132       The following is a list of the methods which are available to change
133       the config of the graph object after it has been created.
134
135       height()
136           Set the height of the graph box, this is the total height of the
137           SVG box created - not the graph it self which auto scales to fix
138           the space.
139
140       width()
141           Set the width of the graph box, this is the total width of the SVG
142           box created - not the graph it self which auto scales to fix the
143           space.
144
145       compress()
146           Whether or not to compress the content of the SVG file
147           (Compress::Zlib required).
148
149       tidy()
150           Whether or not to tidy the content of the SVG file (XML::Tidy
151           required).
152
153       style_sheet()
154           Set the path to an external stylesheet, set to '' if you want to
155           revert back to using the default internal version.
156
157           Set to "inline:<style>...</style>" with your CSS in between the
158           tags.  You can thus override the default style without requireing
159           an external URL.
160
161           The default stylesheet handles up to 12 data sets. All data series
162           over the 12th will have no style and be in black. If you have over
163           12 data sets you can assign them all random colors (see the
164           random_color() method) or create your own stylesheet and add the
165           additional settings for the extra data sets.
166
167           To create an external stylesheet create a graph using the default
168           internal version and copy the stylesheet section to an external
169           file and edit from there.
170
171       random_colors()
172           Use random colors in the internal stylesheet.
173
174       show_data_values()
175           Show the value of each element of data on the graph (or optionally
176           a user-defined label; see add_data).
177
178       rollover_values()
179           Shows data values and data points when the mouse is over the point.
180           Used in combination with show_data_values.
181
182       data_value_format()
183           Format specifier to for data values (as per printf).
184
185       max_x_span()
186           Maximum span for a line between data points on the X-axis. If this
187           span is exceeded, the points are not connected. This is useful for
188           skipping missing data sections. If you set this value to something
189           smaller than 0 (e.g. -1), you will get an XY scatter plot with no
190           line joining the data points.
191
192       stacked()
193           Accumulates each data set. (i.e. Each point increased by sum of all
194           previous series at same point). Default is 0, set to '1' to show.
195
196       min_yscale_value()
197           The point at which the Y axis starts, defaults to '0', if set to ''
198           it will default to the minimum data value.
199
200       max_yscale_value()
201           The point at which the Y axis ends, if set to '' it will default to
202           the maximum data value.
203
204       yscale_divisions()
205           This defines the gap between markers on the Y axis, default is a
206           10th of the range, 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_labels()
211           Whether to show labels on the X axis or not, defaults to 1, set to
212           '0' if you want to turn them off.
213
214       show_y_labels()
215           Whether to show labels on the Y axis or not, defaults to 1, set to
216           '0' if you want to turn them off.
217
218       y_label_format()
219           Format string for presenting the Y axis labels (as per printf).
220
221       xscale_divisions()
222           This defines the gap between markers on the X axis.  Default is the
223           entire range (only start and end axis labels).
224
225       stagger_x_labels()
226           This puts the labels at alternative levels so if they are long
227           field names they will not overlap so easily.  Default it '0', to
228           turn on set to '1'.
229
230       rotate_x_labels()
231           This turns the X axis labels by 90 degrees.  Default it '0', to
232           turn on set to '1'.
233
234       min_xscale_value()
235           This sets the minimum X value. Any data points before this value
236           will not be shown.
237
238       max_xscale_value()
239           This sets the maximum X value. Any data points after this value
240           will not be shown.
241
242       show_x_title()
243           Whether to show the title under the X axis labels, default is 0,
244           set to '1' to show.
245
246       x_title()
247           What the title under X axis should be, e.g. 'Parameter X'.
248
249       show_y_title()
250           Whether to show the title under the Y axis labels, default is 0,
251           set to '1' to show.
252
253       y_title()
254           What the title under Y axis should be, e.g. 'Sales in thousands'.
255
256       show_graph_title()
257           Whether to show a title on the graph, default is 0, set to '1' to
258           show.
259
260       graph_title()
261           What the title on the graph should be.
262
263       show_graph_subtitle()
264           Whether to show a subtitle on the graph, default is 0, set to '1'
265           to show.
266
267       graph_subtitle()
268           What the subtitle on the graph should be.
269
270       key()
271           Whether to show a key, defaults to 0, set to '1' if you want to
272           show it.
273
274       key_position()
275           Where the key should be positioned, defaults to 'right', set to
276           'bottom' if you want to move it.
277
278       x_label_formatter ()
279           A callback subroutine which will format a label on the x axis.  For
280           example:
281
282               $graph->x_label_formatter( sub { return '$' . $_[0] } );
283
284       y_label_formatter()
285           A callback subroutine which will format a label on the y axis.  For
286           example:
287
288               $graph->y_label_formatter( sub { return '$' . $_[0] } );
289
290       bubble_fill()
291           This is a floating number from 0 to 1 and determins how opaque the
292           bubbles are.  Default: 0.4
293
294       bubble_border_stroke()
295           Whether to show a 1px border stroke around the bubble.
296

EXAMPLES

298       For examples look at the project home page
299       http://leo.cuckoo.org/projects/SVG-TT-Graph/
300

EXPORT

302       None by default.
303

SEE ALSO

305       SVG::TT::Graph, SVG::TT::Graph::Line, SVG::TT::Graph::Bar,
306       SVG::TT::Graph::BarHorizontal, SVG::TT::Graph::BarLine,
307       SVG::TT::Graph::Pie, Compress::Zlib, XML::Tidy
308
309
310
311perl v5.30.0                      2019-07-26         SVG::TT::Graph::Bubble(3)
Impressum