Chart/Plotly/Trace/Image.pm untested

filter: Statementstmt 0.0% 0 / 82 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 117 CC 6 SCAR 30.2
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 20.5
1 package Chart::Plotly::Trace::Image;
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::Image::Hoverlabel;
10 use Chart::Plotly::Trace::Image::Legendgrouptitle;
11 use Chart::Plotly::Trace::Image::Stream;
12  
13 our $VERSION = '0.042'; # VERSION
14  
15 # ABSTRACT: Display an image, i.e. data on a 2D regular raster. By default, when an image is displayed in a subplot, its y axis will be reversed (ie. `autorange: 'reversed'`), constrained to the domain (ie. `constrain: 'domain'`) and it will have the same scale as its x axis (ie. `scaleanchor: 'x,`) in order for pixels to be rendered as squares.
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 my $plotly_meta = delete $hash{'pmeta'};
33 if ( defined $plotly_meta ) {
34 $hash{'meta'} = $plotly_meta;
35 }
36 %hash = ( %hash, %$extra_args );
37 delete $hash{'extra_args'};
38 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
39 $hash{type} = $self->type();
40 }
41 return \%hash;
42 }
43  
44 sub type {
45 my @components = split( /::/, __PACKAGE__ );
46 return lc( $components[-1] );
47 }
48  
49 has colormodel => (
50 is => "rw",
51 isa => enum( [ "rgb", "rgba", "rgba256", "hsl", "hsla" ] ),
52 documentation =>
53 "Color model used to map the numerical color components described in `z` into colors. If `source` is specified, this attribute will be set to `rgba256` otherwise it defaults to `rgb`.",
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 dx => ( is => "rw",
69 isa => "Num",
70 documentation => "Set the pixel's horizontal size.",
71 );
72  
73 has dy => ( is => "rw",
74 isa => "Num",
75 documentation => "Set the pixel's vertical size",
76 );
77  
78 has hoverinfo => (
79 is => "rw",
80 isa => "Str|ArrayRef[Str]",
81 documentation =>
82 "Determines which trace information appear on hover. If `none` or `skip` are set, no information is displayed upon hovering. But, if `none` is set, click and hover events are still fired.",
83 );
84  
85 has hoverinfosrc => ( is => "rw",
86 isa => "Str",
87 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
88 );
89  
90 has hoverlabel => ( is => "rw",
91 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Image::Hoverlabel", );
92  
93 has hovertemplate => (
94 is => "rw",
95 isa => "Str|ArrayRef[Str]",
96 documentation =>
97 "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 `z`, `color` and `colormodel`. 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>`.",
98 );
99  
100 has hovertemplatesrc => ( is => "rw",
101 isa => "Str",
102 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
103 );
104  
105 has hovertext => ( is => "rw",
106 isa => "ArrayRef|PDL",
107 documentation => "Same as `text`.",
108 );
109  
110 has hovertextsrc => ( is => "rw",
111 isa => "Str",
112 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
113 );
114  
115 has ids => (
116 is => "rw",
117 isa => "ArrayRef|PDL",
118 documentation =>
119 "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.",
120 );
121  
122 has idssrc => ( is => "rw",
123 isa => "Str",
124 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
125 );
126  
127 has legendgrouptitle => ( is => "rw",
128 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Image::Legendgrouptitle", );
129  
130 has legendrank => (
131 is => "rw",
132 isa => "Num",
133 documentation =>
134 "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.",
135 );
136  
137 has pmeta => (
138 is => "rw",
139 isa => "Any|ArrayRef[Any]",
140 documentation =>
141 "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.",
142 );
143  
144 has metasrc => ( is => "rw",
145 isa => "Str",
146 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
147 );
148  
149 has name => ( is => "rw",
150 isa => "Str",
151 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
152 );
153  
154 has opacity => ( is => "rw",
155 isa => "Num",
156 documentation => "Sets the opacity of the trace.",
157 );
158  
159 has source => (
160 is => "rw",
161 isa => "Str",
162 documentation =>
163 "Specifies the data URI of the image to be visualized. The URI consists of \"data:image/[<media subtype>][;base64],<data>\"",
164 );
165  
166 has stream => ( is => "rw",
167 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Image::Stream", );
168  
169 has text => ( is => "rw",
170 isa => "ArrayRef|PDL",
171 documentation => "Sets the text elements associated with each z value.",
172 );
173  
174 has textsrc => ( is => "rw",
175 isa => "Str",
176 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
177 );
178  
179 has uid => (
180 is => "rw",
181 isa => "Str",
182 documentation =>
183 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
184 );
185  
186 has uirevision => (
187 is => "rw",
188 isa => "Any",
189 documentation =>
190 "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.",
191 );
192  
193 has visible => (
194 is => "rw",
195 documentation =>
196 "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).",
197 );
198  
199 has x0 => ( is => "rw",
200 isa => "Any",
201 documentation => "Set the image's x position.",
202 );
203  
204 has xaxis => (
205 is => "rw",
206 documentation =>
207 "Sets a reference between this trace's x coordinates and a 2D cartesian x axis. If *x* (the default value), the x coordinates refer to `layout.xaxis`. If *x2*, the x coordinates refer to `layout.xaxis2`, and so on.",
208 );
209  
210 has y0 => ( is => "rw",
211 isa => "Any",
212 documentation => "Set the image's y position.",
213 );
214  
215 has yaxis => (
216 is => "rw",
217 documentation =>
218 "Sets a reference between this trace's y coordinates and a 2D cartesian y axis. If *y* (the default value), the y coordinates refer to `layout.yaxis`. If *y2*, the y coordinates refer to `layout.yaxis2`, and so on.",
219 );
220  
221 has z => (
222 is => "rw",
223 isa => "ArrayRef|PDL",
224 documentation => "A 2-dimensional array in which each element is an array of 3 or 4 numbers representing a color.",
225 );
226  
227 has zmax => (
228 is => "rw",
229 isa => "ArrayRef|PDL",
230 documentation =>
231 "Array defining the higher bound for each color component. Note that the default value will depend on the colormodel. For the `rgb` colormodel, it is [255, 255, 255]. For the `rgba` colormodel, it is [255, 255, 255, 1]. For the `rgba256` colormodel, it is [255, 255, 255, 255]. For the `hsl` colormodel, it is [360, 100, 100]. For the `hsla` colormodel, it is [360, 100, 100, 1].",
232 );
233  
234 has zmin => (
235 is => "rw",
236 isa => "ArrayRef|PDL",
237 documentation =>
238 "Array defining the lower bound for each color component. Note that the default value will depend on the colormodel. For the `rgb` colormodel, it is [0, 0, 0]. For the `rgba` colormodel, it is [0, 0, 0, 0]. For the `rgba256` colormodel, it is [0, 0, 0, 0]. For the `hsl` colormodel, it is [0, 0, 0]. For the `hsla` colormodel, it is [0, 0, 0, 0].",
239 );
240  
241 has zsmooth => (
242 is => "rw",
243 documentation =>
244 "Picks a smoothing algorithm used to smooth `z` data. This only applies for image traces that use the `source` attribute.",
245 );
246  
247 has zsrc => ( is => "rw",
248 isa => "Str",
249 documentation => "Sets the source reference on Chart Studio Cloud for `z`.",
250 );
251  
252 __PACKAGE__->meta->make_immutable();
253 1;
254  
255 __END__