« Chart/Plotly/Trace/Parcoords/Line/Colorbar.pm
↑ Summary
Chart/Plotly/Trace/Scatter3d/Line/Colorbar.pm »
| 1 | package Chart::Plotly::Trace::Sankey::Link; | ||
| 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::Sankey::Link::Concentrationscales; | ||
| 10 | use Chart::Plotly::Trace::Sankey::Link::Hoverlabel; | ||
| 11 | use Chart::Plotly::Trace::Sankey::Link::Line; | ||
| 12 | |||
| 13 | our $VERSION = '0.042'; # VERSION | ||
| 14 | |||
| 15 | # ABSTRACT: This attribute is one of the possible options for the trace sankey. | ||
| 16 | |||
| 17 | sub TO_JSON { | ||
| 18 | my $self = shift; | ||
| 19 | my $extra_args = $self->extra_args // {}; | ||
| 20 | my $meta = $self->meta; | ||
| 21 | my %hash = %$self; | ||
| 22 | for my $name ( sort keys %hash ) { | ||
| 23 | my $attr = $meta->get_attribute($name); | ||
| 24 | if ( defined $attr ) { | ||
| 25 | my $value = $hash{$name}; | ||
| 26 | my $type = $attr->type_constraint; | ||
| 27 | if ( $type && $type->equals('Bool') ) { | ||
| 28 | $hash{$name} = $value ? \1 : \0; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | %hash = ( %hash, %$extra_args ); | ||
| 33 | delete $hash{'extra_args'}; | ||
| 34 | if ( $self->can('type') && ( !defined $hash{'type'} ) ) { | ||
| 35 | $hash{type} = $self->type(); | ||
| 36 | } | ||
| 37 | return \%hash; | ||
| 38 | } | ||
| 39 | |||
| 40 | has arrowlen => ( is => "rw", | ||
| 41 | isa => "Num", | ||
| 42 | documentation => "Sets the length (in px) of the links arrow, if 0 no arrow will be drawn.", | ||
| 43 | ); | ||
| 44 | |||
| 45 | has color => ( | ||
| 46 | is => "rw", | ||
| 47 | isa => "Str|ArrayRef[Str]", | ||
| 48 | documentation => | ||
| 49 | "Sets the `link` color. It can be a single value, or an array for specifying color for each `link`. If `link.color` is omitted, then by default, a translucent grey link will be used.", | ||
| 50 | ); | ||
| 51 | |||
| 52 | has colorscales => ( is => "rw", | ||
| 53 | isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Sankey::Link::Concentrationscales]", ); | ||
| 54 | |||
| 55 | has colorsrc => ( is => "rw", | ||
| 56 | isa => "Str", | ||
| 57 | documentation => "Sets the source reference on Chart Studio Cloud for `color`.", | ||
| 58 | ); | ||
| 59 | |||
| 60 | has customdata => ( is => "rw", | ||
| 61 | isa => "ArrayRef|PDL", | ||
| 62 | documentation => "Assigns extra data to each link.", | ||
| 63 | ); | ||
| 64 | |||
| 65 | has customdatasrc => ( is => "rw", | ||
| 66 | isa => "Str", | ||
| 67 | documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.", | ||
| 68 | ); | ||
| 69 | |||
| 70 | has description => ( is => "ro", | ||
| 71 | default => "The links of the Sankey plot.", ); | ||
| 72 | |||
| 73 | has hoverinfo => ( | ||
| 74 | is => "rw", | ||
| 75 | isa => enum( [ "all", "none", "skip" ] ), | ||
| 76 | documentation => | ||
| 77 | "Determines which trace information appear when hovering links. If `none` or `skip` are set, no information is displayed upon hovering. But, if `none` is set, click and hover events are still fired.", | ||
| 78 | ); | ||
| 79 | |||
| 80 | has hoverlabel => ( is => "rw", | ||
| 81 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Sankey::Link::Hoverlabel", ); | ||
| 82 | |||
| 83 | has hovertemplate => ( | ||
| 84 | is => "rw", | ||
| 85 | isa => "Str|ArrayRef[Str]", | ||
| 86 | documentation => | ||
| 87 | "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\" as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:\$.2f}\". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example \"Day: %{2019-01-01|%A}\". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variables `value` and `label`. Anything contained in tag `<extra>` is displayed in the secondary box, for example \"<extra>{fullData.name}</extra>\". To hide the secondary box completely, use an empty tag `<extra></extra>`.", | ||
| 88 | ); | ||
| 89 | |||
| 90 | has hovertemplatesrc => ( is => "rw", | ||
| 91 | isa => "Str", | ||
| 92 | documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.", | ||
| 93 | ); | ||
| 94 | |||
| 95 | has label => ( is => "rw", | ||
| 96 | isa => "ArrayRef|PDL", | ||
| 97 | documentation => "The shown name of the link.", | ||
| 98 | ); | ||
| 99 | |||
| 100 | has labelsrc => ( is => "rw", | ||
| 101 | isa => "Str", | ||
| 102 | documentation => "Sets the source reference on Chart Studio Cloud for `label`.", | ||
| 103 | ); | ||
| 104 | |||
| 105 | has line => ( is => "rw", | ||
| 106 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Sankey::Link::Line", ); | ||
| 107 | |||
| 108 | has source => ( is => "rw", | ||
| 109 | isa => "ArrayRef|PDL", | ||
| 110 | documentation => "An integer number `[0..nodes.length - 1]` that represents the source node.", | ||
| 111 | ); | ||
| 112 | |||
| 113 | has sourcesrc => ( is => "rw", | ||
| 114 | isa => "Str", | ||
| 115 | documentation => "Sets the source reference on Chart Studio Cloud for `source`.", | ||
| 116 | ); | ||
| 117 | |||
| 118 | has target => ( is => "rw", | ||
| 119 | isa => "ArrayRef|PDL", | ||
| 120 | documentation => "An integer number `[0..nodes.length - 1]` that represents the target node.", | ||
| 121 | ); | ||
| 122 | |||
| 123 | has targetsrc => ( is => "rw", | ||
| 124 | isa => "Str", | ||
| 125 | documentation => "Sets the source reference on Chart Studio Cloud for `target`.", | ||
| 126 | ); | ||
| 127 | |||
| 128 | has value => ( is => "rw", | ||
| 129 | isa => "ArrayRef|PDL", | ||
| 130 | documentation => "A numeric value representing the flow volume value.", | ||
| 131 | ); | ||
| 132 | |||
| 133 | has valuesrc => ( is => "rw", | ||
| 134 | isa => "Str", | ||
| 135 | documentation => "Sets the source reference on Chart Studio Cloud for `value`.", | ||
| 136 | ); | ||
| 137 | |||
| 138 | __PACKAGE__->meta->make_immutable(); | ||
| 139 | 1; | ||
| 140 | |||
| 141 | __END__ |