| 1 | package Chart::Plotly::Trace::Table::Cells; | ||
| 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::Table::Cells::Fill; | ||
| 10 | use Chart::Plotly::Trace::Table::Cells::Font; | ||
| 11 | use Chart::Plotly::Trace::Table::Cells::Line; | ||
| 12 | |||
| 13 | our $VERSION = '0.042'; # VERSION | ||
| 14 | |||
| 15 | # ABSTRACT: This attribute is one of the possible options for the trace table. | ||
| 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 align => ( | ||
| 41 | is => "rw", | ||
| 42 | isa => union( [ enum( [ "left", "center", "right" ] ), "ArrayRef" ] ), | ||
| 43 | documentation => | ||
| 44 | "Sets the horizontal alignment of the `text` within the box. Has an effect only if `text` spans two or more lines (i.e. `text` contains one or more <br> HTML tags) or if an explicit width is set to override the text width.", | ||
| 45 | ); | ||
| 46 | |||
| 47 | has alignsrc => ( is => "rw", | ||
| 48 | isa => "Str", | ||
| 49 | documentation => "Sets the source reference on Chart Studio Cloud for `align`.", | ||
| 50 | ); | ||
| 51 | |||
| 52 | has fill => ( is => "rw", | ||
| 53 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Table::Cells::Fill", ); | ||
| 54 | |||
| 55 | has font => ( is => "rw", | ||
| 56 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Table::Cells::Font", ); | ||
| 57 | |||
| 58 | has format => ( | ||
| 59 | is => "rw", | ||
| 60 | isa => "ArrayRef|PDL", | ||
| 61 | documentation => | ||
| 62 | "Sets the cell value formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format.", | ||
| 63 | ); | ||
| 64 | |||
| 65 | has formatsrc => ( is => "rw", | ||
| 66 | isa => "Str", | ||
| 67 | documentation => "Sets the source reference on Chart Studio Cloud for `format`.", | ||
| 68 | ); | ||
| 69 | |||
| 70 | has height => ( is => "rw", | ||
| 71 | isa => "Num", | ||
| 72 | documentation => "The height of cells.", | ||
| 73 | ); | ||
| 74 | |||
| 75 | has line => ( is => "rw", | ||
| 76 | isa => "Maybe[HashRef]|Chart::Plotly::Trace::Table::Cells::Line", ); | ||
| 77 | |||
| 78 | has prefix => ( is => "rw", | ||
| 79 | isa => "Str|ArrayRef[Str]", | ||
| 80 | documentation => "Prefix for cell values.", | ||
| 81 | ); | ||
| 82 | |||
| 83 | has prefixsrc => ( is => "rw", | ||
| 84 | isa => "Str", | ||
| 85 | documentation => "Sets the source reference on Chart Studio Cloud for `prefix`.", | ||
| 86 | ); | ||
| 87 | |||
| 88 | has suffix => ( is => "rw", | ||
| 89 | isa => "Str|ArrayRef[Str]", | ||
| 90 | documentation => "Suffix for cell values.", | ||
| 91 | ); | ||
| 92 | |||
| 93 | has suffixsrc => ( is => "rw", | ||
| 94 | isa => "Str", | ||
| 95 | documentation => "Sets the source reference on Chart Studio Cloud for `suffix`.", | ||
| 96 | ); | ||
| 97 | |||
| 98 | has values => ( | ||
| 99 | is => "rw", | ||
| 100 | isa => "ArrayRef|PDL", | ||
| 101 | documentation => | ||
| 102 | "Cell values. `values[m][n]` represents the value of the `n`th point in column `m`, therefore the `values[m]` vector length for all columns must be the same (longer vectors will be truncated). Each value must be a finite number or a string.", | ||
| 103 | ); | ||
| 104 | |||
| 105 | has valuessrc => ( is => "rw", | ||
| 106 | isa => "Str", | ||
| 107 | documentation => "Sets the source reference on Chart Studio Cloud for `values`.", | ||
| 108 | ); | ||
| 109 | |||
| 110 | __PACKAGE__->meta->make_immutable(); | ||
| 111 | 1; | ||
| 112 | |||
| 113 | __END__ |