Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

sparklines

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: http://www.ietf.org/rfc/rfc2397.txt 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 :
#!/usr/bin/perl

use strict;
use warnings;

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

use MIME::Base64;

my @data = ( 
    ["1st","2nd"],
    [    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,', 
      encode_base64($gd->png),
      '" alt="sparkline"/>';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://501403]
help
Chatterbox?
[Corion]: I hope you had a good weekend!
[marto]: jetlag has really done a number on the kids, it's been a tough week
choroba played with the band on Saturday, so Sunday was very sleepy
[choroba]: managed to release Syntax::Construct with 5.28 support in the night, though
[Corion]: choroba: Whee ;)
[Corion]: marto: Ouch - I would've thought that kids adapt much better, but that's obviously not the case...
[marto]: well, their mother let them sleep till 15:00 & 12:00 last week, which didn't help them adjust :P
[Corion]: I was "productive" over the weekend in the sense that I revived my old "Perlmonks on SQLite" code, which likely means I can get a test instance back up running on my webhost. Small steps :)
[Corion]: marto: Ow, no, that doesn't help at all :)
[choroba]: Related to the new release, anyone could explain this or this tester report?

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2018-06-25 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?