| 1 | package Chart::Plotly::Trace::Parcoords; | ||
| 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::Parcoords::Dimension; | ||
| 10 | use Chart::Plotly::Trace::Parcoords::Domain; | ||
| 11 | use Chart::Plotly::Trace::Parcoords::Labelfont; | ||
| 12 | use Chart::Plotly::Trace::Parcoords::Legendgrouptitle; | ||
| 13 | use Chart::Plotly::Trace::Parcoords::Line; | ||
| 14 | use Chart::Plotly::Trace::Parcoords::Rangefont; | ||
| 15 | use Chart::Plotly::Trace::Parcoords::Stream; | ||
| 16 | use Chart::Plotly::Trace::Parcoords::Tickfont; | ||
| 17 | use Chart::Plotly::Trace::Parcoords::Transform; | ||
| 18 | use Chart::Plotly::Trace::Parcoords::Unselected; | ||
| 19 | |||
| 20 | our $VERSION = '0.042'; # VERSION | ||
| 21 | |||
| 22 | # ABSTRACT: Parallel coordinates for multidimensional exploratory data analysis. The samples are specified in `dimensions`. The colors are set in `line.color`. | ||
| 23 | |||
| 24 | sub TO_JSON { | ||
| 25 | my $self = shift; | ||
| 26 | my $extra_args = $self->extra_args // {}; | ||
| 27 | my $meta = $self->meta; | ||
| 28 | my %hash = %$self; | ||
| 29 | for my $name ( sort keys %hash ) { | ||
| 30 | my $attr = $meta->get_attribute($name); | ||
| 31 | if ( defined $attr ) { | ||
| 32 | my $value = $hash{$name}; | ||
| 33 | my $type = $attr->type_constraint; | ||
| 34 | if ( $type && $type->equals('Bool') ) { | ||
| 35 | $hash{$name} = $value ? \1 : \0; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | my $plotly_meta = delete $hash{'pmeta'}; | ||
| 40 | if ( defined $plotly_meta ) { | ||
| 41 | $hash{'meta'} = $plotly_meta; | ||
| 42 | } | ||
| 43 | %hash = ( %hash, %$extra_args ); | ||
| 44 | delete $hash{'extra_args'}; | ||
| 45 | if ( $self->can('type') && ( !defined $hash{'type'} ) ) { | ||
| 46 | $hash{type} = $self->type(); | ||
| 47 | } | ||
| 48 | return \%hash; | ||
| 49 | } | ||
| 50 | |||
| 51 | sub type { | ||
| 52 | my @components = split( /::/, __PACKAGE__ ); | ||
| 53 | return lc( $components[-1] ); | ||
| 54 | } | ||
| 55 | |||
| 56 | has customdata => ( | ||
| 57 | is => "rw", | ||
| 58 | isa => "ArrayRef|PDL", | ||
| 59 | documentation => | ||
| 60 | "Assigns extra data each datum. This may be useful when listening to hover, click and selection events. Note that, *scatter* traces also appends customdata items in the markers DOM elements", | ||
| 61 | ); | ||
| 62 | |||
| 63 | has customdatasrc => ( is => "rw", | ||
| 64 | isa => "Str", | ||
| 65 | documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.", | ||
| 66 | ); | ||
| 67 | |||
| 68 | has dimensions => ( is => "rw", | ||
| 69 | isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Parcoords::Dimension]", ); | ||
| 70 | |||
| 71 | has domain => ( is => "rw", | ||
| 72 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Domain", ); | ||
| 73 | |||
| 74 | has ids => ( | ||
| 75 | is => "rw", | ||
| 76 | isa => "ArrayRef|PDL", | ||
| 77 | documentation => | ||
| 78 | "Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type.", | ||
| 79 | ); | ||
| 80 | |||
| 81 | has idssrc => ( is => "rw", | ||
| 82 | isa => "Str", | ||
| 83 | documentation => "Sets the source reference on Chart Studio Cloud for `ids`.", | ||
| 84 | ); | ||
| 85 | |||
| 86 | has labelangle => ( | ||
| 87 | is => "rw", | ||
| 88 | documentation => | ||
| 89 | "Sets the angle of the labels with respect to the horizontal. For example, a `tickangle` of -90 draws the labels vertically. Tilted labels with *labelangle* may be positioned better inside margins when `labelposition` is set to *bottom*.", | ||
| 90 | ); | ||
| 91 | |||
| 92 | has labelfont => ( is => "rw", | ||
| 93 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Labelfont", ); | ||
| 94 | |||
| 95 | has labelside => ( | ||
| 96 | is => "rw", | ||
| 97 | isa => enum( [ "top", "bottom" ] ), | ||
| 98 | documentation => | ||
| 99 | "Specifies the location of the `label`. *top* positions labels above, next to the title *bottom* positions labels below the graph Tilted labels with *labelangle* may be positioned better inside margins when `labelposition` is set to *bottom*.", | ||
| 100 | ); | ||
| 101 | |||
| 102 | has legendgrouptitle => ( is => "rw", | ||
| 103 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Legendgrouptitle", ); | ||
| 104 | |||
| 105 | has legendrank => ( | ||
| 106 | is => "rw", | ||
| 107 | isa => "Num", | ||
| 108 | documentation => | ||
| 109 | "Sets the legend rank for this trace. Items and groups with smaller ranks are presented on top/left side while with `*reversed* `legend.traceorder` they are on bottom/right side. The default legendrank is 1000, so that you can use ranks less than 1000 to place certain items before all unranked items, and ranks greater than 1000 to go after all unranked items.", | ||
| 110 | ); | ||
| 111 | |||
| 112 | has line => ( is => "rw", | ||
| 113 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Line", ); | ||
| 114 | |||
| 115 | has pmeta => ( | ||
| 116 | is => "rw", | ||
| 117 | isa => "Any|ArrayRef[Any]", | ||
| 118 | documentation => | ||
| 119 | "Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace `name`, graph, axis and colorbar `title.text`, annotation `text` `rangeselector`, `updatemenues` and `sliders` `label` text all support `meta`. To access the trace `meta` values in an attribute in the same trace, simply use `%{meta[i]}` where `i` is the index or key of the `meta` item in question. To access trace `meta` in layout attributes, use `%{data[n[.meta[i]}` where `i` is the index or key of the `meta` and `n` is the trace index.", | ||
| 120 | ); | ||
| 121 | |||
| 122 | has metasrc => ( is => "rw", | ||
| 123 | isa => "Str", | ||
| 124 | documentation => "Sets the source reference on Chart Studio Cloud for `meta`.", | ||
| 125 | ); | ||
| 126 | |||
| 127 | has name => ( is => "rw", | ||
| 128 | isa => "Str", | ||
| 129 | documentation => "Sets the trace name. The trace name appear as the legend item and on hover.", | ||
| 130 | ); | ||
| 131 | |||
| 132 | has rangefont => ( is => "rw", | ||
| 133 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Rangefont", ); | ||
| 134 | |||
| 135 | has stream => ( is => "rw", | ||
| 136 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Stream", ); | ||
| 137 | |||
| 138 | has tickfont => ( is => "rw", | ||
| 139 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Tickfont", ); | ||
| 140 | |||
| 141 | has transforms => ( is => "rw", | ||
| 142 | isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Parcoords::Transform]", ); | ||
| 143 | |||
| 144 | has uid => ( | ||
| 145 | is => "rw", | ||
| 146 | isa => "Str", | ||
| 147 | documentation => | ||
| 148 | "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.", | ||
| 149 | ); | ||
| 150 | |||
| 151 | has uirevision => ( | ||
| 152 | is => "rw", | ||
| 153 | isa => "Any", | ||
| 154 | documentation => | ||
| 155 | "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves.", | ||
| 156 | ); | ||
| 157 | |||
| 158 | has unselected => ( is => "rw", | ||
| 159 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Parcoords::Unselected", ); | ||
| 160 | |||
| 161 | has visible => ( | ||
| 162 | is => "rw", | ||
| 163 | documentation => | ||
| 164 | "Determines whether or not this trace is visible. If *legendonly*, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).", | ||
| 165 | ); | ||
| 166 | |||
| 167 | __PACKAGE__->meta->make_immutable(); | ||
| 168 | 1; | ||
| 169 | |||
| 170 | __END__ |