| 1 | package Chart::Clicker::Context; | ||
| 2 | 8 | $Chart::Clicker::Context::VERSION = '2.89'; | |
| 3 | 8 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | # ABSTRACT: A rendering context: Axes, Markers and a Renderer | ||
| 6 | |||
| 7 | 8 | ▶ | use Chart::Clicker::Axis; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 8 | ▶ | use Chart::Clicker::Renderer::Line; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | |||
| 11 | has 'domain_axis' => ( | ||
| 12 | is => 'rw', | ||
| 13 | isa => 'Chart::Clicker::Axis', | ||
| 14 | default => sub { | ||
| 15 | 9 | ▶ | Chart::Clicker::Axis->new( |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 16 | orientation => 'horizontal', | ||
| 17 | position => 'bottom', | ||
| 18 | format => '%0.2f' | ||
| 19 | ) | ||
| 20 | } | ||
| 21 | 8 | ); | |
| 22 | |||
| 23 | |||
| 24 | has 'markers' => ( | ||
| 25 | traits => [ 'Array' ], | ||
| 26 | is => 'rw', | ||
| 27 | isa => 'ArrayRef[Chart::Clicker::Data::Marker]', | ||
| 28 | 10 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 29 | 8 | handles => { | |
| 30 | 'marker_count' => 'count', | ||
| 31 | 'add_marker' => 'push' | ||
| 32 | } | ||
| 33 | ); | ||
| 34 | |||
| 35 | |||
| 36 | 8 | has 'name' => ( | |
| 37 | is => 'rw', | ||
| 38 | isa => 'Str', | ||
| 39 | required => 1 | ||
| 40 | ); | ||
| 41 | |||
| 42 | |||
| 43 | has 'range_axis' => ( | ||
| 44 | is => 'rw', | ||
| 45 | isa => 'Chart::Clicker::Axis', | ||
| 46 | default => sub { | ||
| 47 | 10 | ▶ | Chart::Clicker::Axis->new( |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 48 | orientation => 'vertical', | ||
| 49 | position => 'left', | ||
| 50 | format => '%0.2f' | ||
| 51 | ) | ||
| 52 | } | ||
| 53 | 8 | ); | |
| 54 | |||
| 55 | |||
| 56 | has 'renderer' => ( | ||
| 57 | is => 'rw', | ||
| 58 | isa => 'Chart::Clicker::Renderer', | ||
| 59 | 9 | ▶ | default => sub { Chart::Clicker::Renderer::Line->new }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 60 | 8 | ); | |
| 61 | |||
| 62 | |||
| 63 | sub share_axes_with { | ||
| 64 | 0 | ▶ | my ($self, $other_context) = @_; |
|
Subroutine
share_axes_with: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 65 | |||
| 66 | 0 | $self->range_axis($other_context->range_axis); | |
| 67 | 0 | $self->domain_axis($other_context->domain_axis); | |
| 68 | } | ||
| 69 | |||
| 70 | 8 | __PACKAGE__->meta->make_immutable; | |
| 71 | |||
| 72 | 8 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 73 | |||
| 74 | 8 | 1; | |
| 75 | |||
| 76 | __END__ | ||
| 77 | |||
| 78 | =pod | ||
| 79 | |||
| 80 | =head1 NAME | ||
| 81 | |||
| 82 | Chart::Clicker::Context - A rendering context: Axes, Markers and a Renderer | ||
| 83 | |||
| 84 | =head1 VERSION | ||
| 85 | |||
| 86 | version 2.89 | ||
| 87 | |||
| 88 | =head1 SYNOPSIS | ||
| 89 | |||
| 90 | my $clicker = Chart::Clicker->new; | ||
| 91 | |||
| 92 | my $context = Chart::Clicker::Context->new( | ||
| 93 | name => 'Foo' | ||
| 94 | ); | ||
| 95 | |||
| 96 | $clicker->add_to_contexts('foo', $context); | ||
| 97 | |||
| 98 | =head1 DESCRIPTION | ||
| 99 | |||
| 100 | Contexts represent the way a dataset should be charted. Multiple contexts | ||
| 101 | allow a chart with multiple renderers and axes. See the CONTEXTS section | ||
| 102 | in L<Chart::Clicker>. | ||
| 103 | |||
| 104 | =head2 renderer | ||
| 105 | |||
| 106 | Set/get this context's renderer | ||
| 107 | |||
| 108 | =head1 ATTRIBUTES | ||
| 109 | |||
| 110 | =head2 domain_axis | ||
| 111 | |||
| 112 | Set/get this context's domain L<Axis|Chart::Clicker::Axis>. | ||
| 113 | |||
| 114 | =head2 markers | ||
| 115 | |||
| 116 | An arrayref of L<Chart::Clicker::Data::Marker>s for this context. | ||
| 117 | |||
| 118 | =head2 name | ||
| 119 | |||
| 120 | Set/get this context's name | ||
| 121 | |||
| 122 | =head2 range_axis | ||
| 123 | |||
| 124 | Set/get this context's range L<Axis|Chart::Clicker::Axis>. | ||
| 125 | |||
| 126 | =head1 METHODS | ||
| 127 | |||
| 128 | =head2 add_marker | ||
| 129 | |||
| 130 | Add a marker to this context. | ||
| 131 | |||
| 132 | =head2 marker_count | ||
| 133 | |||
| 134 | Get a count of markers in this context. | ||
| 135 | |||
| 136 | =head2 share_axes_with ($other_context) | ||
| 137 | |||
| 138 | Sets this context's axes to those of the supplied context. This is a | ||
| 139 | convenience method for quickly sharing axes. It's simple doing: | ||
| 140 | |||
| 141 | $self->range_axis($other_context->range_axis); | ||
| 142 | $self->domain_axis($other_context->domain_axis); | ||
| 143 | |||
| 144 | =head1 AUTHOR | ||
| 145 | |||
| 146 | Cory G Watson <gphat@cpan.org> | ||
| 147 | |||
| 148 | =head1 COPYRIGHT AND LICENSE | ||
| 149 | |||
| 150 | This software is copyright (c) 2016 by Cory G Watson. | ||
| 151 | |||
| 152 | This is free software; you can redistribute it and/or modify it under | ||
| 153 | the same terms as the Perl 5 programming language system itself. | ||
| 154 | |||
| 155 | =cut | ||