| 1 | package Chart::Plotly::Trace::Violin::Marker; | ||
| 2 | use Moose; | ||
| 3 | use MooseX::ExtraArgs; | ||
| 4 | use Moose::Util::TypeConstraints qw(enum union); | ||
| 5 | if ( !defined Moose::Util::TypeConstraints::find_type_constraint('PDL') ) { | ||
| 6 | Moose::Util::TypeConstraints::type('PDL'); | ||
| 7 | } | ||
| 8 | |||
| 9 | use Chart::Plotly::Trace::Violin::Marker::Line; | ||
| 10 | |||
| 11 | our $VERSION = '0.042'; # VERSION | ||
| 12 | |||
| 13 | # ABSTRACT: This attribute is one of the possible options for the trace violin. | ||
| 14 | |||
| 15 | sub TO_JSON { | ||
| 16 | my $self = shift; | ||
| 17 | my $extra_args = $self->extra_args // {}; | ||
| 18 | my $meta = $self->meta; | ||
| 19 | my %hash = %$self; | ||
| 20 | for my $name ( sort keys %hash ) { | ||
| 21 | my $attr = $meta->get_attribute($name); | ||
| 22 | if ( defined $attr ) { | ||
| 23 | my $value = $hash{$name}; | ||
| 24 | my $type = $attr->type_constraint; | ||
| 25 | if ( $type && $type->equals('Bool') ) { | ||
| 26 | $hash{$name} = $value ? \1 : \0; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | ||
| 30 | %hash = ( %hash, %$extra_args ); | ||
| 31 | delete $hash{'extra_args'}; | ||
| 32 | if ( $self->can('type') && ( !defined $hash{'type'} ) ) { | ||
| 33 | $hash{type} = $self->type(); | ||
| 34 | } | ||
| 35 | return \%hash; | ||
| 36 | } | ||
| 37 | |||
| 38 | has color => ( | ||
| 39 | is => "rw", | ||
| 40 | isa => "Str", | ||
| 41 | documentation => | ||
| 42 | "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `marker.cmin` and `marker.cmax` if set.", | ||
| 43 | ); | ||
| 44 | |||
| 45 | has line => ( is => "rw", | ||
| 46 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Marker::Line", ); | ||
| 47 | |||
| 48 | has opacity => ( is => "rw", | ||
| 49 | isa => "Num", | ||
| 50 | documentation => "Sets the marker opacity.", | ||
| 51 | ); | ||
| 52 | |||
| 53 | has outliercolor => ( is => "rw", | ||
| 54 | isa => "Str", | ||
| 55 | documentation => "Sets the color of the outlier sample points.", | ||
| 56 | ); | ||
| 57 | |||
| 58 | has size => ( is => "rw", | ||
| 59 | isa => "Num", | ||
| 60 | documentation => "Sets the marker size (in px).", | ||
| 61 | ); | ||
| 62 | |||
| 63 | has symbol => ( | ||
| 64 | is => "rw", | ||
| 65 | documentation => | ||
| 66 | "Sets the marker symbol type. Adding 100 is equivalent to appending *-open* to a symbol name. Adding 200 is equivalent to appending *-dot* to a symbol name. Adding 300 is equivalent to appending *-open-dot* or *dot-open* to a symbol name.", | ||
| 67 | ); | ||
| 68 | |||
| 69 | __PACKAGE__->meta->make_immutable(); | ||
| 70 | 1; | ||
| 71 | |||
| 72 | __END__ |