Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 83 lines (66 sloc) 2.07 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#!/usr/bin/perl
use strict;

use Chart::Clicker;
use Chart::Clicker::Context;
use Chart::Clicker::Data::DataSet;
use Chart::Clicker::Data::Marker;
use Chart::Clicker::Data::Series;
use Chart::Clicker::Decoration::OverAxis;
use Chart::Clicker::Renderer::Bar;
use Geometry::Primitive::Rectangle;
use Graphics::Color::RGB;

my $cc = Chart::Clicker->new(width => 300, height => 150, format => 'pdf');

my @years = qw(
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
);
my @top = qw(
8 7 2 5 9 5 7 3 5 7 9
);
my @bottom = qw(
-4 -2 -7 -9 -5 -7 -5 -5 -3 -9 -7
);


my $series = Chart::Clicker::Data::Series->new(
    keys => \@years,
    values => \@top,
);

my $series2 = Chart::Clicker::Data::Series->new(
    keys => \@years,
    values => \@bottom,
);

my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series, $series2 ]);

$cc->add_to_datasets($ds);

my $defctx = $cc->get_context('default');

my $grey = Graphics::Color::RGB->new(
    red => .36, green => .36, blue => .36, alpha => 1
);
my $red = Graphics::Color::RGB->new(
    red => .71, green => .71, blue => .71, alpha => 1
);


$cc->color_allocator->colors([ $grey, $red ]);
$cc->border->width(0);

$cc->background_color(
    Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
);
$cc->plot->grid->visible(0);
$cc->legend->visible(0);

$defctx->renderer(Chart::Clicker::Renderer::Bar->new);

$defctx->range_axis->baseline(0);
$defctx->range_axis->hidden(1);
$defctx->domain_axis->hidden(1);
$defctx->domain_axis->fudge_amount(.1);
$defctx->renderer->brush->width(1);
$defctx->domain_axis->tick_values([qw(2000 2002 2004 2006 2008)]);

$cc->add_to_over_decorations(
    Chart::Clicker::Decoration::OverAxis->new(
        context => 'default',
        border_color => Graphics::Color::RGB->new(
            red => .95, green => .94, blue => .92
        ),
        font => Graphics::Primitive::Font->new(
            family => 'Hoefler Text',
            size => 12
        )
    )
);

$cc->draw;
$cc->write('foo.pdf');
Something went wrong with that request. Please try again.