| 1 | package Chart::GGPlot::Position::Dodge; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Position for 'dodge' | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Chart::GGPlot::Class; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 6 | our $VERSION = '0.002003'; # VERSION | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use List::AllUtils qw(count_by); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use Types::Standard qw(Enum); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Chart::GGPlot::Position::Util qw(collide pos_dodge); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | my $PreserveEnum = Enum [qw(total single)]; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 6 | has width => ( is => 'ro' ); | |||||||||||||||||||||||||||
| 19 | 6 | has preserve => ( is => 'ro', isa => $PreserveEnum, default => 'total' ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 6 | with qw(Chart::GGPlot::Position); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | method setup_data ($data, $params) { | ||||||||||||||||||||||||||
|
Subroutine
setup_data: not called CC=5 SCAR=34.0
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ( not $data->exists('x') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $data->exists("x") and &List::AllUtils::all(sub {
$data->exists($_);
}
, "xmin", "xmax")
MC/DC0%0/2
not $data->exists("x") and &List::AllUtils::all(sub {
$data->exists($_);
}
, "xmin", "xmax")
not $data->exists("x")
&List::AllUtils::all(sub {
$data->exists($_);
}
, "xmin", "xmax")
Truth table0%0/3
not(A) and B
A= not $data->exists("x")B= &List::AllUtils::all(sub {
$data->exists($_);
}
, "xmin", "xmax")
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | and List::AllUtils::all { $data->exists($_) } qw(xmin xmax) ) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||
| 27 | 0 | $data->set( 'x', ( $data->at('xmin') + $data->at('xmax') ) / 2 ); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 0 | return $data; | |||||||||||||||||||||||||||
| 30 | 6 | } | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | method setup_params ($data) { | ||||||||||||||||||||||||||
|
Subroutine
setup_params: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 33 | 0 | my $splitted = $data->split( $data->at('PANEL') ); | |||||||||||||||||||||||||||
| 34 | 0 | my $n; | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ( $self->preserve ne 'total' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | $n = List::AllUtils::max( | ||||||||||||||||||||||||||||
| 37 | $splitted->values->map( | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my %count = count_by { $_ } $_->at('xmin')->flatten; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 40 | 0 | return List::AllUtils::max( values(%count), 1 ); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | )->flatten | |||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return { width => $self->width, n => $n }; | |||||||||||||||||||||||||||
| 47 | 6 | } | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | method compute_panel ($data, $params, $scales) { | ||||||||||||||||||||||||||
|
Subroutine
compute_panel: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 50 | return collide( | ||||||||||||||||||||||||||||
| 51 | $data, $params->{width}, 'position_dodge', \&pos_dodge, | ||||||||||||||||||||||||||||
| 52 | n => $params->{n}, | ||||||||||||||||||||||||||||
| 53 | 0 | check_width => false | |||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | 6 | } | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 6 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||