Chart-Clicker

 view release on metacpan or  search on metacpan

lib/Chart/Clicker/Axis/DivisionType/LinearRounded.pm  view on Meta::CPAN

    my @vals;
    push( @vals, $lowestTick );

    # Loop until upper from the starting point
    my $lastTick = $lowestTick;
    while ( $range->upper - $tickSize > $lastTick ) {
        $lastTick = $lastTick + $tickSize;

        push( @vals, $lastTick );
    }

    # If the upper value is nearby to the last tick above it
    # (gap at end of graph would be low) then use that as the
    # ending value; otherwise use the tick value immediately before
    # the upper value.
    my $potentialUpperTick = $lastTick + $tickSize;
    if ( $potentialUpperTick - $range->upper < $self->tick_slop * $tickSize ) {
        $range->upper($potentialUpperTick);
        push( @vals, $potentialUpperTick );
    }

    return \@vals;
}

no Moose;
1;

__END__

=pod

=head1 NAME

Chart::Clicker::Axis::DivisionType::LinearRounded

=head1 VERSION

version 2.90

=head1 SYNOPSIS

  use Chart::Clicker::Axis;

  my $axis = Chart::Clicker::Axis->new({
    tick_division_type  => 'LinearRounded'
  });

=head1 DESCRIPTION

Role describing how to divide data for Chart::Clicker::Axis.

=head1 NAME

Chart::Clicker::Axis::DivisionType::LinearRounded - Nicely rounded segments on a linear scale.

=head1 ATTRIBUTES

=head2 tick_slop

This setting determines whether to add a tick outside of the data. If the tick would be
within the percentage of a ticks size specified here as a decimal (10% would be 0.1), then
the tick will be added expanding the graph.

=head1 METHODS

=head2 best_tick_size

The tick division considered best for the approximate number of ticks requested
and data within the range.

=head2 divvy

Divides the range up into nicely rounded chunks for L<Chart::Clicker::Axis>.

=head1 AUTHOR

Rod Taylor <chartclicker@rbt.ca>

=head1 SEE ALSO

perl(1)

=head1 LICENSE

You can redistribute and/or modify this code under the same terms as Perl
itself.

=head1 AUTHOR

Cory G Watson <gphat@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Cory G Watson.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.788 second using v1.01-cache-2.11-cpan-39bf76dae61 )