SVG::T...Bubble(3pm)
π«§ NAME
SVG::TT::Graph::Bubble β bestie, this is the one that makes presentation quality SVG Bubble plots. That's the whole vibe. Manual page goes by SVG::T...Bubble(3pm) if you're looking it up on your system, iykyk.
β¨ SYNOPSIS
okay so here's the whole thing in one breath:
use SVG::TT::Graph::Bubble;
my @data = ( 2, 15, 18.10, 6, 19, 0.10, 12, 17, 12.92, 17, 10, 17.97 );
my $graph = SVG::TT::Graph::Bubble->new( { 'height' => '500',
'width' => '300',
} );
$graph->add_data( { 'data' => \@data_cpu,
'title' => 'CPU',
} );
print "Content-type: image/svg+xml\n\n"; print $graph->burn();
literally that's it. feed it xyz data, get a bubble plot. slay. π
π DESCRIPTION
so the whole point of this object is letting you easily create high quality SVG Bubble plot graphs from xyz data. You can either roll with the default style sheet or bring your own β either way there are so many options you can configure to control exactly how the graph gets generated. Want a key? Don't want a key? Data elements hanging out at each point? Title? Subtitle? All of it. Yours. π
πΈ METHODS
π¦ new()
use SVG::TT::Graph::Bubble;
my $graph = SVG::TT::Graph::Bubble->new({
# Optional - defaults shown
'height' => 500,
'width' => 300,
'show_y_labels' => 1,
'yscale_divisions' => '',
'min_yscale_value' => 0,
'max_yscale_value' => '',
'show_x_labels' => 1,
'xscale_divisions' => '',
'min_xscale_value' => '',
'max_xscale_value' => '',
'stagger_x_labels' => 0,
'rotate_x_labels' => 0,
'y_label_formatter' => sub { return @_ },
'x_label_formatter' => sub { return @_ },
'show_data_values' => 1,
'rollover_values' => 0,
'area_fill' => 0,
'show_x_title' => 0,
'x_title' => 'X Field names',
'show_y_title' => 0,
'y_title' => 'Y Scale',
'show_graph_title' => 0,
'graph_title' => 'Graph Title',
'show_graph_subtitle' => 0,
'graph_subtitle' => 'Graph Sub Title',
'key' => 0,
'key_position' => 'right',
# Stylesheet defaults
'style_sheet' => '/includes/graph.css', # internal stylesheet
'random_colors' => 0,
'bubble_fill' => 0.4,
'bubble_border_stroke' => 0,
});
The constructor takes a hash reference, and every value defaults to the ones shown above β with one exception: style_sheet defaults to using the internal style sheet. π«Ά
π§ add_data()
my @data = ( 2, 15, 18.10,
6, 19, 0.10,
12, 17, 12.92,
17, 10, 17.97 );
or
my @data = ( [2, 15, 18.10] , [6, 19, 0.10],
[12, 17, 12.92], [17, 10, 17.97], );
or
my @data = ( { x => 2, y => 15, z => 18.10 },
{ x => 6, y => 19, z => 0.10 },
{ x => 12, y => 17, z => 12.92 },
{ x => 17, y => 10, z => 17.97 },
)
$graph->add_data({
'data' => \@data_cpu,
'title' => 'CPU',
});
okay so this method is how you actually feed the graph object data. The data is expected to be either:
- a list of scalars β in which case pairs of elements are taken to be X,Y pairs, or
- a list of array references. In that case, the first two elements in each referenced array are taken to be X and Y, and the optional third element (if present) is used as the text to display for that point for
show_data_valuesandrollover_values; otherwise the Y value itself is displayed.
You can call it several times to add more data sets in. stack 'em up bestie. π₯
π clear_data()
my $graph->clear_data();
This one removes all data from the object so you can reuse it to create a new graph but with the same config options. fresh start, same personality. β¨
π burn()
print $graph->burn();
This method processes the template with the data and config which has been set and returns the resulting SVG.
β οΈ Heads up: this method will croak unless at least one data set has been added to the graph object. No data, no graph, no mercy. π
π config methods
my $value = $graph->method();
my $confirmed_new_value = $graph->method($value);
Below is the full list of methods available to change the config of the graph object after it's been created. every single one. no skips. π
π height()
Set the height of the graph box β this is the total height of the SVG box created, not the graph itself, which auto scales to fix the space.
π width()
Set the width of the graph box β this is the total width of the SVG box created, not the graph itself, which auto scales to fix the space.
π compress()
Whether or not to compress the content of the SVG file (Compress::Zlib required).
π tidy()
Whether or not to tidy the content of the SVG file (XML::Tidy required).
π style_sheet()
Set the path to an external stylesheet, set to '' if you want to revert back to using the default internal version.
Set to "inline:<style>...</style>" with your CSS in between the tags. You can thus override the default style without requireing an external URL.
The default stylesheet handles up to 12 data sets. All data series over the 12th will have no style and be in black. If you have over 12 data sets you can assign them all random colors (see the random_color() method) or create your own stylesheet and add the additional settings for the extra data sets.
To create an external stylesheet create a graph using the default internal version and copy the stylesheet section to an external file and edit from there.
π random_colors()
Use random colors in the internal stylesheet. chaos, but make it pretty. π
π show_data_values()
Show the value of each element of data on the graph (or optionally a user-defined label; see add_data).
π rollover_values()
Shows data values and data points when the mouse is over the point. Used in combination with show_data_values.
π data_value_format()
Format specifier to for data values (as per printf).
π max_x_span()
Maximum span for a line between data points on the X-axis. If this span is exceeded, the points are not connected. This is useful for skipping missing data sections. If you set this value to something smaller than 0 (e.g. -1), you will get an XY scatter plot with no line joining the data points.
π stacked()
Accumulates each data set. (i.e. Each point increased by sum of all previous series at same point). Default is 0, set to '1' to show.
π min_yscale_value()
The point at which the Y axis starts, defaults to '0', if set to '' it will default to the minimum data value.
π max_yscale_value()
The point at which the Y axis ends, if set to '' it will default to the maximum data value.
π yscale_divisions()
This defines the gap between markers on the Y axis, default is a 10th of the range, e.g. you will have 10 markers on the Y axis.
β οΈ NOTE: do not set this too low β you are limited to 999 markers, after that the graph won't generate. π
π show_x_labels()
Whether to show labels on the X axis or not, defaults to 1, set to '0' if you want to turn them off.
π show_y_labels()
Whether to show labels on the Y axis or not, defaults to 1, set to '0' if you want to turn them off.
π y_label_format()
Format string for presenting the Y axis labels (as per printf).
π xscale_divisions()
This defines the gap between markers on the X axis. Default is the entire range (only start and end axis labels).
π stagger_x_labels()
This puts the labels at alternative levels so if they are long field names they will not overlap so easily. Default it '0', to turn on set to '1'.
π rotate_x_labels()
This turns the X axis labels by 90 degrees. Default it '0', to turn on set to '1'.
π min_xscale_value()
This sets the minimum X value. Any data points before this value will not be shown.
π max_xscale_value()
This sets the maximum X value. Any data points after this value will not be shown.
π show_x_title()
Whether to show the title under the X axis labels, default is 0, set to '1' to show.
π x_title()
What the title under X axis should be, e.g. 'Parameter X'.
π show_y_title()
Whether to show the title under the Y axis labels, default is 0, set to '1' to show.
π y_title()
What the title under Y axis should be, e.g. 'Sales in thousands'.
π show_graph_title()
Whether to show a title on the graph, default is 0, set to '1' to show.
π graph_title()
What the title on the graph should be.
π show_graph_subtitle()
Whether to show a subtitle on the graph, default is 0, set to '1' to show.
π graph_subtitle()
What the subtitle on the graph should be.
π key()
Whether to show a key, defaults to 0, set to '1' if you want to show it.
π key_position()
Where the key should be positioned, defaults to 'right', set to 'bottom' if you want to move it.
π x_label_formatter ()
A callback subroutine which will format a label on the x axis. For example:
$graph->x_label_formatter( sub { return '$' . $_[0] } );
π y_label_formatter()
A callback subroutine which will format a label on the y axis. For example:
$graph->y_label_formatter( sub { return '$' . $_[0] } );
π bubble_fill()
This is a floating number from 0 to 1 and determins how opaque the bubbles are. Default: 0.4
π bubble_border_stroke()
Whether to show a 1px border stroke around the bubble.
β EXAMPLES
For examples look at the project home page http://leo.cuckoo.org/projects/SVG-TT-Graph/ β go look, it's giving inspiration. π¦
π EXPORT
None by default. (she's not handing out freebies bestie, you gotta call the methods yourself π )
π« SEE ALSO
SVG::TT::GraphSVG::TT::Graph::LineSVG::TT::Graph::BarSVG::TT::Graph::BarHorizontalSVG::TT::Graph::BarLineSVG::TT::Graph::PieCompress::ZlibXML::Tidy
πΈ and that's the whole page, bestie. this one'sperl v5.36.0, dated2022-11-19, and it lives in the User Contributed Perl Documentation collection. go make some bubbles. π«§π
π¦ where this page comes from
- debian bookworm: libsvg-tt-graph-perl 1.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsvg-tt-graph-perl 1.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsvg-tt-graph-perl 1.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsvg-tt-graph-perl 1.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsvg-tt-graph-perl 1.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms