Permalink
Browse files

Add write_output method to use in place of draw & write.

  • Loading branch information...
1 parent bb4cc1d commit fbd6c071af15fedd0057fa441a49cd32048ad6e3 @gphat committed Jul 12, 2009
View
@@ -54,5 +54,4 @@
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
$def->domain_axis->format('%d');
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -55,5 +55,4 @@
$def->domain_axis->format('%d');
$def->domain_axis->fudge_amount(.05);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -56,5 +56,4 @@
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
$def->domain_axis->format('%d');
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -53,5 +53,4 @@
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
$def->domain_axis->format('%d');
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -62,5 +62,4 @@
);
$defctx->renderer->brush->width(2);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -54,5 +54,4 @@
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
$def->domain_axis->format('%d');
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -47,5 +47,4 @@
$defctx->add_marker($range_marker);
$defctx->add_marker($domain_marker);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -74,5 +74,4 @@
$defctx->domain_axis->tick_label_angle(0.785398163);
$defctx->renderer->brush->width(1);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -78,5 +78,4 @@
# we'll change the default to a Bar. Voila!
$defctx->renderer(Chart::Clicker::Renderer::Bar->new);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -75,5 +75,4 @@
)
);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -31,5 +31,4 @@
$defctx->range_axis->hidden(1);
$cc->plot->grid->visible(0);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -53,5 +53,4 @@
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
$def->domain_axis->format('%d');
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -81,5 +81,4 @@
# we'll change the default to a Bar. Voila!
$defctx->renderer(Chart::Clicker::Renderer::Bar->new);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -2,12 +2,8 @@
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;
my $cc = Chart::Clicker->new(width => 500, height => 400);
@@ -20,5 +16,4 @@
$cc->add_to_datasets($ds);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -98,5 +98,4 @@
$defctx->domain_axis->fudge_amount(.1);
$defctx->renderer->brush->width(1);
-$cc->draw;
-$cc->write('foo.png')
+$cc->write_output('foo.png')
@@ -54,5 +54,4 @@
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
$def->domain_axis->format('%d');
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -55,5 +55,4 @@
$def->domain_axis->format('%d');
$def->domain_axis->fudge_amount(.05);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -69,5 +69,4 @@
# $defctx->domain_axis->tick_label_angle(0.785398163);
$defctx->renderer->brush->width(3);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
@@ -16,5 +16,4 @@
$cc->add_to_datasets($ds);
-$cc->draw;
-$cc->write('foo.png');
+$cc->write_output('foo.png');
View
@@ -330,6 +330,13 @@ sub set_renderer {
$ctx->renderer($renderer);
}
+sub write_output {
+ my $self = shift;
+
+ $self->draw;
+ $self->write(@_);
+}
+
__PACKAGE__->meta->make_immutable;
no Moose;
@@ -344,7 +351,7 @@ Chart::Clicker - Powerful, extensible charting.
=head1 SYNOPSIS
- use Chart::Clicker
+ use Chart::Clicker;
use Chart::Clicker::Data::Series;
use Chart::Clicker::Data::DataSet;
@@ -359,8 +366,7 @@ Chart::Clicker - Powerful, extensible charting.
$cc->add_to_datasets($ds);
- $cc->draw;
- $cc->write('foo.png')
+ $cc->write_output('foo.png')
=head1 DESCRIPTION
@@ -500,10 +506,14 @@ Sets the renderer on the specified context. If no context is provided then
=head2 write
+
+=head2 write_output ($path)
+
Write the chart output to the specified location. Output is written in the
-format provided to the constructor (which defaults to Png).
+format provided to the constructor (which defaults to Png). Internally
+calls C<draw> for you. If you use this method, do not call C<draw> first!
- $c->write('/path/to/the.png');
+ $c->write_output('/path/to/the.png');
=head1 AUTHOR
@@ -70,7 +70,7 @@ Used to highlight a particular key, value or range of either.
my $ctx = $cc->get_context('default');
$ctx->add_marker($mark);
- $cc->draw;
+ $cc->write_output('foo.png');
=head1 METHODS
@@ -39,9 +39,8 @@ contributions, drop me a line!
# add the dataset to the chart
$chart->add_to_datasets($dataset);
- # draw and write the chart to a file
- $chart->draw;
- $chart->write('chart.png');
+ # write the chart to a file
+ $chart->write_output('chart.png');
=head2 Simple chart from multiple data sources
@@ -68,8 +67,7 @@ contributions, drop me a line!
$chart->add_to_datasets($dataset);
- $chart->draw;
- $chart->write('chart.png');
+ $chart->write_output('chart.png');
=head2 Simple chart with multiple data sources and custom colors
@@ -126,8 +124,7 @@ contributions, drop me a line!
# assign the color allocator to the chart
$chart->color_allocator($ca);
- $chart->draw;
- $chart->write('chart.png');
+ $chart->write_output('chart.png');
=head2 Example 4 : Simple chart with a different render type
@@ -158,8 +155,7 @@ contributions, drop me a line!
# assign the renderer to the default context
$chart->get_context('default')->renderer($renderer);
- $chart->draw;
- $chart->write('chart.png');
+ $chart->write_output('chart.png');
=head1 AUTHOR

0 comments on commit fbd6c07

Please sign in to comment.