Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation


by neniro (Priest)
on Oct 19, 2005 at 20:08 UTC ( #501403=snippet: print w/ replies, xml ) Need Help??

Description: Sparklines are something that I haven't seen mentioned on perlmonks so far. Sparklines are small graphs that are base64 encoded and embededded into plain html (see: for further details). There is already a module on cpan: GD::Graph::sparklines to build line-graphs as sparklines. My snippet is just a quick hack to show a way to build different kind of sparklines using GD and MIME::Base64 :

use strict;
use warnings;

use GD::Graph;
use GD::Graph::pie;

use MIME::Base64;

my @data = ( 
    [    1,    2],

my $graph = new GD::Graph::pie( 120, 120 );

$graph->set( dclrs       => [ qw( #FECECE #FEFECE #FFFFFF ) ],
             start_angle => 90 );

my $gd = $graph->plot(\@data) or die $graph->error;

print '<IMG SRC="data:image/png;base64,', 
      '" alt="sparkline"/>';

Comment on sparklines
Download Code

Back to Snippets Section

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://501403]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2015-11-27 08:09 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (720 votes), past polls