Chart-GGPlot

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "PDL::Graphics::ColorSpace" : "0.203",
            "PDL::Lite" : "0",
            "PDL::Math" : "0",
            "PDL::MatrixOps" : "0",
            "PDL::Primitive" : "0",
            "PDL::SV" : "0",
            "PDL::Ufunc" : "0",
            "POSIX" : "0",
            "Package::Stash" : "0",
            "PerlX::Maybe" : "0",
            "Ref::Util" : "0",
            "Role::Tiny" : "0",
            "Safe::Isa" : "1.000010",
            "Scalar::Util" : "0",
            "Storable" : "0",
            "String::Util" : "0",
            "Time::Moment" : "0",
            "Type::Library" : "0",
            "Type::Params" : "0",
            "Type::Utils" : "0",
            "Types::PDL" : "0",

META.yml  view on Meta::CPAN

  PDL::Graphics::ColorSpace: '0.203'
  PDL::Lite: '0'
  PDL::Math: '0'
  PDL::MatrixOps: '0'
  PDL::Primitive: '0'
  PDL::SV: '0'
  PDL::Ufunc: '0'
  POSIX: '0'
  Package::Stash: '0'
  PerlX::Maybe: '0'
  Ref::Util: '0'
  Role::Tiny: '0'
  Safe::Isa: '1.000010'
  Scalar::Util: '0'
  Storable: '0'
  String::Util: '0'
  Time::Moment: '0'
  Type::Library: '0'
  Type::Params: '0'
  Type::Utils: '0'
  Types::PDL: '0'

Makefile.PL  view on Meta::CPAN

    "PDL::Graphics::ColorSpace" => "0.203",
    "PDL::Lite" => 0,
    "PDL::Math" => 0,
    "PDL::MatrixOps" => 0,
    "PDL::Primitive" => 0,
    "PDL::SV" => 0,
    "PDL::Ufunc" => 0,
    "POSIX" => 0,
    "Package::Stash" => 0,
    "PerlX::Maybe" => 0,
    "Ref::Util" => 0,
    "Role::Tiny" => 0,
    "Safe::Isa" => "1.000010",
    "Scalar::Util" => 0,
    "Storable" => 0,
    "String::Util" => 0,
    "Time::Moment" => 0,
    "Type::Library" => 0,
    "Type::Params" => 0,
    "Type::Utils" => 0,
    "Types::PDL" => 0,

Makefile.PL  view on Meta::CPAN

  "PDL::Graphics::ColorSpace" => "0.203",
  "PDL::Lite" => 0,
  "PDL::Math" => 0,
  "PDL::MatrixOps" => 0,
  "PDL::Primitive" => 0,
  "PDL::SV" => 0,
  "PDL::Ufunc" => 0,
  "POSIX" => 0,
  "Package::Stash" => 0,
  "PerlX::Maybe" => 0,
  "Ref::Util" => 0,
  "Role::Tiny" => 0,
  "Safe::Isa" => "1.000010",
  "Scalar::Util" => 0,
  "Storable" => 0,
  "String::Util" => 0,
  "Test2::Tools::DataFrame" => 0,
  "Test2::Tools::PDL" => "0.0004",
  "Test2::V0" => 0,
  "Time::Moment" => 0,
  "Type::Library" => 0,

cpanfile  view on Meta::CPAN

requires "PDL::Graphics::ColorSpace" => "0.203";
requires "PDL::Lite" => "0";
requires "PDL::Math" => "0";
requires "PDL::MatrixOps" => "0";
requires "PDL::Primitive" => "0";
requires "PDL::SV" => "0";
requires "PDL::Ufunc" => "0";
requires "POSIX" => "0";
requires "Package::Stash" => "0";
requires "PerlX::Maybe" => "0";
requires "Ref::Util" => "0";
requires "Role::Tiny" => "0";
requires "Safe::Isa" => "1.000010";
requires "Scalar::Util" => "0";
requires "Storable" => "0";
requires "String::Util" => "0";
requires "Time::Moment" => "0";
requires "Type::Library" => "0";
requires "Type::Params" => "0";
requires "Type::Utils" => "0";
requires "Types::PDL" => "0";

