Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 83 lines (66 sloc) 2.07 kb
f78bc6a Cory G Watson Initial import.
authored
1 #!/usr/bin/perl
2 use strict;
3
4 use Chart::Clicker;
5 use Chart::Clicker::Context;
6 use Chart::Clicker::Data::DataSet;
7 use Chart::Clicker::Data::Marker;
8 use Chart::Clicker::Data::Series;
9 use Chart::Clicker::Decoration::OverAxis;
10 use Chart::Clicker::Renderer::Bar;
11 use Geometry::Primitive::Rectangle;
12 use Graphics::Color::RGB;
13
14 my $cc = Chart::Clicker->new(width => 300, height => 150, format => 'pdf');
15
16 my @years = qw(
17 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
18 );
19 my @top = qw(
20 8 7 2 5 9 5 7 3 5 7 9
21 );
22 my @bottom = qw(
23 -4 -2 -7 -9 -5 -7 -5 -5 -3 -9 -7
24 );
25
26
27 my $series = Chart::Clicker::Data::Series->new(
28 keys => \@years,
29 values => \@top,
30 );
31
32 my $series2 = Chart::Clicker::Data::Series->new(
33 keys => \@years,
34 values => \@bottom,
35 );
36
37 my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series, $series2 ]);
38
39 $cc->add_to_datasets($ds);
40
41 my $defctx = $cc->get_context('default');
42
43 my $grey = Graphics::Color::RGB->new(
44 red => .36, green => .36, blue => .36, alpha => 1
45 );
46 my $red = Graphics::Color::RGB->new(
47 red => .71, green => .71, blue => .71, alpha => 1
48 );
49
50
51 $cc->color_allocator->colors([ $grey, $red ]);
52 $cc->border->width(0);
53
54 $cc->background_color(
55 Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
56 );
57 $cc->plot->grid->visible(0);
58 $cc->legend->visible(0);
59
60 $defctx->renderer(Chart::Clicker::Renderer::Bar->new);
61
62 $defctx->range_axis->baseline(0);
63 $defctx->range_axis->hidden(1);
64 $defctx->domain_axis->hidden(1);
65 $defctx->domain_axis->fudge_amount(.1);
66 $defctx->renderer->brush->width(1);
67 $defctx->domain_axis->tick_values([qw(2000 2002 2004 2006 2008)]);
68
69 $cc->add_to_over_decorations(
70 Chart::Clicker::Decoration::OverAxis->new(
71 context => 'default',
72 border_color => Graphics::Color::RGB->new(
73 red => .95, green => .94, blue => .92
74 ),
75 font => Graphics::Primitive::Font->new(
76 family => 'Hoefler Text',
77 size => 12
78 )
79 )
80 );
81
82 $cc->draw;
83 $cc->write('foo.pdf');
Something went wrong with that request. Please try again.