Chart/Plotly/Trace/Indicator.pm untested

filter: Statementstmt 0.0% 0 / 83 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 123 CC 6 SCAR 27.3
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 15.3
1 package Chart::Plotly::Trace::Indicator;
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::Indicator::Delta;
10 use Chart::Plotly::Trace::Indicator::Domain;
11 use Chart::Plotly::Trace::Indicator::Gauge;
12 use Chart::Plotly::Trace::Indicator::Legendgrouptitle;
13 use Chart::Plotly::Trace::Indicator::Number;
14 use Chart::Plotly::Trace::Indicator::Stream;
15 use Chart::Plotly::Trace::Indicator::Title;
16 use Chart::Plotly::Trace::Indicator::Transform;
17  
18 our $VERSION = '0.042'; # VERSION
19  
20 # ABSTRACT: An indicator is used to visualize a single `value` along with some contextual information such as `steps` or a `threshold`, using a combination of three visual elements: a number, a delta, and/or a gauge. Deltas are taken with respect to a `reference`. Gauges can be either angular or bullet (aka linear) gauges.
21  
22 sub TO_JSON {
23 my $self = shift;
24 my $extra_args = $self->extra_args // {};
25 my $meta = $self->meta;
26 my %hash = %$self;
27 for my $name ( sort keys %hash ) {
28 my $attr = $meta->get_attribute($name);
29 if ( defined $attr ) {
30 my $value = $hash{$name};
31 my $type = $attr->type_constraint;
32 if ( $type && $type->equals('Bool') ) {
33 $hash{$name} = $value ? \1 : \0;
34 }
35 }
36 }
37 my $plotly_meta = delete $hash{'pmeta'};
38 if ( defined $plotly_meta ) {
39 $hash{'meta'} = $plotly_meta;
40 }
41 %hash = ( %hash, %$extra_args );
42 delete $hash{'extra_args'};
43 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
44 $hash{type} = $self->type();
45 }
46 return \%hash;
47 }
48  
49 sub type {
50 my @components = split( /::/, __PACKAGE__ );
51 return lc( $components[-1] );
52 }
53  
54 has align => (
55 is => "rw",
56 isa => enum( [ "left", "center", "right" ] ),
57 documentation =>
58 "Sets the horizontal alignment of the `text` within the box. Note that this attribute has no effect if an angular gauge is displayed: in this case, it is always centered",
59 );
60  
61 has customdata => (
62 is => "rw",
63 isa => "ArrayRef|PDL",
64 documentation =>
65 "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",
66 );
67  
68 has customdatasrc => ( is => "rw",
69 isa => "Str",
70 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
71 );
72  
73 has delta => ( is => "rw",
74 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Delta", );
75  
76 has domain => ( is => "rw",
77 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Domain", );
78  
79 has gauge => ( is => "rw",
80 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Gauge", );
81  
82 has ids => (
83 is => "rw",
84 isa => "ArrayRef|PDL",
85 documentation =>
86 "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.",
87 );
88  
89 has idssrc => ( is => "rw",
90 isa => "Str",
91 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
92 );
93  
94 has legendgrouptitle => ( is => "rw",
95 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Legendgrouptitle", );
96  
97 has legendrank => (
98 is => "rw",
99 isa => "Num",
100 documentation =>
101 "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.",
102 );
103  
104 has pmeta => (
105 is => "rw",
106 isa => "Any|ArrayRef[Any]",
107 documentation =>
108 "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.",
109 );
110  
111 has metasrc => ( is => "rw",
112 isa => "Str",
113 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
114 );
115  
116 has mode => (
117 is => "rw",
118 isa => "Str",
119 documentation =>
120 "Determines how the value is displayed on the graph. `number` displays the value numerically in text. `delta` displays the difference to a reference value in text. Finally, `gauge` displays the value graphically on an axis.",
121 );
122  
123 has name => ( is => "rw",
124 isa => "Str",
125 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
126 );
127  
128 has number => ( is => "rw",
129 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Number", );
130  
131 has stream => ( is => "rw",
132 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Stream", );
133  
134 has title => ( is => "rw",
135 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Indicator::Title", );
136  
137 has transforms => ( is => "rw",
138 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Indicator::Transform]", );
139  
140 has uid => (
141 is => "rw",
142 isa => "Str",
143 documentation =>
144 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
145 );
146  
147 has uirevision => (
148 is => "rw",
149 isa => "Any",
150 documentation =>
151 "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.",
152 );
153  
154 has value => ( is => "rw",
155 isa => "Num",
156 documentation => "Sets the number to be displayed.",
157 );
158  
159 has visible => (
160 is => "rw",
161 documentation =>
162 "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).",
163 );
164  
165 __PACKAGE__->meta->make_immutable();
166 1;
167  
168 __END__