lib/Chart/GGPlot/Geom/Boxplot.pm  view on Meta::CPAN

        :$stat='boxplot', :$position='dodge2',
        :$outlier_color=undef, :$outlier_colour=undef,
        :$outlier_fill=undef, :$outlier_shape=undef,
        :$outlier_size=1.5, :$outlier_stroke=undef,
        :$outlier_alpha=undef,
        :$notch=false, :$notchwidth=0.25,
        :$varwidth=false, :$na_rm=false,
        :$show_legend=undef, :$inherit_aes=true,
        %rest )
{
    if ( not Ref::Util::is_ref($position) ) {
        if ($varwidth) {
            $position = position_dodge2( preserve => 'single' );
        }
    }
    else {
        if ( $position->preserve eq 'total' and $varwidth ) {
            warn "Can't preserve total widths when varwidth is true.";
            $position->preserve('single');
        }
    }

lib/Chart/GGPlot/Labeller.pm  view on Meta::CPAN

use overload
  '&{}'    => sub { $_[0]->func },
  fallback => 1;

has func => ( is => 'ro', isa => CodeRef, required => 1 );

around BUILDARGS( $orig, $class : @rest ) {
    my %params;
    if ( @rest == 1 ) {
        %params =
          Ref::Util::is_plain_coderef( $rest[0] )
          ? ( func => $rest[0] )
          : %{ $rest[0] };
    }
    else {
        %params = @rest;
    }
    return $class->$orig(%params);
}

classmethod _collapse_labels_lines ($labeller_out) {

lib/Chart/GGPlot/Labeller.pm  view on Meta::CPAN

            ? $class->label_value($multi_line)->($labels)
            : $class->label_both( $multi_line, $sep )->($labels)
        );
    };
    return $class->new($f);
}


classmethod _labeller_by_name ($x, $multi_line) {
    state $supported_labeller_names = [qw(value both context)];
    if ( !Ref::Util::is_ref($x) and elem( $x, $supported_labeller_names ) ) {
        my $f = "label_$x";
        return $class->$f($multi_line);
    }
    else {
        return $x;
    }
}

classmethod as_labeller ($x, $default='value', $multi_line=true) {
    $x       = $class->_labeller_by_name( $x,       $multi_line );
    $default = $class->_labeller_by_name( $default, $multi_line );

    if ( $x->$_isa($class) ) {
        return $x->func;
    }
    elsif ( Ref::Util::is_plain_coderef($x) ) {
        my $f = fun( DataFrame $labels) {
            return $default->( $labels->apply($x) );
        };
        return $class->new( func => $f );
    }
    else {
        return $default;
    }
}

