Chart/Plotly/Trace/Contour.pm untested

filter: Statementstmt 0.0% 0 / 142 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 / 182 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::Contour;
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::Contour::Colorbar;
10 use Chart::Plotly::Trace::Contour::Contours;
11 use Chart::Plotly::Trace::Contour::Hoverlabel;
12 use Chart::Plotly::Trace::Contour::Legendgrouptitle;
13 use Chart::Plotly::Trace::Contour::Line;
14 use Chart::Plotly::Trace::Contour::Stream;
15 use Chart::Plotly::Trace::Contour::Textfont;
16 use Chart::Plotly::Trace::Contour::Transform;
17  
18 our $VERSION = '0.042'; # VERSION
19  
20 # ABSTRACT: The data from which contour lines are computed is set in `z`. Data in `z` must be a {2D array} of numbers. Say that `z` has N rows and M columns, then by default, these N rows correspond to N y coordinates (set in `y` or auto-generated) and the M columns correspond to M x coordinates (set in `x` or auto-generated). By setting `transpose` to *true*, the above behavior is flipped.
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 autocolorscale => (
55 is => "rw",
56 isa => "Bool",
57 documentation =>
58 "Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.",
59 );
60  
61 has autocontour => (
62 is => "rw",
63 isa => "Bool",
64 documentation =>
65 "Determines whether or not the contour level attributes are picked by an algorithm. If *true*, the number of contour levels can be set in `ncontours`. If *false*, set the contour level attributes in `contours`.",
66 );
67  
68 has coloraxis => (
69 is => "rw",
70 documentation =>
71 "Sets a reference to a shared color axis. References to these shared color axes are *coloraxis*, *coloraxis2*, *coloraxis3*, etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.",
72 );
73  
74 has colorbar => ( is => "rw",
75 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Colorbar", );
76  
77 has colorscale => (
78 is => "rw",
79 documentation =>
80 "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `zmin` and `zmax`. Alternatively, `colorscale` may be a palette name string of the following list: Blackbody,Bluered,Blues,Cividis,Earth,Electric,Greens,Greys,Hot,Jet,Picnic,Portland,Rainbow,RdBu,Reds,Viridis,YlGnBu,YlOrRd.",
81 );
82  
83 has connectgaps => (
84 is => "rw",
85 isa => "Bool",
86 documentation =>
87 "Determines whether or not gaps (i.e. {nan} or missing values) in the `z` data are filled in. It is defaulted to true if `z` is a one dimensional array otherwise it is defaulted to false.",
88 );
89  
90 has contours => ( is => "rw",
91 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Contours", );
92  
93 has customdata => (
94 is => "rw",
95 isa => "ArrayRef|PDL",
96 documentation =>
97 "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",
98 );
99  
100 has customdatasrc => ( is => "rw",
101 isa => "Str",
102 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
103 );
104  
105 has dx => ( is => "rw",
106 isa => "Num",
107 documentation => "Sets the x coordinate step. See `x0` for more info.",
108 );
109  
110 has dy => ( is => "rw",
111 isa => "Num",
112 documentation => "Sets the y coordinate step. See `y0` for more info.",
113 );
114  
115 has fillcolor => (
116 is => "rw",
117 isa => "Str",
118 documentation =>
119 "Sets the fill color if `contours.type` is *constraint*. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.",
120 );
121  
122 has hoverinfo => (
123 is => "rw",
124 isa => "Str|ArrayRef[Str]",
125 documentation =>
126 "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.",
127 );
128  
129 has hoverinfosrc => ( is => "rw",
130 isa => "Str",
131 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
132 );
133  
134 has hoverlabel => ( is => "rw",
135 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Hoverlabel", );
136  
137 has hoverongaps => (
138 is => "rw",
139 isa => "Bool",
140 documentation =>
141 "Determines whether or not gaps (i.e. {nan} or missing values) in the `z` data have hover labels associated with them.",
142 );
143  
144 has hovertemplate => (
145 is => "rw",
146 isa => "Str|ArrayRef[Str]",
147 documentation =>
148 "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. 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>`.",
149 );
150  
151 has hovertemplatesrc => ( is => "rw",
152 isa => "Str",
153 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
154 );
155  
156 has hovertext => ( is => "rw",
157 isa => "ArrayRef|PDL",
158 documentation => "Same as `text`.",
159 );
160  
161 has hovertextsrc => ( is => "rw",
162 isa => "Str",
163 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
164 );
165  
166 has ids => (
167 is => "rw",
168 isa => "ArrayRef|PDL",
169 documentation =>
170 "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.",
171 );
172  
173 has idssrc => ( is => "rw",
174 isa => "Str",
175 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
176 );
177  
178 has legendgroup => (
179 is => "rw",
180 isa => "Str",
181 documentation =>
182 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
183 );
184  
185 has legendgrouptitle => ( is => "rw",
186 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Legendgrouptitle", );
187  
188 has legendrank => (
189 is => "rw",
190 isa => "Num",
191 documentation =>
192 "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.",
193 );
194  
195 has line => ( is => "rw",
196 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Line", );
197  
198 has pmeta => (
199 is => "rw",
200 isa => "Any|ArrayRef[Any]",
201 documentation =>
202 "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.",
203 );
204  
205 has metasrc => ( is => "rw",
206 isa => "Str",
207 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
208 );
209  
210 has name => ( is => "rw",
211 isa => "Str",
212 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
213 );
214  
215 has ncontours => (
216 is => "rw",
217 isa => "Int",
218 documentation =>
219 "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of `ncontours`. Has an effect only if `autocontour` is *true* or if `contours.size` is missing.",
220 );
221  
222 has opacity => ( is => "rw",
223 isa => "Num",
224 documentation => "Sets the opacity of the trace.",
225 );
226  
227 has reversescale => (
228 is => "rw",
229 isa => "Bool",
230 documentation =>
231 "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color.",
232 );
233  
234 has showlegend => (
235 is => "rw",
236 isa => "Bool",
237 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
238 );
239  
240 has showscale => ( is => "rw",
241 isa => "Bool",
242 documentation => "Determines whether or not a colorbar is displayed for this trace.",
243 );
244  
245 has stream => ( is => "rw",
246 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Stream", );
247  
248 has text => ( is => "rw",
249 isa => "ArrayRef|PDL",
250 documentation => "Sets the text elements associated with each z value.",
251 );
252  
253 has textfont => ( is => "rw",
254 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Contour::Textfont", );
255  
256 has textsrc => ( is => "rw",
257 isa => "Str",
258 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
259 );
260  
261 has texttemplate => (
262 is => "rw",
263 isa => "Str",
264 documentation =>
265 "For this trace it only has an effect if `coloring` is set to *heatmap*. Template string used for rendering the information text that appear on points. Note that this will override `textinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". 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. Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variables `x`, `y`, `z` and `text`.",
266 );
267  
268 has transforms => ( is => "rw",
269 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Contour::Transform]", );
270  
271 has transpose => ( is => "rw",
272 isa => "Bool",
273 documentation => "Transposes the z data.",
274 );
275  
276 has uid => (
277 is => "rw",
278 isa => "Str",
279 documentation =>
280 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
281 );
282  
283 has uirevision => (
284 is => "rw",
285 isa => "Any",
286 documentation =>
287 "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.",
288 );
289  
290 has visible => (
291 is => "rw",
292 documentation =>
293 "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).",
294 );
295  
296 has x => ( is => "rw",
297 isa => "ArrayRef|PDL",
298 documentation => "Sets the x coordinates.",
299 );
300  
301 has x0 => (
302 is => "rw",
303 isa => "Any",
304 documentation =>
305 "Alternate to `x`. Builds a linear space of x coordinates. Use with `dx` where `x0` is the starting coordinate and `dx` the step.",
306 );
307  
308 has xaxis => (
309 is => "rw",
310 documentation =>
311 "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.",
312 );
313  
314 has xcalendar => ( is => "rw",
315 isa => enum(
316 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
317 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
318 ]
319 ),
320 documentation => "Sets the calendar system to use with `x` date data.",
321 );
322  
323 has xhoverformat => (
324 is => "rw",
325 isa => "Str",
326 documentation =>
327 "Sets the hover text formatting rulefor `x` 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. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*By default the values are formatted using `xaxis.hoverformat`.",
328 );
329  
330 has xperiod => (
331 is => "rw",
332 isa => "Any",
333 documentation =>
334 "Only relevant when the axis `type` is *date*. Sets the period positioning in milliseconds or *n* on the x axis. Special values in the form of *n* could be used to declare the number of months. In this case `n` must be a positive integer.",
335 );
336  
337 has xperiod0 => (
338 is => "rw",
339 isa => "Any",
340 documentation =>
341 "Only relevant when the axis `type` is *date*. Sets the base for period positioning in milliseconds or date string on the x0 axis. When `x0period` is round number of weeks, the `x0period0` by default would be on a Sunday i.e. 2000-01-02, otherwise it would be at 2000-01-01.",
342 );
343  
344 has xperiodalignment => (
345 is => "rw",
346 isa => enum( [ "start", "middle", "end" ] ),
347 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the x axis.",
348 );
349  
350 has xsrc => ( is => "rw",
351 isa => "Str",
352 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
353 );
354  
355 has xtype => (
356 is => "rw",
357 isa => enum( [ "array", "scaled" ] ),
358 documentation =>
359 "If *array*, the heatmap's x coordinates are given by *x* (the default behavior when `x` is provided). If *scaled*, the heatmap's x coordinates are given by *x0* and *dx* (the default behavior when `x` is not provided).",
360 );
361  
362 has y => ( is => "rw",
363 isa => "ArrayRef|PDL",
364 documentation => "Sets the y coordinates.",
365 );
366  
367 has y0 => (
368 is => "rw",
369 isa => "Any",
370 documentation =>
371 "Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step.",
372 );
373  
374 has yaxis => (
375 is => "rw",
376 documentation =>
377 "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.",
378 );
379  
380 has ycalendar => ( is => "rw",
381 isa => enum(
382 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
383 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
384 ]
385 ),
386 documentation => "Sets the calendar system to use with `y` date data.",
387 );
388  
389 has yhoverformat => (
390 is => "rw",
391 isa => "Str",
392 documentation =>
393 "Sets the hover text formatting rulefor `y` 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. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: *%h* for half of the year as a decimal number as well as *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*By default the values are formatted using `yaxis.hoverformat`.",
394 );
395  
396 has yperiod => (
397 is => "rw",
398 isa => "Any",
399 documentation =>
400 "Only relevant when the axis `type` is *date*. Sets the period positioning in milliseconds or *n* on the y axis. Special values in the form of *n* could be used to declare the number of months. In this case `n` must be a positive integer.",
401 );
402  
403 has yperiod0 => (
404 is => "rw",
405 isa => "Any",
406 documentation =>
407 "Only relevant when the axis `type` is *date*. Sets the base for period positioning in milliseconds or date string on the y0 axis. When `y0period` is round number of weeks, the `y0period0` by default would be on a Sunday i.e. 2000-01-02, otherwise it would be at 2000-01-01.",
408 );
409  
410 has yperiodalignment => (
411 is => "rw",
412 isa => enum( [ "start", "middle", "end" ] ),
413 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the y axis.",
414 );
415  
416 has ysrc => ( is => "rw",
417 isa => "Str",
418 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
419 );
420  
421 has ytype => (
422 is => "rw",
423 isa => enum( [ "array", "scaled" ] ),
424 documentation =>
425 "If *array*, the heatmap's y coordinates are given by *y* (the default behavior when `y` is provided) If *scaled*, the heatmap's y coordinates are given by *y0* and *dy* (the default behavior when `y` is not provided)",
426 );
427  
428 has z => ( is => "rw",
429 isa => "ArrayRef|PDL",
430 documentation => "Sets the z data.",
431 );
432  
433 has zauto => (
434 is => "rw",
435 isa => "Bool",
436 documentation =>
437 "Determines whether or not the color domain is computed with respect to the input data (here in `z`) or the bounds set in `zmin` and `zmax` Defaults to `false` when `zmin` and `zmax` are set by the user.",
438 );
439  
440 has zhoverformat => (
441 is => "rw",
442 isa => "Str",
443 documentation =>
444 "Sets the hover text formatting rulefor `z` 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.By default the values are formatted using generic number format.",
445 );
446  
447 has zmax => (
448 is => "rw",
449 isa => "Num",
450 documentation =>
451 "Sets the upper bound of the color domain. Value should have the same units as in `z` and if set, `zmin` must be set as well.",
452 );
453  
454 has zmid => (
455 is => "rw",
456 isa => "Num",
457 documentation =>
458 "Sets the mid-point of the color domain by scaling `zmin` and/or `zmax` to be equidistant to this point. Value should have the same units as in `z`. Has no effect when `zauto` is `false`.",
459 );
460  
461 has zmin => (
462 is => "rw",
463 isa => "Num",
464 documentation =>
465 "Sets the lower bound of the color domain. Value should have the same units as in `z` and if set, `zmax` must be set as well.",
466 );
467  
468 has zsrc => ( is => "rw",
469 isa => "Str",
470 documentation => "Sets the source reference on Chart Studio Cloud for `z`.",
471 );
472  
473 __PACKAGE__->meta->make_immutable();
474 1;
475  
476 __END__