This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
427 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/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 => 'png'); | ||
|
||
my @hours = qw( | ||
); | ||
|
||
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 ] | ||
); | ||
|
||
# Pretty stuff | ||
$cc->border->width(0); | ||
|
||
# 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('Lorem'); | ||
$defctx->range_axis->fudge_amount(.2); | ||
$defctx->domain_axis->label('Ipsum'); | ||
$defctx->domain_axis->tick_label_angle(0.785398163); | ||
$defctx->domain_axis->fudge_amount(.06); | ||
|
||
# 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.png'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
|
||
use Chart::Clicker; | ||
use Chart::Clicker::Data::DataSet; | ||
use Chart::Clicker::Data::Series; | ||
|
||
my $cc = Chart::Clicker->new(width => 500, height => 400); | ||
|
||
my $series1 = Chart::Clicker::Data::Series->new( | ||
keys => qw(1 2 3 4 5 6 7 8 9 10 11 12), | ||
values => qw(5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8) | ||
); | ||
|
||
my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1 ]); | ||
|
||
$cc->add_to_datasets($ds); | ||
|
||
$cc->draw; | ||
$cc->write('foo.png'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package Chart::Clicker::Data::Series::HighLow; | ||
use Moose; | ||
|
||
extends 'Chart::Clicker::Data::Series'; | ||
|
||
use List::Util qw(max min); | ||
|
||
has 'highs' => ( | ||
metaclass => 'Collection::Array', | ||
is => 'rw', | ||
isa => 'ArrayRef', | ||
default => sub { [] }, | ||
provides => { | ||
'push' => 'add_to_highs', | ||
'count' => 'high_count', | ||
'get' => 'get_high' | ||
} | ||
); | ||
|
||
has 'lows' => ( | ||
metaclass => 'Collection::Array', | ||
is => 'rw', | ||
isa => 'ArrayRef', | ||
default => sub { [] }, | ||
provides => { | ||
'push' => 'add_to_lows', | ||
'count' => 'low_count', | ||
'get' => 'get_low' | ||
} | ||
); | ||
|
||
has 'opens' => ( | ||
metaclass => 'Collection::Array', | ||
is => 'rw', | ||
isa => 'ArrayRef', | ||
default => sub { [] }, | ||
provides => { | ||
'push' => 'add_to_opens', | ||
'count' => 'open_count', | ||
'get' => 'get_open' | ||
} | ||
); | ||
|
||
sub find_range { | ||
my ($self) = @_; | ||
|
||
return Chart::Clicker::Data::Range->new( | ||
lower => min(@{ $self->lows }), | ||
upper => max(@{ $self->highs }) | ||
); | ||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
|
||
no Moose; | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Chart::Clicker::Data::Series::HighLow | ||
=head1 DESCRIPTION | ||
Chart::Clicker::Data::Series::HighLow is an extension of the Series class | ||
that provides storage for a three new variables called for use with the | ||
CandleStick renderer. The general idea is: | ||
--- <-- High | ||
| | ||
| | ||
- <-- max of Open, Value | ||
| | | ||
| | | ||
- <-- min of Open, Value | ||
| | ||
| | ||
--- <-- Low | ||
=head1 SYNOPSIS | ||
use Chart::Clicker::Data::Series::HighLow; | ||
my $series = Chart::Clicker::Data::Series::HighLow->new({ | ||
keys => \@keys, | ||
values => \@values, | ||
highs => \@highs, | ||
lows => \@lows, | ||
opens => \@opens | ||
}); | ||
=head1 METHODS | ||
=head2 new | ||
Creates a new, empty Series::Size | ||
=head2 add_to_highs | ||
Adds a high to this series. | ||
=head2 add_to_lows | ||
Adds a high to this series. | ||
=head2 add_to_opens | ||
Adds an open to this series. | ||
=head2 get_high | ||
Get a high by it's index. | ||
=head2 get_low | ||
Get a low by it's index. | ||
=head2 get_open | ||
Get an open by it's index. | ||
=head2 highs | ||
Set/Get the highs for this series. | ||
=head2 lows | ||
Set/Get the lows for this series. | ||
=head2 opens | ||
Set/Get the opens for this series. | ||
=head2 high_count | ||
Gets the count of sizes in this series. | ||
=head2 low_count | ||
Gets the count of lows in this series. | ||
=head2 open_count | ||
Gets the count of opens in this series. | ||
=head1 AUTHOR | ||
Cory 'G' Watson <gphat@cpan.org> | ||
=head1 LICENSE | ||
You can redistribute and/or modify this code under the same terms as Perl | ||
itself. | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.