Permalink
Browse files

Initial import.

  • Loading branch information...
0 parents commit f78bc6ab3fb60de98c5ff772b0166ba5dbdf6c0a @gphat committed Jun 19, 2009
Showing with 7,009 additions and 0 deletions.
  1. +13 −0 README
  2. +84 −0 area.pl
  3. +105 −0 bar.pl
  4. +82 −0 bubble.pl
  5. +68 −0 candlestick.pl
  6. +2,662 −0 contexts-first.graffle
  7. +1,805 −0 contexts-second.graffle
  8. +78 −0 markers.pl
  9. +107 −0 maxes.pl
  10. +129 −0 multiple-axes.pl
  11. +131 −0 multiple-renderers.pl
  12. +83 −0 overaxis-bar.pl
  13. +964 −0 parts.graffle
  14. +60 −0 pie.pl
  15. +83 −0 point.pl
  16. +94 −0 rockway.pl
  17. +94 −0 simple.pl
  18. +111 −0 sparkline.pl
  19. +96 −0 stackbar.pl
  20. +84 −0 stackedarea.pl
  21. +76 −0 tufte-whitegrid.pl
@@ -0,0 +1,13 @@
+Chart::Clicker Examples
+==========================
+
+These are examples of Chart::Clicker usage.
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2007 by Cory G Watson
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.6 or,
+at your option, any later version of Perl 5 you may have available.
+
@@ -0,0 +1,84 @@
+#!/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 Geometry::Primitive::Rectangle;
+use Graphics::Color::RGB;
+use Chart::Clicker::Renderer::Area;
+
+my $cc = Chart::Clicker->new(width => 550, height => 300, format => 'pdf');
+
+my @hours = qw(
+ 1 2 3 4 5 6 7 8 9 10 11 12
+);
+my @bw1 = qw(
+ 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8
+);
+my @bw2 = qw(
+ .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4
+);
+my @bw3 = qw(
+ .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1
+);
+
+my $series1 = Chart::Clicker::Data::Series->new(
+ keys => \@hours,
+ values => \@bw1,
+);
+my $series2 = Chart::Clicker::Data::Series->new(
+ keys => \@hours,
+ values => \@bw2,
+);
+
+my $series3 = Chart::Clicker::Data::Series->new(
+ keys => \@hours,
+ values => \@bw3,
+);
+
+
+$cc->border->width(0);
+$cc->background_color(
+ Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
+);
+my $grey = Graphics::Color::RGB->new(
+ red => .36, green => .36, blue => .36, alpha => 1
+);
+my $moregrey = Graphics::Color::RGB->new(
+ red => .71, green => .71, blue => .71, alpha => 1
+);
+my $orange = Graphics::Color::RGB->new(
+ red => .88, green => .48, blue => .09, alpha => 1
+);
+$cc->color_allocator->colors([ $grey, $moregrey, $orange ]);
+
+$cc->plot->grid->background_color->alpha(0);
+my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]);
+
+$cc->add_to_datasets($ds);
+
+my $defctx = $cc->get_context('default');
+
+$cc->legend->visible(0);
+# $defctx->range_axis->label('Lorem');
+# $defctx->domain_axis->label('Ipsum');
+$defctx->range_axis->brush->width(0);
+$defctx->domain_axis->brush->width(0);
+$defctx->range_axis->show_ticks(0);
+$defctx->domain_axis->show_ticks(0);
+
+$defctx->domain_axis->tick_label_angle(0.785398163);
+$defctx->range_axis->label_font->family('Hoefler Text');
+$defctx->range_axis->tick_font->family('Hoefler Text');
+$defctx->domain_axis->tick_font->family('Hoefler Text');
+$defctx->domain_axis->label_font->family('Hoefler Text');
+$defctx->renderer(Chart::Clicker::Renderer::Area->new(opacity => .75));
+$defctx->renderer->brush->width(2);
+
+$cc->legend->font->family('Hoefler Text');
+
+$cc->draw;
+$cc->write('foo.pdf');
@@ -0,0 +1,105 @@
+#!/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::Renderer::Bar;
+use Geometry::Primitive::Rectangle;
+use Graphics::Color::RGB;
+
+my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf');
+
+my @hours = qw(
+ 1 2 3 4
+);
+my @bw1 = qw(
+ 1.8 5.0 1.9 4.8
+);
+my @bw2 = qw(
+ .7 1.1 4 2.5
+);
+my @bw3 = qw(
+ .3 1.4 1.2 3.5
+);
+
+my $series1 = Chart::Clicker::Data::Series->new(
+ keys => \@hours,
+ values => \@bw1,
+ name => 'Sales'
+);
+my $series2 = Chart::Clicker::Data::Series->new(
+ keys => \@hours,
+ values => \@bw2,
+ name => 'Whales'
+);
+# We'll put the third into it's own dataset so we can put it in a new context
+my $series3 = Chart::Clicker::Data::Series->new(
+ keys => \@hours,
+ values => \@bw3,
+ name => 'Tails'
+);
+
+# We'll create a dataset with our first two series in it...
+my $ds = Chart::Clicker::Data::DataSet->new(
+ series => [ $series1, $series2, $series3 ]
+);
+
+# Create a new context
+my $other_context = Chart::Clicker::Context->new(
+ name => 'other'
+);
+
+my $defctx = $cc->get_context('default');
+
+# Pretty stuff
+$cc->border->width(0);
+
+my $grey = Graphics::Color::RGB->new(
+ red => .36, green => .36, blue => .36, alpha => 1
+);
+my $moregrey = Graphics::Color::RGB->new(
+ red => .71, green => .71, blue => .71, alpha => 1
+);
+my $orange = Graphics::Color::RGB->new(
+ red => .88, green => .48, blue => .09, alpha => 1
+);
+$cc->color_allocator->colors([ $grey, $moregrey, $orange ]);
+
+# Add the datasets to the chart
+$cc->add_to_datasets($ds);
+
+# Set some labels on the default context
+my $defctx = $cc->get_context('default');
+$defctx->range_axis->label('Dollars (millions)');
+$defctx->domain_axis->label('Region');
+# $defctx->domain_axis->tick_label_angle(0.785398163);
+$defctx->range_axis->label_font->family('Hoefler Text');
+# $defctx->range_axis->fudge_amount(.2);
+$defctx->domain_axis->fudge_amount(.2);
+$defctx->range_axis->tick_font->family('Hoefler Text');
+$defctx->domain_axis->tick_font->family('Hoefler Text');
+$defctx->domain_axis->label_font->family('Hoefler Text');
+
+$defctx->range_axis->tick_values([qw(3)]);
+$defctx->range_axis->format('%d');
+$defctx->domain_axis->tick_values([qw(1 2 3 4)]);
+$defctx->domain_axis->tick_labels([qw(North South East West)]);
+$defctx->domain_axis->format('%d');
+# $defctx->range_axis->baseline(3);
+
+$cc->background_color(
+ Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
+);
+$cc->plot->grid->background_color->alpha(0);
+
+# Here's the magic: You can set a renderer for any context. In this case
+# we'll change the default to a Bar. Voila!
+$defctx->renderer(Chart::Clicker::Renderer::Bar->new(bar_padding => 8));
+
+$cc->legend->font->family('Hoefler Text');
+
+$cc->draw;
+$cc->write('foo.pdf');
@@ -0,0 +1,82 @@
+#!/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::Size;
+use Geometry::Primitive::Rectangle;
+use Chart::Clicker::Renderer::Bubble;
+use Graphics::Color::RGB;
+use Geometry::Primitive::Circle;
+
+my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf');
+
+my @hours = qw(
+ 1 2 3 4 5 6 7 8 9 10 11 12
+);
+my @bw1 = qw(
+ 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8
+);
+my @bw2 = qw(
+ .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4
+);
+my @bw3 = qw(
+ .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1
+);
+
+my $series1 = Chart::Clicker::Data::Series::Size->new(
+ keys => \@hours,
+ values => \@bw1,
+ sizes => [qw(2 5 9 1 8 9 2 1 3 8 3 1)]
+);
+my $series2 = Chart::Clicker::Data::Series::Size->new(
+ keys => \@hours,
+ values => \@bw2,
+ sizes => [qw(2 5 4 1 8 9 2 1 6 8 8 7)]
+);
+
+my $series3 = Chart::Clicker::Data::Series::Size->new(
+ keys => \@hours,
+ values => \@bw3,
+ sizes => [qw(2 5 3 1 8 9 2 1 1 4 2 5)]
+);
+
+
+$cc->border->width(0);
+$cc->background_color(
+ Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
+);
+my $grey = Graphics::Color::RGB->new(
+ red => .36, green => .36, blue => .36, alpha => 1
+);
+my $moregrey = Graphics::Color::RGB->new(
+ red => .71, green => .71, blue => .71, alpha => 1
+);
+my $orange = Graphics::Color::RGB->new(
+ red => .88, green => .48, blue => .09, alpha => 1
+);
+$cc->color_allocator->colors([ $grey, $moregrey, $orange ]);
+
+$cc->plot->grid->background_color->alpha(0);
+my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]);
+
+$cc->add_to_datasets($ds);
+
+my $defctx = $cc->get_context('default');
+
+$defctx->range_axis->label('Lorem');
+$defctx->domain_axis->label('Ipsum');
+$defctx->range_axis->fudge_amount(.05);
+$defctx->domain_axis->fudge_amount(.05);
+$defctx->range_axis->label_font->family('Amaze');
+$defctx->range_axis->tick_font->family('Amaze');
+$defctx->domain_axis->tick_font->family('Amaze');
+$defctx->domain_axis->label_font->family('Amaze');
+$defctx->renderer(Chart::Clicker::Renderer::Bubble->new);
+
+$cc->legend->visible(0);
+
+$cc->draw;
+$cc->write('foo.pdf');
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+use strict;
+
+use Chart::Clicker;
+use Chart::Clicker::Data::DataSet;
+use Chart::Clicker::Data::Series::HighLow;
+use Chart::Clicker::Renderer::CandleStick;
+use Graphics::Color::RGB;
+
+my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf');
+
+my $series1 = Chart::Clicker::Data::Series::HighLow->new(
+ keys => [qw(1 2 3 4 5 6 7 8 9 10)],
+ highs => [qw(5 9 7 8 8 9 5 4 7 9)],
+
+ lows => [qw(1 4 2 3 1 4 1 1 1 4)],
+ opens => [qw(3 5 4 6 4 8 4 1 1 6)],
+ values => [qw(5 4 6 4 8 4 1 1 6 9)]
+);
+
+# We'll create a dataset with our first two series in it...
+my $ds = Chart::Clicker::Data::DataSet->new(
+ series => [ $series1 ]
+);
+
+my $grey = Graphics::Color::RGB->new(
+ red => .36, green => .36, blue => .36, alpha => 1
+);
+my $moregrey = Graphics::Color::RGB->new(
+ red => .71, green => .71, blue => .71, alpha => 1
+);
+my $orange = Graphics::Color::RGB->new(
+ red => .88, green => .48, blue => .09, alpha => 1
+);
+$cc->color_allocator->colors([ $grey, $moregrey, $orange ]);
+
+$cc->legend->font->family('Hoefler Text');
+
+# Pretty stuff
+$cc->border->width(0);
+
+# Add the datasets to the chart
+$cc->add_to_datasets($ds);
+
+$cc->background_color(
+ Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
+);
+$cc->plot->grid->background_color->alpha(0);
+
+# Set some labels on the default context
+my $defctx = $cc->get_context('default');
+$defctx->range_axis->label('Lorem');
+$defctx->range_axis->fudge_amount(.2);
+$defctx->range_axis->label_font->family('Hoefler Text');
+$defctx->range_axis->tick_font->family('Gentium');
+
+$defctx->domain_axis->label('Ipsum');
+$defctx->domain_axis->tick_label_angle(0.785398163);
+$defctx->domain_axis->fudge_amount(.06);
+$defctx->domain_axis->tick_font->family('Gentium');
+$defctx->domain_axis->label_font->family('Hoefler Text');
+
+# Here's the magic: You can set a renderer for any context. In this case
+# we'll change the default to a Bar. Voila!
+$defctx->renderer(Chart::Clicker::Renderer::CandleStick->new(bar_padding => 30));
+
+$cc->draw;
+$cc->write('foo.pdf');
Oops, something went wrong.

0 comments on commit f78bc6a

Please sign in to comment.