lib/Chart/GGPlot/Layer.pm  view on Meta::CPAN

                    :$params = { na_rm => false },
                    :$inherit_aes = true, :$check_aes = true,
                    :$check_param = true, :$show_legend = NA
  ) {
    $mapping //= Chart::GGPlot::Aes->new();
    unless ( defined $params->at("na_rm") ) {
        $params->set( "na_rm", "nan" );
    }

    my $find_subclass = fun( $super, $x ) {
        unless ( Ref::Util::is_ref($x) ) {  # $x is a class name
            my $subclass = $class->_find_subclass( $super, $x );
            load $subclass;
            return $subclass->new();
        }
        return $x;
    };
    $geom     = $find_subclass->( 'Geom',     $geom );
    $stat     = $find_subclass->( 'Stat',     $stat );
    $position = $find_subclass->( 'Position', $position );

lib/Chart/GGPlot/Params.pm  view on Meta::CPAN

method defaults ($other) {
    return $self->clone unless defined $other;
    return $other->merge( $self, true );
}


method rename ($href_or_coderef) {
    my $class = ref($self);

    my $new_hash;
    if ( Ref::Util::is_coderef($href_or_coderef) ) {
        my $f = sub { $href_or_coderef->( $self->transform_key( $_[0] ) ) };
        $new_hash = $self->_hash->rename($f);
    }
    else {
        my $mapping = {
            pairmap { $self->transform_key($a) => $self->transform_key($b) }
            $href_or_coderef->flatten
        };
        $new_hash = $self->_hash->rename($mapping);
    }

lib/Chart/GGPlot/Scale/Continuous.pm  view on Meta::CPAN

    return pdl( [] ) if ( zero_range($limits) );
    return null if ( $self->minor_breaks->$_call_if_object('isempty') );

    my $breaks;
    if ( not defined $self->minor_breaks ) {
        $breaks =
          $b->isempty
          ? null
          : $self->trans->minor_breaks->( $b, $limits, $n );
    }
    elsif ( Ref::Util::is_coderef( $self->minor_breaks ) ) {

        # Find breaks in data space, and convert to numeric
        $breaks = $self->minor_breaks->( $self->trans->inverse->($limits) );
        $breaks = $self->trans->transform->($breaks);
    }
    else {
        $breaks = $self->trans->transform->( $self->minor_breaks );
    }

    # Any minor breaks outside the dimensions need to be thrown away

lib/Chart/GGPlot/Scale/Discrete.pm  view on Meta::CPAN


method get_labels ( $breaks = $self->get_breaks ) {
    return pdl( [] ) if $self->isempty;

    return null if $breaks->$_call_if_object('isempty');
    return null if $self->labels->$_call_if_object('isempty');

    if ( not defined $self->labels ) {
        return $self->get_breaks();
    }
    elsif ( Ref::Util::is_coderef( $self->labels ) ) {
        return $self->labels->($breaks);
    }
    else {
        if ( not $self->labels->names->isempty ) {

            # If labels have names, use them to match with breaks
            my $labels   = $breaks;
            my $match_id = which( match( $self->labels->names, $labels ) > 0 );
            $labels->slice($match_id) .= $self->labels->slice($match_id);
            return $labels;

lib/Chart/GGPlot/Theme/ElementTree.pm  view on Meta::CPAN

use Chart::GGPlot::Theme::ElementTree;

# Overrides Chart::GGPlot::Params behavior to support both "foo.bar" and
# "foo_bar" as element name.
classmethod transform_key ($key) {
    return ( $key =~ s/\./_/gr );
}


classmethod el_def ( $type, $inherit = [], $desc = '' ) {
    $inherit = Ref::Util::is_arrayref($inherit) ? $inherit : [ $inherit // () ];
    return {
        type        => $type,
        inherit     => $inherit,
        description => $desc,
    };
}


classmethod default_element_tree () {
    my $ElementLine = InstanceOf ["Chart::GGPlot::Theme::Element::Line"];

lib/Chart/GGPlot/Types.pm  view on Meta::CPAN

package Chart::GGPlot::Types;

# ABSTRACT: Custom types and coercions

use Chart::GGPlot::Setup qw(:base :pdl); 

our $VERSION = '0.002003'; # VERSION

use Ref::Util qw(is_plain_arrayref);
use Type::Library -base, -declare => qw(
  GGParams AesMapping
  ColorBrewerTypeEnum PositionEnum
  Theme Margin Labeller
  Coord Facet Scale
  HJust VJust
);

use Type::Utils -all;
use Types::Standard -types;

lib/Chart/GGPlot/Util.pm  view on Meta::CPAN

        }
        return $df->select_rows( which( !$missing ) );
    }
    else {
        return $df;
    }
}


fun call_if_coderef ($x, @args) {
    return ( Ref::Util::is_coderef($x) ? $x->(@args) : $x );
}

fun clist ($hash_like) {
    unless ( Ref::Util::is_plain_hashref($hash_like) ) {
        $hash_like = { map { $_ => $hash_like->at($_) } @{ $hash_like->keys } };
    }
    return Data::Dumper::Concise::Dumper($hash_like);
}


fun alias_color_functions ($package, @function_names) {
    return map {
        if ( $_ =~ /color/ ) {
            my $alias_name = $_ =~ s/color/colour/gr;

t/11-aes.t  view on Meta::CPAN

#!perl

use Chart::GGPlot::Setup;

use List::AllUtils qw(pairmap);
use Ref::Util qw(is_arrayref);

use Test2::V0;

use Chart::GGPlot::Aes;
use Chart::GGPlot::Aes::Functions qw(:all);

sub aes_quosure_to_hashref {
    my ($aes) = @_;
    return { pairmap { $a => $b->expr } $aes->flatten };
}



( run in 0.396 second using v1.01-cache-2.11-cpan-4d50c553e7e )