| 1 | package Chart::Plotly::Trace::Parcats::Dimension; | ||
| 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 | our $VERSION = '0.042'; # VERSION | ||
| 10 | |||
| 11 | # ABSTRACT: This attribute is one of the possible options for the trace parcats. | ||
| 12 | |||
| 13 | sub TO_JSON { | ||
| 14 | my $self = shift; | ||
| 15 | my $extra_args = $self->extra_args // {}; | ||
| 16 | my $meta = $self->meta; | ||
| 17 | my %hash = %$self; | ||
| 18 | for my $name ( sort keys %hash ) { | ||
| 19 | my $attr = $meta->get_attribute($name); | ||
| 20 | if ( defined $attr ) { | ||
| 21 | my $value = $hash{$name}; | ||
| 22 | my $type = $attr->type_constraint; | ||
| 23 | if ( $type && $type->equals('Bool') ) { | ||
| 24 | $hash{$name} = $value ? \1 : \0; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
| 28 | %hash = ( %hash, %$extra_args ); | ||
| 29 | delete $hash{'extra_args'}; | ||
| 30 | if ( $self->can('type') && ( !defined $hash{'type'} ) ) { | ||
| 31 | $hash{type} = $self->type(); | ||
| 32 | } | ||
| 33 | return \%hash; | ||
| 34 | } | ||
| 35 | |||
| 36 | has categoryarray => ( | ||
| 37 | is => "rw", | ||
| 38 | isa => "ArrayRef|PDL", | ||
| 39 | documentation => | ||
| 40 | "Sets the order in which categories in this dimension appear. Only has an effect if `categoryorder` is set to *array*. Used with `categoryorder`.", | ||
| 41 | ); | ||
| 42 | |||
| 43 | has categoryarraysrc => ( is => "rw", | ||
| 44 | isa => "Str", | ||
| 45 | documentation => "Sets the source reference on Chart Studio Cloud for `categoryarray`.", | ||
| 46 | ); | ||
| 47 | |||
| 48 | has categoryorder => ( | ||
| 49 | is => "rw", | ||
| 50 | isa => enum( [ "trace", "category ascending", "category descending", "array" ] ), | ||
| 51 | documentation => | ||
| 52 | "Specifies the ordering logic for the categories in the dimension. By default, plotly uses *trace*, which specifies the order that is present in the data supplied. Set `categoryorder` to *category ascending* or *category descending* if order should be determined by the alphanumerical order of the category names. Set `categoryorder` to *array* to derive the ordering from the attribute `categoryarray`. If a category is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to the *trace* mode. The unspecified categories will follow the categories in `categoryarray`.", | ||
| 53 | ); | ||
| 54 | |||
| 55 | has description => ( is => "ro", | ||
| 56 | default => "The dimensions (variables) of the parallel categories diagram.", ); | ||
| 57 | |||
| 58 | has displayindex => ( | ||
| 59 | is => "rw", | ||
| 60 | isa => "Int", | ||
| 61 | documentation => "The display index of dimension, from left to right, zero indexed, defaults to dimension index.", | ||
| 62 | ); | ||
| 63 | |||
| 64 | has label => ( is => "rw", | ||
| 65 | isa => "Str", | ||
| 66 | documentation => "The shown name of the dimension.", | ||
| 67 | ); | ||
| 68 | |||
| 69 | has ticktext => ( | ||
| 70 | is => "rw", | ||
| 71 | isa => "ArrayRef|PDL", | ||
| 72 | documentation => | ||
| 73 | "Sets alternative tick labels for the categories in this dimension. Only has an effect if `categoryorder` is set to *array*. Should be an array the same length as `categoryarray` Used with `categoryorder`.", | ||
| 74 | ); | ||
| 75 | |||
| 76 | has ticktextsrc => ( is => "rw", | ||
| 77 | isa => "Str", | ||
| 78 | documentation => "Sets the source reference on Chart Studio Cloud for `ticktext`.", | ||
| 79 | ); | ||
| 80 | |||
| 81 | has values => ( | ||
| 82 | is => "rw", | ||
| 83 | isa => "ArrayRef|PDL", | ||
| 84 | documentation => | ||
| 85 | "Dimension values. `values[n]` represents the category value of the `n`th point in the dataset, therefore the `values` vector for all dimensions must be the same (longer vectors will be truncated).", | ||
| 86 | ); | ||
| 87 | |||
| 88 | has valuessrc => ( is => "rw", | ||
| 89 | isa => "Str", | ||
| 90 | documentation => "Sets the source reference on Chart Studio Cloud for `values`.", | ||
| 91 | ); | ||
| 92 | |||
| 93 | has visible => ( | ||
| 94 | is => "rw", | ||
| 95 | isa => "Bool", | ||
| 96 | documentation => "Shows the dimension when set to `true` (the default). Hides the dimension for `false`.", | ||
| 97 | ); | ||
| 98 | |||
| 99 | __PACKAGE__->meta->make_immutable(); | ||
| 100 | 1; | ||
| 101 | |||
| 102 | __END__ |