| 1 | package Chart::GGPlot::Aes; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ABSTRACT: Aesthetic mappings | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 14 | ▶ | use Chart::GGPlot::Setup; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 14 | ▶ | use Function::Parameters qw(classmethod); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 14 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 14 | our $VERSION = '0.002003'; # VERSION | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 14 | ▶ | use parent qw(Chart::GGPlot::Params); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 14 | ▶ | use List::AllUtils qw(pairmap); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 14 | my @all_aesthetics = ( | |||||||||||||||||||
| 16 | "adj", "alpha", "angle", "bg", | ||||||||||||||||||||
| 17 | "cex", "col", "color", "colour", | ||||||||||||||||||||
| 18 | "fg", "fill", "group", "hjust", | ||||||||||||||||||||
| 19 | "label", "linetype", "lower", "lty", | ||||||||||||||||||||
| 20 | "lwd", "max", "middle", "min", | ||||||||||||||||||||
| 21 | "pch", "radius", "sample", "shape", | ||||||||||||||||||||
| 22 | "size", "srt", "upper", "vjust", | ||||||||||||||||||||
| 23 | "weight", "width", "x", "xend", | ||||||||||||||||||||
| 24 | "xmax", "xmin", "xintercept", "y", | ||||||||||||||||||||
| 25 | "yend", "ymax", "ymin", "yintercept", | ||||||||||||||||||||
| 26 | "z" | ||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 14 | my %base_to_ggplot = ( | |||||||||||||||||||
| 30 | "col" => "color", | ||||||||||||||||||||
| 31 | "colour" => "color", | ||||||||||||||||||||
| 32 | "pch" => "shape", | ||||||||||||||||||||
| 33 | "cex" => "size", | ||||||||||||||||||||
| 34 | "lty" => "linetype", | ||||||||||||||||||||
| 35 | "lwd" => "size", | ||||||||||||||||||||
| 36 | "srt" => "angle", | ||||||||||||||||||||
| 37 | "adj" => "hjust", | ||||||||||||||||||||
| 38 | "bg" => "fill", | ||||||||||||||||||||
| 39 | "fg" => "color", | ||||||||||||||||||||
| 40 | "min" => "ymin", | ||||||||||||||||||||
| 41 | "max" => "ymax" | ||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | # Overrides the same method in Chart::GGPlot::Params. | ||||||||||||||||||||
| 45 | 405 | ▶ | classmethod transform_key ($key) { | ||||||||||||||||||
|
Subroutine
transform_key: called CC=4 SCAR=14.3
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||
| 46 | 405 | ▶ | return ( $base_to_ggplot{$key} // $key ); | ||||||||||||||||||
|
Condition66%2/3
$base_to_ggplot{$key} // $key
MC/DC0%0/2
$base_to_ggplot{$key} // $key
$base_to_ggplot{$key}
$key
Truth table66%2/3
A // B
A= $base_to_ggplot{$key}B= $key
| |||||||||||||||||||||
| 47 | 14 | } | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | ▶ | classmethod all_aesthetics () { \@all_aesthetics; } | ||||||||||||||||||
|
Subroutine
all_aesthetics: called CC=3 SCAR=11.2
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 217 | ▶ | method keys () { [ sort( @{ $self->SUPER::keys() } ) ]; } | ||||||||||||||||||
|
Subroutine
keys: called CC=3 SCAR=11.2
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 12 | ▶ | classmethod check_aesthetics ($aes, $n=undef) { | ||||||||||||||||||
|
Subroutine
check_aesthetics: called CC=6 SCAR=21.3
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||
| 55 | 12 | ▶ | unless ( defined $n ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | $n = List::AllUtils::max( | ||||||||||||||||||||
| 57 | 0 | ▶ | @{ $aes->names->map( sub { $aes->at($_)->length } ) } ); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | my @bad_keys = grep { | ||||||||||||||||||||
| 61 | 14 | my $length = $aes->at($_)->length(); | |||||||||||||||||||
| 62 | 14 | ▶ | !( $length == 1 or $length == $n ) | ||||||||||||||||||
|
Condition33%1/3
$length == 1 || $length == $n
MC/DC0%0/2
$length == 1 || $length == $n
$length == 1
$length == $n
Truth table33%1/3
A || B
A= $length == 1B= $length == $n
| |||||||||||||||||||||
| 63 | 12 | } @{ $aes->names }; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 12 | ▶ | return unless @bad_keys; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | die( | ||||||||||||||||||||
| 68 | sprintf( | ||||||||||||||||||||
| 69 | "Aesthetics must be either length 1 or the same as the data (%s): %s.", | ||||||||||||||||||||
| 70 | 0 | $n, join( ', ', map { qq{"$_"} } @bad_keys ) | |||||||||||||||||||
| 71 | ) | ||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||
| 73 | 14 | } | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 1 | ▶ | method string () { | ||||||||||||||||||
|
Subroutine
string: called CC=3 SCAR=11.3
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||
| 77 | 2 | ▶ | my @assoc = pairmap { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 78 | 2 | ▶ | $a => $b->$_DOES('Eval::Quosure') ? $b->expr : $b; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 79 | 1 | } $self->flatten; | |||||||||||||||||||
| 80 | 1 | ▶ | return join(", ", pairmap { qq{$a => $b} } @assoc); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 81 | 14 | } | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 14 | 1; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||