├── README ├── area.pl ├── area ├── area.pl ├── area.png ├── stacked-area.pl └── stacked-area.png ├── bar ├── bar-baseline.pl ├── bar-baseline.png ├── bar.pl ├── bar.png ├── stacked-bar.pl └── stacked-bar.png ├── bubble ├── bubble.pl └── bubble.png ├── candlestick ├── candlestick.pl └── candlestick.png ├── line ├── line-shapes-brushed.pl ├── line-shapes-brushed.png ├── line-shapes.pl ├── line-shapes.png ├── line.pl ├── line.png ├── stacked-line.pl └── stacked-line.png ├── markers.pl ├── maxes.pl ├── multiple-axes.pl ├── multiple-renderers.pl ├── overaxis-bar.pl ├── pie ├── pie-gradient.pl ├── pie-gradient.png ├── pie.pl └── pie.png ├── point ├── point.pl └── point.png ├── polararea ├── polararea.pl └── polararea.png ├── simple.pl ├── sparkline.pl ├── stackbar.pl ├── stackedarea.pl └── tufte-whitegrid.pl /README: -------------------------------------------------------------------------------- 1 | Chart::Clicker Examples 2 | ========================== 3 | 4 | These are examples of Chart::Clicker usage. 5 | 6 | COPYRIGHT AND LICENCE 7 | 8 | Copyright (C) 2007 by Cory G Watson 9 | 10 | This library is free software; you can redistribute it and/or modify 11 | it under the same terms as Perl itself, either Perl version 5.8.6 or, 12 | at your option, any later version of Perl 5 you may have available. 13 | 14 | -------------------------------------------------------------------------------- /area.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Chart::Clicker::Renderer::Area; 12 | 13 | my $cc = Chart::Clicker->new(width => 550, height => 300, format => 'png'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | 43 | $cc->border->width(0); 44 | $cc->background_color( 45 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 46 | ); 47 | my $grey = Graphics::Color::RGB->new( 48 | red => .36, green => .36, blue => .36, alpha => 1 49 | ); 50 | my $moregrey = Graphics::Color::RGB->new( 51 | red => .71, green => .71, blue => .71, alpha => 1 52 | ); 53 | my $orange = Graphics::Color::RGB->new( 54 | red => .88, green => .48, blue => .09, alpha => 1 55 | ); 56 | $cc->color_allocator->colors([ $grey, $moregrey, $orange ]); 57 | 58 | $cc->plot->grid->background_color->alpha(0); 59 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 60 | 61 | $cc->add_to_datasets($ds); 62 | 63 | my $defctx = $cc->get_context('default'); 64 | 65 | $cc->legend->visible(0); 66 | # $defctx->range_axis->label('Lorem'); 67 | # $defctx->domain_axis->label('Ipsum'); 68 | $defctx->range_axis->brush->width(0); 69 | $defctx->domain_axis->brush->width(0); 70 | $defctx->range_axis->show_ticks(0); 71 | $defctx->domain_axis->show_ticks(0); 72 | 73 | $defctx->domain_axis->tick_label_angle(0.785398163); 74 | $defctx->range_axis->label_font->family('Hoefler Text'); 75 | $defctx->range_axis->tick_font->family('Hoefler Text'); 76 | $defctx->domain_axis->tick_font->family('Hoefler Text'); 77 | $defctx->domain_axis->label_font->family('Hoefler Text'); 78 | $defctx->renderer(Chart::Clicker::Renderer::Area->new(opacity => .75)); 79 | $defctx->renderer->brush->width(2); 80 | 81 | $cc->legend->font->family('Hoefler Text'); 82 | 83 | $cc->draw; 84 | $cc->write('area.png'); 85 | -------------------------------------------------------------------------------- /area/area.pl: -------------------------------------------------------------------------------- 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::Renderer::Area; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | use Geometry::Primitive::Circle; 13 | 14 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 15 | 16 | my @hours = qw( 17 | 1 2 3 4 5 6 7 8 9 10 11 12 18 | ); 19 | my @bw1 = qw( 20 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 21 | ); 22 | my @bw2 = qw( 23 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 24 | ); 25 | my @bw3 = qw( 26 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 27 | ); 28 | 29 | my $series1 = Chart::Clicker::Data::Series->new( 30 | keys => \@hours, 31 | values => \@bw1, 32 | ); 33 | my $series2 = Chart::Clicker::Data::Series->new( 34 | keys => \@hours, 35 | values => \@bw2, 36 | ); 37 | 38 | my $series3 = Chart::Clicker::Data::Series->new( 39 | keys => \@hours, 40 | values => \@bw3, 41 | ); 42 | 43 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 44 | 45 | $cc->title->text('Area Chart'); 46 | $cc->title->padding->bottom(5); 47 | $cc->add_to_datasets($ds); 48 | 49 | my $defctx = $cc->get_context('default'); 50 | 51 | my $area = Chart::Clicker::Renderer::Area->new(opacity => .6); 52 | $area->brush->width(3); 53 | $defctx->renderer($area); 54 | 55 | $defctx->range_axis->label('Lorem'); 56 | $defctx->domain_axis->label('Ipsum'); 57 | 58 | $defctx->renderer->brush->width(2); 59 | 60 | $cc->write_output('area.png'); 61 | -------------------------------------------------------------------------------- /area/area.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/area/area.png -------------------------------------------------------------------------------- /area/stacked-area.pl: -------------------------------------------------------------------------------- 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::Renderer::StackedArea; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | use Geometry::Primitive::Circle; 13 | 14 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 15 | 16 | my @hours = qw( 17 | 1 2 3 4 5 6 7 8 9 10 11 12 18 | ); 19 | my @bw1 = qw( 20 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 21 | ); 22 | my @bw2 = qw( 23 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 24 | ); 25 | my @bw3 = qw( 26 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 27 | ); 28 | 29 | my $series1 = Chart::Clicker::Data::Series->new( 30 | keys => \@hours, 31 | values => \@bw1, 32 | ); 33 | my $series2 = Chart::Clicker::Data::Series->new( 34 | keys => \@hours, 35 | values => \@bw2, 36 | ); 37 | 38 | my $series3 = Chart::Clicker::Data::Series->new( 39 | keys => \@hours, 40 | values => \@bw3, 41 | ); 42 | 43 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 44 | 45 | $cc->title->text('Stacked Area Chart'); 46 | $cc->title->padding->bottom(5); 47 | $cc->add_to_datasets($ds); 48 | 49 | my $defctx = $cc->get_context('default'); 50 | 51 | my $area = Chart::Clicker::Renderer::StackedArea->new(opacity => .6); 52 | $area->brush->width(3); 53 | $defctx->renderer($area); 54 | 55 | $defctx->range_axis->label('Lorem'); 56 | $defctx->domain_axis->label('Ipsum'); 57 | $defctx->range_axis->fudge_amount(.02); 58 | 59 | $defctx->renderer->brush->width(2); 60 | 61 | $cc->write_output('stacked-area.png'); 62 | -------------------------------------------------------------------------------- /area/stacked-area.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/area/stacked-area.png -------------------------------------------------------------------------------- /bar/bar-baseline.pl: -------------------------------------------------------------------------------- 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::Renderer::Bar; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | 43 | $cc->title->text('Bar (Baseline)'); 44 | $cc->title->padding->bottom(5); 45 | 46 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 47 | 48 | $cc->add_to_datasets($ds); 49 | 50 | my $def = $cc->get_context('default'); 51 | 52 | my $area = Chart::Clicker::Renderer::Bar->new(opacity => .6); 53 | $area->brush->width(3); 54 | 55 | $def->renderer($area); 56 | $def->range_axis->tick_values([qw(1 3 5)]); 57 | $def->range_axis->format('%d'); 58 | 59 | $def->range_axis->baseline(3); 60 | 61 | $def->domain_axis->tick_values([qw(2 4 6 8 10)]); 62 | $def->domain_axis->format('%d'); 63 | 64 | # We ask clicker to "fudge" the edges with some padding so that the bars show 65 | # up properly. 66 | $def->domain_axis->fudge_amount(.05); 67 | $def->range_axis->fudge_amount(.01); 68 | 69 | $cc->write_output('bar-baseline.png'); 70 | -------------------------------------------------------------------------------- /bar/bar-baseline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/bar/bar-baseline.png -------------------------------------------------------------------------------- /bar/bar.pl: -------------------------------------------------------------------------------- 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::Renderer::Bar; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | $cc->title->text('Bar'); 43 | $cc->title->padding->bottom(5); 44 | 45 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 46 | 47 | $cc->add_to_datasets($ds); 48 | 49 | my $def = $cc->get_context('default'); 50 | 51 | my $area = Chart::Clicker::Renderer::Bar->new(opacity => .6); 52 | $area->brush->width(3); 53 | $def->renderer($area); 54 | $def->range_axis->tick_values([qw(1 3 5)]); 55 | $def->range_axis->format('%d'); 56 | $def->domain_axis->tick_values([qw(2 4 6 8 10)]); 57 | $def->domain_axis->format('%d'); 58 | 59 | # We ask clicker to "fudge" the edges with some padding so that the bars show 60 | # up properly. 61 | $def->domain_axis->fudge_amount(.05); 62 | $def->range_axis->fudge_amount(.01); 63 | 64 | $cc->write_output('bar.png'); 65 | -------------------------------------------------------------------------------- /bar/bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/bar/bar.png -------------------------------------------------------------------------------- /bar/stacked-bar.pl: -------------------------------------------------------------------------------- 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::Renderer::StackedBar; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | $cc->title->text('Stacked Bar'); 43 | $cc->title->padding->bottom(5); 44 | 45 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 46 | 47 | $cc->add_to_datasets($ds); 48 | 49 | my $def = $cc->get_context('default'); 50 | 51 | my $area = Chart::Clicker::Renderer::StackedBar->new(opacity => .8); 52 | $area->brush->width(3); 53 | $def->renderer($area); 54 | $def->range_axis->tick_values([qw(1 3 5 7 9 11)]); 55 | $def->range_axis->format('%d'); 56 | $def->domain_axis->tick_values([qw(1 3 5 7 9 11)]); 57 | $def->domain_axis->format('%d'); 58 | 59 | # We ask clicker to "fudge" the edges with some padding so that the bars show 60 | # up properly. 61 | $def->domain_axis->fudge_amount(.05); 62 | $def->range_axis->fudge_amount(.01); 63 | 64 | $cc->write_output('stacked-bar.png'); 65 | -------------------------------------------------------------------------------- /bar/stacked-bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/bar/stacked-bar.png -------------------------------------------------------------------------------- /bubble/bubble.pl: -------------------------------------------------------------------------------- 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::Size; 9 | use Geometry::Primitive::Rectangle; 10 | use Chart::Clicker::Renderer::Bubble; 11 | use Graphics::Color::RGB; 12 | use Geometry::Primitive::Circle; 13 | 14 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 15 | 16 | my @hours = qw( 17 | 1 2 3 4 5 6 7 8 9 10 11 12 18 | ); 19 | my @bw1 = qw( 20 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 21 | ); 22 | my @bw2 = qw( 23 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 24 | ); 25 | my @bw3 = qw( 26 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 27 | ); 28 | 29 | my $series1 = Chart::Clicker::Data::Series::Size->new( 30 | keys => \@hours, 31 | values => \@bw1, 32 | sizes => [qw(2 5 9 1 8 9 2 1 3 8 3 1)] 33 | ); 34 | my $series2 = Chart::Clicker::Data::Series::Size->new( 35 | keys => \@hours, 36 | values => \@bw2, 37 | sizes => [qw(2 5 4 1 8 9 2 1 6 8 8 7)] 38 | ); 39 | 40 | my $series3 = Chart::Clicker::Data::Series::Size->new( 41 | keys => \@hours, 42 | values => \@bw3, 43 | sizes => [qw(2 5 3 1 8 9 2 1 1 4 2 5)] 44 | ); 45 | 46 | $cc->title->text('Bubble'); 47 | $cc->title->padding->bottom(5); 48 | 49 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 50 | 51 | $cc->add_to_datasets($ds); 52 | 53 | my $defctx = $cc->get_context('default'); 54 | 55 | $defctx->range_axis->fudge_amount(.05); 56 | $defctx->domain_axis->fudge_amount(.05); 57 | $defctx->renderer(Chart::Clicker::Renderer::Bubble->new); 58 | 59 | $cc->write_output('bubble.png'); 60 | -------------------------------------------------------------------------------- /bubble/bubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/bubble/bubble.png -------------------------------------------------------------------------------- /candlestick/candlestick.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | use Chart::Clicker; 5 | use Chart::Clicker::Data::DataSet; 6 | use Chart::Clicker::Data::Series::HighLow; 7 | use Chart::Clicker::Renderer::CandleStick; 8 | use Graphics::Color::RGB; 9 | 10 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 11 | 12 | my $series1 = Chart::Clicker::Data::Series::HighLow->new( 13 | keys => [qw(1 2 3 4 5 6 7 8 9 10)], 14 | highs => [qw(5 9 7 8 8 9 5 4 7 9)], 15 | 16 | lows => [qw(1 4 2 3 1 4 1 1 1 4)], 17 | opens => [qw(3 5 4 6 4 8 4 1 1 6)], 18 | values => [qw(5 4 6 4 8 4 1 1 6 9)] 19 | ); 20 | 21 | $cc->title->text('Candlestick'); 22 | $cc->title->padding->bottom(5); 23 | 24 | # We'll create a dataset with our first two series in it... 25 | my $ds = Chart::Clicker::Data::DataSet->new( 26 | series => [ $series1 ] 27 | ); 28 | 29 | # Add the datasets to the chart 30 | $cc->add_to_datasets($ds); 31 | 32 | # Set some labels on the default context 33 | my $defctx = $cc->get_context('default'); 34 | $defctx->range_axis->label('Lorem'); 35 | $defctx->range_axis->fudge_amount(.2); 36 | 37 | $defctx->domain_axis->label('Ipsum'); 38 | $defctx->domain_axis->fudge_amount(.06); 39 | 40 | # Here's the magic: You can set a renderer for any context. In this case 41 | # we'll change the default to a Bar. Voila! 42 | $defctx->renderer(Chart::Clicker::Renderer::CandleStick->new(bar_padding => 30)); 43 | 44 | $cc->write_output('candlestick.png'); 45 | -------------------------------------------------------------------------------- /candlestick/candlestick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/candlestick/candlestick.png -------------------------------------------------------------------------------- /line/line-shapes-brushed.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Geometry::Primitive::Circle; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | 43 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 44 | 45 | $cc->title->text('Line + Shapes (Brushed)'); 46 | $cc->add_to_datasets($ds); 47 | 48 | my $defctx = $cc->get_context('default'); 49 | 50 | $defctx->range_axis->label('Lorem'); 51 | $defctx->domain_axis->label('Ipsum'); 52 | 53 | $defctx->renderer->shape( 54 | Geometry::Primitive::Circle->new({ 55 | radius => 5, 56 | }) 57 | ); 58 | $defctx->renderer->shape_brush( 59 | Graphics::Primitive::Brush->new( 60 | width => 2, 61 | color => Graphics::Color::RGB->new(red => 1, green => 1, blue => 1) 62 | ) 63 | ); 64 | 65 | $defctx->renderer->brush->width(2); 66 | 67 | $cc->write_output('line-shapes-brushed.png'); 68 | -------------------------------------------------------------------------------- /line/line-shapes-brushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/line/line-shapes-brushed.png -------------------------------------------------------------------------------- /line/line-shapes.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Geometry::Primitive::Circle; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | 43 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 44 | 45 | $cc->title->text('Line + Shapes'); 46 | $cc->add_to_datasets($ds); 47 | 48 | my $defctx = $cc->get_context('default'); 49 | 50 | $defctx->range_axis->label('Lorem'); 51 | $defctx->domain_axis->label('Ipsum'); 52 | 53 | $defctx->renderer->shape( 54 | Geometry::Primitive::Circle->new({ 55 | radius => 5, 56 | }) 57 | ); 58 | 59 | $defctx->renderer->brush->width(2); 60 | 61 | $cc->write_output('line-shapes.png'); 62 | -------------------------------------------------------------------------------- /line/line-shapes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/line/line-shapes.png -------------------------------------------------------------------------------- /line/line.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Geometry::Primitive::Circle; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 43 | 44 | $cc->title->text('Line Chart'); 45 | $cc->title->padding->bottom(5); 46 | $cc->add_to_datasets($ds); 47 | 48 | my $defctx = $cc->get_context('default'); 49 | 50 | $defctx->range_axis->label('Lorem'); 51 | $defctx->domain_axis->label('Ipsum'); 52 | 53 | # $defctx->range_axis->label_font->family('Arno Pro'); 54 | # $defctx->range_axis->tick_font->family('Arno Pro'); 55 | # $defctx->domain_axis->tick_font->family('Arno Pro'); 56 | # $defctx->domain_axis->label_font->family('Arno Pro'); 57 | 58 | $defctx->renderer->brush->width(2); 59 | 60 | # $cc->legend->font->size(15); 61 | # $cc->legend->font->family('Arno Pro'); 62 | 63 | $cc->write_output('line.png'); 64 | -------------------------------------------------------------------------------- /line/line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/line/line.png -------------------------------------------------------------------------------- /line/stacked-line.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Geometry::Primitive::Circle; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 43 | 44 | $cc->title->text('Stacked Line Chart'); 45 | $cc->title->padding->bottom(5); 46 | $cc->add_to_datasets($ds); 47 | 48 | my $defctx = $cc->get_context('default'); 49 | 50 | $defctx->range_axis->label('Lorem'); 51 | $defctx->domain_axis->label('Ipsum'); 52 | 53 | $defctx->renderer->additive(1); 54 | $defctx->renderer->brush->width(2); 55 | 56 | $cc->write_output('stacked-line.png'); 57 | -------------------------------------------------------------------------------- /line/stacked-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/line/stacked-line.png -------------------------------------------------------------------------------- /markers.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | 12 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf'); 13 | 14 | my $series1 = Chart::Clicker::Data::Series->new( 15 | keys => [qw(1 2 3 4 5 6 7 8 9 10 11 12)], 16 | values => [qw(5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8)] 17 | ); 18 | 19 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1 ]); 20 | 21 | $cc->add_to_datasets($ds); 22 | $cc->border->width(0); 23 | 24 | $cc->background_color( 25 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 26 | ); 27 | $cc->plot->grid->background_color->alpha(0); 28 | 29 | my $orange = Graphics::Color::RGB->new( 30 | red => .88, green => .48, blue => .09, alpha => 1 31 | ); 32 | $cc->color_allocator->colors([ $orange ]); 33 | 34 | my $domain_range_marker = Chart::Clicker::Data::Marker->new(key => 4, key2 => 6); 35 | $domain_range_marker->inside_color( 36 | Graphics::Color::RGB->new( 37 | red => .88, green => .48, blue => .09, alpha => .35 38 | ) 39 | ); 40 | 41 | my $domain_marker = Chart::Clicker::Data::Marker->new(key => 7); 42 | $domain_marker->color($orange); 43 | 44 | my $range_range_marker = Chart::Clicker::Data::Marker->new(value => 4, value2 => 5); 45 | $range_range_marker->inside_color( 46 | Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .12) 47 | ); 48 | 49 | my $range_marker = Chart::Clicker::Data::Marker->new(value => 2); 50 | $range_marker->color( 51 | Graphics::Color::RGB->new( 52 | red => .88, green => .48, blue => .09, alpha => .5 53 | ) 54 | ); 55 | $range_marker->brush->width(5); 56 | $range_marker->brush->dash_pattern([qw(15 15)]); 57 | 58 | my $defctx = $cc->get_context('default'); 59 | $cc->plot->grid->visible(0); 60 | 61 | $cc->legend->visible(0); 62 | $defctx->range_axis->label('Lorem'); 63 | $defctx->range_axis->show_ticks(0); 64 | $defctx->domain_axis->label('Ipsum'); 65 | # $defctx->domain_axis->tick_label_angle(0.785398163); 66 | $defctx->range_axis->label_font->family('Hoefler Text'); 67 | $defctx->range_axis->tick_font->family('Gentium'); 68 | $defctx->domain_axis->tick_font->family('Gentium'); 69 | $defctx->domain_axis->label_font->family('Hoefler Text'); 70 | 71 | 72 | $defctx->add_marker($domain_range_marker); 73 | $defctx->add_marker($range_range_marker); 74 | $defctx->add_marker($range_marker); 75 | $defctx->add_marker($domain_marker); 76 | 77 | $cc->draw; 78 | $cc->write('foo.pdf'); 79 | -------------------------------------------------------------------------------- /maxes.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | 12 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf'); 13 | 14 | my @hours = qw( 15 | 1 2 3 4 5 6 16 | ); 17 | my @bw1 = qw( 18 | 10 30 50 120 230 400 19 | ); 20 | my @bw2 = qw( 21 | 0 2 9 12 15 18 22 | ); 23 | 24 | my $series1 = Chart::Clicker::Data::Series->new( 25 | keys => \@hours, 26 | values => \@bw1, 27 | name => 'Feature Requests' 28 | ); 29 | my $series2 = Chart::Clicker::Data::Series->new( 30 | keys => \@hours, 31 | values => \@bw2, 32 | name => 'Patches' 33 | ); 34 | 35 | # We'll create a dataset with our first two series in it... 36 | my $ds = Chart::Clicker::Data::DataSet->new( 37 | series => [ $series1, $series2 ] 38 | ); 39 | 40 | # my $ds0 = Chart::Clicker::Data::DataSet->new( 41 | # series => [ $series2 ] 42 | # ); 43 | 44 | # Create a new context 45 | my $other_context = Chart::Clicker::Context->new( 46 | name => 'other' 47 | ); 48 | #Set it's labels... 49 | $other_context->range_axis->label('Patches'); 50 | $other_context->range_axis->label_font->family('Hoefler Text'); 51 | $other_context->range_axis->tick_font->family('Gentium'); 52 | $other_context->range_axis->format('%d'); 53 | 54 | # $other_context->domain_axis->label('Amet'); 55 | # $other_context->domain_axis->label_font->family('Hoefler Text'); 56 | # $other_context->domain_axis->tick_font->family('Hoefler Text'); 57 | 58 | $cc->legend->visible(1); 59 | 60 | # Instruct the ds1 dataset to use the 'other' context. DataSets default to 61 | # the 'default' context. 62 | # $ds0->context('other'); 63 | $cc->add_to_contexts($other_context); 64 | 65 | # Pretty stuff 66 | $cc->border->width(0); 67 | 68 | my $grey = Graphics::Color::RGB->new( 69 | red => .36, green => .36, blue => .36, alpha => 1 70 | ); 71 | my $moregrey = Graphics::Color::RGB->new( 72 | red => .71, green => .71, blue => .71, alpha => 1 73 | ); 74 | my $orange = Graphics::Color::RGB->new( 75 | red => .88, green => .48, blue => .09, alpha => 1 76 | ); 77 | $cc->color_allocator->colors([ $grey, $orange ]); 78 | 79 | # Add the datasets to the chart 80 | $cc->add_to_datasets($ds); 81 | #$cc->add_to_datasets($ds0); 82 | 83 | $cc->background_color( 84 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 85 | ); 86 | $cc->plot->grid->background_color->alpha(0); 87 | 88 | # Set some labels on the default context 89 | my $defctx = $cc->get_context('default'); 90 | 91 | $other_context->domain_axis($defctx->domain_axis); 92 | 93 | $defctx->range_axis->label('Requests'); 94 | $defctx->range_axis->label_font->family('Hoefler Text'); 95 | $defctx->range_axis->tick_font->family('Gentium'); 96 | $defctx->range_axis->format('%d'); 97 | $defctx->domain_axis->label('Month'); 98 | $defctx->domain_axis->tick_font->family('Gentium'); 99 | $defctx->domain_axis->label_font->family('Hoefler Text'); 100 | $defctx->domain_axis->format('%d'); 101 | $defctx->renderer->brush->width(2); 102 | 103 | $cc->legend->font->family('Hoefler Text'); 104 | 105 | $cc->draw; 106 | 107 | $cc->write('foo.pdf'); 108 | -------------------------------------------------------------------------------- /multiple-axes.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | 12 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf'); 13 | 14 | my @hours = qw( 15 | 1 2 3 4 5 6 7 8 9 10 11 12 16 | ); 17 | my @bw1 = qw( 18 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 19 | ); 20 | my @bw2 = qw( 21 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 22 | ); 23 | my @bw3 = qw( 24 | .3 .4 .2 .5 0 .5 0 .9 .7 .2 .2 .1 25 | ); 26 | 27 | my $series1 = Chart::Clicker::Data::Series->new( 28 | keys => \@hours, 29 | values => \@bw1, 30 | ); 31 | my $series2 = Chart::Clicker::Data::Series->new( 32 | keys => \@hours, 33 | values => \@bw2, 34 | ); 35 | 36 | # We'll create a dataset with our first two series in it... 37 | my $ds = Chart::Clicker::Data::DataSet->new( 38 | series => [ $series1 ] 39 | ); 40 | 41 | my $ds0 = Chart::Clicker::Data::DataSet->new( 42 | series => [ $series2 ] 43 | ); 44 | 45 | # We'll put the third into it's own dataset so we can put it in a new context 46 | my $series3 = Chart::Clicker::Data::Series->new( 47 | keys => \@hours, 48 | values => \@bw3, 49 | ); 50 | my $ds1 = Chart::Clicker::Data::DataSet->new( 51 | series => [ $series3 ] 52 | ); 53 | 54 | # Create a new context 55 | my $other_context = Chart::Clicker::Context->new( 56 | name => 'other' 57 | ); 58 | # Set it's labels... 59 | $other_context->range_axis->label('Solor'); 60 | $other_context->range_axis->label_font->family('Hoefler Text'); 61 | $other_context->range_axis->tick_font->family('Hoefler Text'); 62 | 63 | $other_context->domain_axis->label('Amet'); 64 | $other_context->domain_axis->label_font->family('Hoefler Text'); 65 | $other_context->domain_axis->tick_font->family('Hoefler Text'); 66 | 67 | # Create a new context 68 | my $other1_context = Chart::Clicker::Context->new( 69 | name => 'other1' 70 | ); 71 | # Set it's labels... 72 | $other1_context->range_axis->label('Solor2'); 73 | $other1_context->range_axis->label_font->family('Hoefler Text'); 74 | $other1_context->range_axis->tick_font->family('Hoefler Text'); 75 | 76 | $other1_context->domain_axis->label('Amet 2'); 77 | $other1_context->domain_axis->label_font->family('Hoefler Text'); 78 | $other1_context->domain_axis->tick_font->family('Hoefler Text'); 79 | 80 | 81 | $cc->legend->visible(0); 82 | 83 | # Instruct the ds1 dataset to use the 'other' context. DataSets default to 84 | # the 'default' context. 85 | $ds1->context('other'); 86 | $ds0->context('other1'); 87 | $cc->add_to_contexts($other_context); 88 | $cc->add_to_contexts($other1_context); 89 | 90 | # Pretty stuff 91 | $cc->border->width(0); 92 | 93 | my $grey = Graphics::Color::RGB->new( 94 | red => .36, green => .36, blue => .36, alpha => 1 95 | ); 96 | my $moregrey = Graphics::Color::RGB->new( 97 | red => .71, green => .71, blue => .71, alpha => 1 98 | ); 99 | my $orange = Graphics::Color::RGB->new( 100 | red => .88, green => .48, blue => .09, alpha => 1 101 | ); 102 | $cc->color_allocator->colors([ $grey, $moregrey, $orange ]); 103 | 104 | 105 | # Add the datasets to the chart 106 | $cc->add_to_datasets($ds); 107 | $cc->add_to_datasets($ds1); 108 | $cc->add_to_datasets($ds0); 109 | 110 | $cc->background_color( 111 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 112 | ); 113 | $cc->plot->grid->background_color->alpha(0); 114 | 115 | # Set some labels on the default context 116 | my $defctx = $cc->get_context('default'); 117 | $defctx->range_axis->label('Lorem'); 118 | $defctx->range_axis->label_font->family('Hoefler Text'); 119 | $defctx->range_axis->tick_font->family('Hoefler Text'); 120 | $defctx->domain_axis->label('Ipsum'); 121 | $defctx->domain_axis->tick_font->family('Hoefler Text'); 122 | $defctx->domain_axis->label_font->family('Hoefler Text'); 123 | $defctx->renderer->brush->width(2); 124 | 125 | $cc->legend->font->family('Hoefler Text'); 126 | 127 | $cc->draw; 128 | 129 | $cc->write('foo.pdf'); 130 | -------------------------------------------------------------------------------- /multiple-renderers.pl: -------------------------------------------------------------------------------- 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::Renderer::Bar; 10 | use Chart::Clicker::Renderer::Point; 11 | use Geometry::Primitive::Rectangle; 12 | use Graphics::Color::RGB; 13 | 14 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf'); 15 | 16 | my @hours = qw( 17 | 1 2 3 4 5 6 7 8 9 10 11 12 18 | ); 19 | my @bw1 = qw( 20 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 21 | ); 22 | my @bw2 = qw( 23 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 24 | ); 25 | my @bw3 = qw( 26 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 27 | ); 28 | 29 | my $series1 = Chart::Clicker::Data::Series->new( 30 | keys => \@hours, 31 | values => \@bw1, 32 | ); 33 | my $series2 = Chart::Clicker::Data::Series->new( 34 | keys => \@hours, 35 | values => \@bw2, 36 | ); 37 | 38 | # We'll create a dataset with our first two series in it... 39 | my $ds = Chart::Clicker::Data::DataSet->new( 40 | series => [ $series1 ] 41 | ); 42 | 43 | my $ds0 = Chart::Clicker::Data::DataSet->new( 44 | series => [ $series2 ] 45 | ); 46 | 47 | 48 | # We'll put the third into it's own dataset so we can put it in a new context 49 | my $series3 = Chart::Clicker::Data::Series->new( 50 | keys => \@hours, 51 | values => \@bw3, 52 | ); 53 | my $ds1 = Chart::Clicker::Data::DataSet->new( 54 | series => [ $series3 ] 55 | ); 56 | 57 | # Create a new context 58 | my $other_context = Chart::Clicker::Context->new( 59 | name => 'other' 60 | ); 61 | 62 | my $third_context = Chart::Clicker::Context->new( 63 | name => 'third' 64 | ); 65 | 66 | 67 | my $defctx = $cc->get_context('default'); 68 | 69 | # Set it's labels... 70 | $other_context->range_axis->label('Solor'); 71 | $other_context->domain_axis->label('Amet'); 72 | 73 | $other_context->share_axes_with($defctx); 74 | $third_context->share_axes_with($defctx); 75 | 76 | # Instruct the ds1 dataset to use the 'other' context. DataSets default to 77 | # the 'default' context. 78 | $ds1->context('other'); 79 | $cc->add_to_contexts($other_context); 80 | $ds0->context('third'); 81 | $cc->add_to_contexts($third_context); 82 | 83 | # Pretty stuff 84 | $cc->border->width(0); 85 | 86 | my $grey = Graphics::Color::RGB->new( 87 | red => .36, green => .36, blue => .36, alpha => 1 88 | ); 89 | my $moregrey = Graphics::Color::RGB->new( 90 | red => .71, green => .71, blue => .71, alpha => 1 91 | ); 92 | my $orange = Graphics::Color::RGB->new( 93 | red => .88, green => .48, blue => .09, alpha => 1 94 | ); 95 | $cc->color_allocator->colors([ $grey, $moregrey, $orange ]); 96 | 97 | # Add the datasets to the chart 98 | $cc->add_to_datasets($ds); 99 | $cc->add_to_datasets($ds0); 100 | $cc->add_to_datasets($ds1); 101 | 102 | $cc->plot->grid->show_domain(0); 103 | 104 | # Set some labels on the default context 105 | my $defctx = $cc->get_context('default'); 106 | $other_context->renderer->brush->width(2); 107 | $other_context->renderer->brush->dash_pattern([qw(5 3)]); 108 | $defctx->range_axis->label('Lorem'); 109 | $defctx->domain_axis->label('Ipsum'); 110 | # $defctx->domain_axis->tick_label_angle(0.785398163); 111 | $defctx->range_axis->label_font->family('Hoefler Text'); 112 | $defctx->domain_axis->fudge_amount(.02); 113 | $defctx->range_axis->tick_font->family('Gentium'); 114 | $defctx->domain_axis->tick_font->family('Gentium'); 115 | $defctx->domain_axis->label_font->family('Hoefler Text'); 116 | 117 | $cc->background_color( 118 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 119 | ); 120 | $cc->plot->grid->background_color->alpha(0); 121 | 122 | # Here's the magic: You can set a renderer for any context. In this case 123 | # we'll change the default to a Bar. Voila! 124 | $defctx->renderer(Chart::Clicker::Renderer::Bar->new(bar_padding => 20)); 125 | $third_context->renderer(Chart::Clicker::Renderer::Point->new); 126 | $third_context->renderer->shape->radius(7); 127 | 128 | $cc->legend->font->family('Hoefler Text'); 129 | 130 | $cc->draw; 131 | $cc->write('foo.pdf'); 132 | -------------------------------------------------------------------------------- /overaxis-bar.pl: -------------------------------------------------------------------------------- 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'); -------------------------------------------------------------------------------- /pie/pie-gradient.pl: -------------------------------------------------------------------------------- 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::Renderer::Pie; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 300, height => 250); 14 | 15 | my $series1 = Chart::Clicker::Data::Series->new( 16 | keys => [ 1, 2, 3 ], 17 | values => [ 1, 2, 3 ], 18 | ); 19 | my $series2 = Chart::Clicker::Data::Series->new( 20 | keys => [ 1, 2, 3], 21 | values => [ 1, 1, 3 ], 22 | ); 23 | my $series3 = Chart::Clicker::Data::Series->new( 24 | keys => [ 1, 2, 3], 25 | values => [ 1, 2, 1 ], 26 | ); 27 | my $series4 = Chart::Clicker::Data::Series->new( 28 | keys => [ 1, 2, 3], 29 | values => [ 1, 2, 3 ], 30 | ); 31 | 32 | 33 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3, $series4 ]); 34 | 35 | $cc->add_to_datasets($ds); 36 | 37 | my $defctx = $cc->get_context('default'); 38 | my $ren = Chart::Clicker::Renderer::Pie->new; 39 | $ren->border_color(Graphics::Color::RGB->new(red => 1, green => 1, blue => 1)); 40 | $ren->brush->width(2); 41 | $ren->gradient_color(Graphics::Color::RGB->new(red => 1, green => 1, blue => 1, alpha => .3)); 42 | $ren->gradient_reverse(1); 43 | $defctx->renderer($ren); 44 | $defctx->domain_axis->hidden(1); 45 | $defctx->range_axis->hidden(1); 46 | $cc->plot->grid->visible(0); 47 | 48 | $cc->write_output('pie-gradient.png'); 49 | -------------------------------------------------------------------------------- /pie/pie-gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/pie/pie-gradient.png -------------------------------------------------------------------------------- /pie/pie.pl: -------------------------------------------------------------------------------- 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::Renderer::Pie; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 300, height => 250, format => 'png'); 14 | 15 | my $series1 = Chart::Clicker::Data::Series->new( 16 | keys => [ 1, 2, 3 ], 17 | values => [ 1, 2, 3], 18 | ); 19 | my $series2 = Chart::Clicker::Data::Series->new( 20 | keys => [ 1, 2, 3], 21 | values => [ 1, 1, 1 ], 22 | ); 23 | my $series3 = Chart::Clicker::Data::Series->new( 24 | keys => [ 1, 2, 3], 25 | values => [ 1, 1, 0 ], 26 | ); 27 | 28 | $cc->title->text('Pie'); 29 | $cc->title->padding->bottom(5); 30 | 31 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 32 | 33 | $cc->add_to_datasets($ds); 34 | 35 | my $defctx = $cc->get_context('default'); 36 | my $pie = Chart::Clicker::Renderer::Pie->new; 37 | $pie->brush->width(3); 38 | $pie->border_color(Graphics::Color::RGB->new(red => 1, green => 1, blue => 1)); 39 | $defctx->renderer($pie); 40 | $defctx->domain_axis->hidden(1); 41 | $defctx->range_axis->hidden(1); 42 | $cc->plot->grid->visible(0); 43 | 44 | $cc->write_output('pie.png'); 45 | -------------------------------------------------------------------------------- /pie/pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/pie/pie.png -------------------------------------------------------------------------------- /point/point.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Chart::Clicker::Renderer::Point; 11 | use Graphics::Color::RGB; 12 | use Geometry::Primitive::Circle; 13 | 14 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 15 | 16 | my @hours = qw( 17 | 1 2 3 4 5 6 7 8 9 10 11 12 18 | ); 19 | my @bw1 = qw( 20 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 21 | ); 22 | my @bw2 = qw( 23 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 24 | ); 25 | my @bw3 = qw( 26 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 27 | ); 28 | 29 | my $series1 = Chart::Clicker::Data::Series->new( 30 | keys => \@hours, 31 | values => \@bw1, 32 | ); 33 | my $series2 = Chart::Clicker::Data::Series->new( 34 | keys => \@hours, 35 | values => \@bw2, 36 | ); 37 | 38 | my $series3 = Chart::Clicker::Data::Series->new( 39 | keys => \@hours, 40 | values => \@bw3, 41 | ); 42 | 43 | $cc->title->text('Point'); 44 | $cc->title->padding->bottom(5); 45 | 46 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 47 | 48 | $cc->add_to_datasets($ds); 49 | 50 | my $defctx = $cc->get_context('default'); 51 | 52 | $defctx->renderer(Chart::Clicker::Renderer::Point->new); 53 | 54 | $cc->write_output('point.png'); 55 | -------------------------------------------------------------------------------- /point/point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/point/point.png -------------------------------------------------------------------------------- /polararea/polararea.pl: -------------------------------------------------------------------------------- 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::Renderer::PolarArea; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 300, height => 250); 14 | 15 | my $series1 = Chart::Clicker::Data::Series->new( 16 | keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 17 | values => [ 5, 10, 7, 4, 8, 9, 4, 10, 3, 6 ], 18 | name => 'Fails' 19 | ); 20 | my $series2 = Chart::Clicker::Data::Series->new( 21 | keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 22 | values => [ 5, 10, 16, 9, 4, 4, 11, 9, 3, 1], 23 | name => 'Whales' 24 | ); 25 | my $series3 = Chart::Clicker::Data::Series->new( 26 | keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 27 | values => [ 2, 4, 6, 1, 4, 2, 1, 4, 2, 1], 28 | name => 'Tails' 29 | ); 30 | 31 | 32 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 33 | 34 | my $lgreen = Graphics::Color::RGB->new(red => .69, green => .74, blue => .71); 35 | my $green = Graphics::Color::RGB->new(red => .40, green => .49, blue => .45); 36 | my $red = Graphics::Color::RGB->new(red => .65, green => .09, blue => .09); 37 | $cc->color_allocator->colors([ $lgreen, $green, $red ]); 38 | 39 | $cc->add_to_datasets($ds); 40 | 41 | my $defctx = $cc->get_context('default'); 42 | my $polar = Chart::Clicker::Renderer::PolarArea->new; 43 | $polar->border_color(Graphics::Color::RGB->new(red => 1, blue => 1, green => 1)); 44 | $polar->brush->width(2); 45 | $defctx->renderer($polar); 46 | $defctx->domain_axis->hidden(1); 47 | $defctx->range_axis->hidden(1); 48 | $cc->plot->grid->visible(0); 49 | 50 | $cc->write_output('polararea.png'); 51 | -------------------------------------------------------------------------------- /polararea/polararea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gphat/chart-clicker-examples/fce33e051614029aaa8c1cc5f9ace36402a2fd0f/polararea/polararea.png -------------------------------------------------------------------------------- /simple.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Geometry::Primitive::Circle; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | 43 | $cc->border->width(0); 44 | $cc->background_color( 45 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 46 | ); 47 | my $grey = Graphics::Color::RGB->new( 48 | red => .36, green => .36, blue => .36, alpha => 1 49 | ); 50 | my $moregrey = Graphics::Color::RGB->new( 51 | red => .71, green => .71, blue => .71, alpha => 1 52 | ); 53 | my $orange = Graphics::Color::RGB->new( 54 | red => .88, green => .48, blue => .09, alpha => 1 55 | ); 56 | $cc->color_allocator->colors([ $grey, $moregrey, $orange ]); 57 | 58 | $cc->plot->grid->background_color->alpha(0); 59 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 60 | 61 | $cc->add_to_datasets($ds); 62 | 63 | my $defctx = $cc->get_context('default'); 64 | 65 | $defctx->range_axis->label('Lorem'); 66 | $defctx->domain_axis->label('Ipsum'); 67 | # $defctx->range_axis->brush->width(0); 68 | $defctx->domain_axis->tick_label_angle(0.785398163); 69 | $defctx->range_axis->fudge_amount(.05); 70 | $defctx->domain_axis->fudge_amount(.05); 71 | $defctx->range_axis->label_font->family('Hoefler Text'); 72 | $defctx->range_axis->tick_font->family('Gentium'); 73 | $defctx->domain_axis->tick_font->family('Gentium'); 74 | $defctx->domain_axis->label_font->family('Hoefler Text'); 75 | # $defctx->range_axis->show_ticks(0); 76 | $defctx->renderer->shape( 77 | Geometry::Primitive::Circle->new({ 78 | radius => 5, 79 | }) 80 | ); 81 | $defctx->renderer->shape_brush( 82 | Graphics::Primitive::Brush->new( 83 | width => 2, 84 | color => Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 85 | ) 86 | ); 87 | # $defctx->renderer->additive(1); 88 | $defctx->renderer->brush->width(2); 89 | 90 | 91 | $cc->legend->font->family('Hoefler Text'); 92 | 93 | $cc->draw; 94 | $cc->write('simple.png'); 95 | -------------------------------------------------------------------------------- /sparkline.pl: -------------------------------------------------------------------------------- 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::Renderer::Point; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 50, format => 'pdf'); 14 | 15 | my $series = Chart::Clicker::Data::Series->new( 16 | keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 17 | values => [ 5.8, 5.0, 4.9, 4.8, 4.5, 4.25, 3.5, 2.9, 2.5, 1.8, .9, .8, .7, 1.1, 1.7, 2.5, 3.0, 4.5, 5.0, 4.9, 4.7, 4.8, 4.2, 4.4], 18 | ); 19 | my $series2 = Chart::Clicker::Data::Series->new( 20 | keys => [ 24 ], 21 | values => [ 4.4 ] 22 | ); 23 | my $series3 = Chart::Clicker::Data::Series->new( 24 | keys => [ 13 ], 25 | values => [ .7 ] 26 | ); 27 | 28 | 29 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series ]); 30 | 31 | $cc->add_to_datasets($ds); 32 | 33 | my $defctx = $cc->get_context('default'); 34 | 35 | my $highds = Chart::Clicker::Data::DataSet->new(series => [ $series2 ]); 36 | $cc->add_to_datasets($highds); 37 | 38 | my $highctx = Chart::Clicker::Context->new( 39 | name => 'high', 40 | renderer => Chart::Clicker::Renderer::Point->new( 41 | shape => Geometry::Primitive::Circle->new( 42 | radius => 5 43 | ), 44 | shape_brush => Graphics::Primitive::Brush->new( 45 | width => 1, 46 | color => Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 47 | ) 48 | ), 49 | range_axis => $defctx->range_axis, 50 | domain_axis => $defctx->domain_axis 51 | ); 52 | $cc->add_to_contexts($highctx); 53 | $highds->context('high'); 54 | # 55 | my $noteds = Chart::Clicker::Data::DataSet->new(series => [ $series3 ]); 56 | $cc->add_to_datasets($noteds); 57 | 58 | my $notectx = Chart::Clicker::Context->new( 59 | name => 'notable', 60 | renderer => Chart::Clicker::Renderer::Point->new( 61 | shape => Geometry::Primitive::Circle->new( 62 | radius => 5 63 | ), 64 | shape_brush => Graphics::Primitive::Brush->new( 65 | width => 1, 66 | color => Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 67 | ) 68 | ), 69 | range_axis => $defctx->range_axis, 70 | domain_axis => $defctx->domain_axis 71 | ); 72 | $cc->add_to_contexts($notectx); 73 | $noteds->context('notable'); 74 | 75 | my $grey = Graphics::Color::RGB->new( 76 | red => .36, green => .36, blue => .36, alpha => 1 77 | ); 78 | my $moregrey = Graphics::Color::RGB->new( 79 | red => .71, green => .71, blue => .71, alpha => 1 80 | ); 81 | my $orange = Graphics::Color::RGB->new( 82 | red => .88, green => .48, blue => .09, alpha => 1 83 | ); 84 | 85 | # my $mark = Chart::Clicker::Data::Marker->new(value => 2, value2 => 4); 86 | # $mark->brush->color( 87 | # Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .15) 88 | # ); 89 | # $mark->inside_color( 90 | # Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .15) 91 | # ); 92 | # $defctx->add_marker($mark); 93 | 94 | $cc->background_color( 95 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 96 | ); 97 | $cc->color_allocator->colors([ $grey, $orange, $moregrey ]); 98 | 99 | $cc->plot->grid->visible(0); 100 | $cc->legend->visible(0); 101 | $cc->padding(2); 102 | $cc->border->width(0); 103 | 104 | $defctx->range_axis->hidden(1); 105 | $defctx->range_axis->fudge_amount(.2); 106 | $defctx->domain_axis->hidden(1); 107 | $defctx->domain_axis->fudge_amount(.1); 108 | $defctx->renderer->brush->width(3); 109 | 110 | $cc->draw; 111 | $cc->write('foo.pdf') -------------------------------------------------------------------------------- /stackbar.pl: -------------------------------------------------------------------------------- 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::Renderer::StackedBar; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'pdf'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | # We'll put the third into it's own dataset so we can put it in a new context 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | # We'll create a dataset with our first two series in it... 43 | my $ds = Chart::Clicker::Data::DataSet->new( 44 | series => [ $series1, $series2, $series3 ] 45 | ); 46 | 47 | # Create a new context 48 | my $other_context = Chart::Clicker::Context->new( 49 | name => 'other' 50 | ); 51 | 52 | my $defctx = $cc->get_context('default'); 53 | 54 | # Pretty stuff 55 | $cc->border->width(0); 56 | 57 | my $grey = Graphics::Color::RGB->new( 58 | red => .36, green => .36, blue => .36, alpha => 1 59 | ); 60 | my $moregrey = Graphics::Color::RGB->new( 61 | red => .71, green => .71, blue => .71, alpha => 1 62 | ); 63 | my $orange = Graphics::Color::RGB->new( 64 | red => .88, green => .48, blue => .09, alpha => 1 65 | ); 66 | $cc->color_allocator->colors([ $grey, $moregrey, $orange ]); 67 | 68 | # Add the datasets to the chart 69 | $cc->add_to_datasets($ds); 70 | 71 | # Set some labels on the default context 72 | my $defctx = $cc->get_context('default'); 73 | $defctx->range_axis->label('Lorem'); 74 | $defctx->domain_axis->label('Ipsum'); 75 | # $defctx->domain_axis->tick_label_angle(0.785398163); 76 | $defctx->range_axis->label_font->family('Hoefler Text'); 77 | $defctx->domain_axis->fudge_amount(.05); 78 | $defctx->range_axis->tick_font->family('Gentium'); 79 | $defctx->domain_axis->tick_font->family('Gentium'); 80 | $defctx->domain_axis->label_font->family('Hoefler Text'); 81 | 82 | $cc->legend->visible(0); 83 | 84 | $cc->background_color( 85 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 86 | ); 87 | $cc->plot->grid->background_color->alpha(0); 88 | 89 | # Here's the magic: You can set a renderer for any context. In this case 90 | # we'll change the default to a Bar. Voila! 91 | $defctx->renderer(Chart::Clicker::Renderer::StackedBar->new(bar_padding => 8)); 92 | 93 | $cc->legend->font->family('Hoefler Text'); 94 | 95 | $cc->draw; 96 | $cc->write('foo.pdf'); 97 | -------------------------------------------------------------------------------- /stackedarea.pl: -------------------------------------------------------------------------------- 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 Geometry::Primitive::Rectangle; 10 | use Graphics::Color::RGB; 11 | use Chart::Clicker::Renderer::StackedArea; 12 | 13 | my $cc = Chart::Clicker->new(width => 550, height => 300, format => 'pdf'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | ); 18 | my @bw1 = qw( 19 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 20 | ); 21 | my @bw2 = qw( 22 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 23 | ); 24 | my @bw3 = qw( 25 | .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1 26 | ); 27 | 28 | my $series1 = Chart::Clicker::Data::Series->new( 29 | keys => \@hours, 30 | values => \@bw1, 31 | ); 32 | my $series2 = Chart::Clicker::Data::Series->new( 33 | keys => \@hours, 34 | values => \@bw2, 35 | ); 36 | 37 | my $series3 = Chart::Clicker::Data::Series->new( 38 | keys => \@hours, 39 | values => \@bw3, 40 | ); 41 | 42 | 43 | $cc->border->width(0); 44 | $cc->background_color( 45 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 46 | ); 47 | my $grey = Graphics::Color::RGB->new( 48 | red => .36, green => .36, blue => .36, alpha => 1 49 | ); 50 | my $moregrey = Graphics::Color::RGB->new( 51 | red => .71, green => .71, blue => .71, alpha => 1 52 | ); 53 | my $orange = Graphics::Color::RGB->new( 54 | red => .88, green => .48, blue => .09, alpha => 1 55 | ); 56 | $cc->color_allocator->colors([ $grey, $moregrey, $orange ]); 57 | 58 | $cc->plot->grid->background_color->alpha(0); 59 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]); 60 | 61 | $cc->add_to_datasets($ds); 62 | 63 | my $defctx = $cc->get_context('default'); 64 | 65 | $cc->legend->visible(0); 66 | # $defctx->range_axis->label('Lorem'); 67 | # $defctx->domain_axis->label('Ipsum'); 68 | $defctx->range_axis->brush->width(0); 69 | $defctx->domain_axis->brush->width(0); 70 | # $defctx->range_axis->show_ticks(0); 71 | # $defctx->domain_axis->show_ticks(0); 72 | 73 | # $defctx->domain_axis->tick_label_angle(0.785398163); 74 | $defctx->range_axis->label_font->family('Hoefler Text'); 75 | $defctx->range_axis->tick_font->family('Gentium'); 76 | $defctx->domain_axis->tick_font->family('Gentium'); 77 | $defctx->domain_axis->label_font->family('Hoefler Text'); 78 | $defctx->renderer(Chart::Clicker::Renderer::StackedArea->new(opacity => .75)); 79 | $defctx->renderer->brush->width(2); 80 | 81 | $cc->legend->font->family('Hoefler Text'); 82 | 83 | $cc->draw; 84 | $cc->write('foo.pdf'); 85 | -------------------------------------------------------------------------------- /tufte-whitegrid.pl: -------------------------------------------------------------------------------- 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::Renderer::Point; 10 | use Geometry::Primitive::Rectangle; 11 | use Graphics::Color::RGB; 12 | 13 | my $cc = Chart::Clicker->new(width => 500, height => 200, format => 'pdf'); 14 | 15 | my @hours = qw( 16 | 1 2 3 4 5 6 7 8 9 10 11 12 17 | 13 14 15 16 17 18 19 20 21 22 23 24 18 | ); 19 | my @bw = qw( 20 | 5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8 21 | .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4 22 | ); 23 | 24 | my $series = Chart::Clicker::Data::Series->new( 25 | keys => \@hours, 26 | values => \@bw, 27 | ); 28 | 29 | my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series ]); 30 | 31 | $cc->add_to_datasets($ds); 32 | 33 | my $defctx = $cc->get_context('default'); 34 | 35 | my $grey = Graphics::Color::RGB->new( 36 | red => .36, green => .36, blue => .36, alpha => 1 37 | ); 38 | 39 | $cc->color_allocator->colors([ $grey ]); 40 | 41 | $cc->grid_over(1); 42 | $cc->plot->grid->range_brush->width(5); 43 | $cc->plot->grid->show_domain(1); 44 | $cc->plot->grid->domain_brush->color( 45 | Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .10) 46 | ); 47 | 48 | $cc->legend->visible(0); 49 | 50 | $cc->border->width(0); 51 | $cc->background_color( 52 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 53 | ); 54 | $cc->plot->grid->range_brush->color( 55 | Graphics::Color::RGB->new(red => .95, green => .94, blue => .92) 56 | ); 57 | 58 | $cc->legend_position('n'); 59 | $defctx->range_axis->fudge_amount(.015); 60 | $defctx->range_axis->tick_values([qw(1 2 3 4 5)]); 61 | $defctx->range_axis->format('%d'); 62 | $defctx->range_axis->tick_font->family('Gentium'); 63 | 64 | $defctx->domain_axis->brush->width(0); 65 | $defctx->domain_axis->tick_values([qw(3 6 9 12 15 18 21)]); 66 | $defctx->domain_axis->format('%d'); 67 | $defctx->domain_axis->tick_font->family('Gentium'); 68 | 69 | $defctx->domain_axis->fudge_amount(.015); 70 | $defctx->range_axis->brush->width(0); 71 | 72 | # $defctx->domain_axis->tick_label_angle(0.785398163); 73 | $defctx->renderer->brush->width(3); 74 | 75 | $cc->draw; 76 | $cc->write('foo.pdf'); 77 | --------------------------------------------------------------------------------