| 1 | package Chart::Clicker::Axis::DivisionType::Exact; | ||
| 2 | $Chart::Clicker::Axis::DivisionType::Exact::VERSION = '2.89'; | ||
| 3 | use Moose::Role; | ||
| 4 | with qw{Chart::Clicker::Axis::DivisionType}; | ||
| 5 | |||
| 6 | sub best_tick_size { | ||
| 7 | my ($self) = @_; | ||
| 8 | |||
| 9 | return $self->range->span / ( $self->ticks - 1 ); | ||
| 10 | } | ||
| 11 | |||
| 12 | sub _real_divvy { | ||
| 13 | my ($self) = @_; | ||
| 14 | |||
| 15 | my $per = $self->best_tick_size; | ||
| 16 | |||
| 17 | my @vals; | ||
| 18 | for ( 0 .. ( $self->ticks - 1 ) ) { | ||
| 19 | push( @vals, $self->range->lower + ( $_ * $per ) ); | ||
| 20 | } | ||
| 21 | |||
| 22 | return \@vals; | ||
| 23 | } | ||
| 24 | |||
| 25 | no Moose; | ||
| 26 | 1; | ||
| 27 | |||
| 28 | __END__ | ||
| 29 | |||
| 30 | =pod | ||
| 31 | |||
| 32 | =head1 NAME | ||
| 33 | |||
| 34 | Chart::Clicker::Axis::DivisionType::Exact | ||
| 35 | |||
| 36 | =head1 VERSION | ||
| 37 | |||
| 38 | version 2.89 | ||
| 39 | |||
| 40 | =head1 SYNOPSIS | ||
| 41 | |||
| 42 | use Chart::Clicker::Axis; | ||
| 43 | |||
| 44 | my $axis = Chart::Clicker::Axis->new({ | ||
| 45 | tick_division_type => 'Exact' | ||
| 46 | }); | ||
| 47 | |||
| 48 | =head1 DESCRIPTION | ||
| 49 | |||
| 50 | Role describing how to divide data for Chart::Clicker::Axis. | ||
| 51 | |||
| 52 | =head1 NAME | ||
| 53 | |||
| 54 | Chart::Clicker::Axis::DivisionType::Exact - Divide axis in exact increments, linear scale. | ||
| 55 | |||
| 56 | =head1 METHODS | ||
| 57 | |||
| 58 | =head2 best_tick_size | ||
| 59 | |||
| 60 | The tick division calculated by taking the range and dividing by the requested number of ticks. | ||
| 61 | |||
| 62 | =head2 divvy | ||
| 63 | |||
| 64 | Divides the range up into exact division for L<Chart::Clicker::Axis>. | ||
| 65 | |||
| 66 | =head1 AUTHOR | ||
| 67 | |||
| 68 | Rod Taylor <chartclicker@rbt.ca> | ||
| 69 | |||
| 70 | =head1 SEE ALSO | ||
| 71 | |||
| 72 | perl(1) | ||
| 73 | |||
| 74 | =head1 LICENSE | ||
| 75 | |||
| 76 | You can redistribute and/or modify this code under the same terms as Perl | ||
| 77 | itself. | ||
| 78 | |||
| 79 | =head1 AUTHOR | ||
| 80 | |||
| 81 | Cory G Watson <gphat@cpan.org> | ||
| 82 | |||
| 83 | =head1 COPYRIGHT AND LICENSE | ||
| 84 | |||
| 85 | This software is copyright (c) 2016 by Cory G Watson. | ||
| 86 | |||
| 87 | This is free software; you can redistribute it and/or modify it under | ||
| 88 | the same terms as the Perl 5 programming language system itself. | ||
| 89 | |||
| 90 | =cut |