Chart/Plotly/Trace/Heatmap.pm untested

filter: Statementstmt 0.0% 0 / 134 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 172 CC 6 SCAR 28.3
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 17.0
1 package Chart::Plotly::Trace::Heatmap;
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::Heatmap::Colorbar;
10 use Chart::Plotly::Trace::Heatmap::Hoverlabel;
11 use Chart::Plotly::Trace::Heatmap::Legendgrouptitle;
12 use Chart::Plotly::Trace::Heatmap::Stream;
13 use Chart::Plotly::Trace::Heatmap::Textfont;
14 use Chart::Plotly::Trace::Heatmap::Transform;
15  
16 our $VERSION = '0.042'; # VERSION
17  
18 # ABSTRACT: The data that describes the heatmap value-to-color mapping is set in `z`. Data in `z` can either be a {2D array} of values (ragged or not) or a 1D array of values. In the case where `z` is a {2D array}, say that `z` has N rows and M columns. Then, by default, the resulting heatmap will have N partitions along the y axis and M partitions along the x axis. In other words, the i-th row/ j-th column cell in `z` is mapped to the i-th partition of the y axis (starting from the bottom of the plot) and the j-th partition of the x-axis (starting from the left of the plot). This behavior can be flipped by using `transpose`. Moreover, `x` (`y`) can be provided with M or M+1 (N or N+1) elements. If M (N), then the coordinates correspond to the center of the heatmap cells and the cells have equal width. If M+1 (N+1), then the coordinates correspond to the edges of the heatmap cells. In the case where `z` is a 1D {array}, the x and y coordinates must be provided in `x` and `y` respectively to form data triplets.
19  
20 sub TO_JSON {
21 my $self = shift;
22 my $extra_args = $self->extra_args // {};
23 my $meta = $self->meta;
24 my %hash = %$self;
25 for my $name ( sort keys %hash ) {
26 my $attr = $meta->get_attribute($name);
27 if ( defined $attr ) {
28 my $value = $hash{$name};
29 my $type = $attr->type_constraint;
30 if ( $type && $type->equals('Bool') ) {
31 $hash{$name} = $value ? \1 : \0;
32 }
33 }
34 }
35 my $plotly_meta = delete $hash{'pmeta'};
36 if ( defined $plotly_meta ) {
37 $hash{'meta'} = $plotly_meta;
38 }
39 %hash = ( %hash, %$extra_args );
40 delete $hash{'extra_args'};
41 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
42 $hash{type} = $self->type();
43 }
44 return \%hash;
45 }
46  
47 sub type {
48 my @components = split( /::/, __PACKAGE__ );
49 return lc( $components[-1] );
50 }
51  
52 has autocolorscale => (
53 is => "rw",
54 isa => "Bool",
55 documentation =>
56 "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.",
57 );
58  
59 has coloraxis => (
60 is => "rw",
61 documentation =>
62 "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.",
63 );
64  
65 has colorbar => ( is => "rw",
66 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Heatmap::Colorbar", );
67  
68 has colorscale => (
69 is => "rw",
70 documentation =>
71 "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.",
72 );
73  
74 has connectgaps => (
75 is => "rw",
76 isa => "Bool",
77 documentation =>
78 "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 and `zsmooth` is not false; otherwise it is defaulted to false.",
79 );
80  
81 has customdata => (
82 is => "rw",
83 isa => "ArrayRef|PDL",
84 documentation =>
85 "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",
86 );
87  
88 has customdatasrc => ( is => "rw",
89 isa => "Str",
90 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
91 );
92  
93 has dx => ( is => "rw",
94 isa => "Num",
95 documentation => "Sets the x coordinate step. See `x0` for more info.",
96 );
97  
98 has dy => ( is => "rw",
99 isa => "Num",
100 documentation => "Sets the y coordinate step. See `y0` for more info.",
101 );
102  
103 has hoverinfo => (
104 is => "rw",
105 isa => "Str|ArrayRef[Str]",
106 documentation =>
107 "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.",
108 );
109  
110 has hoverinfosrc => ( is => "rw",
111 isa => "Str",
112 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
113 );
114  
115 has hoverlabel => ( is => "rw",
116 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Heatmap::Hoverlabel", );
117  
118 has hoverongaps => (
119 is => "rw",
120 isa => "Bool",
121 documentation =>
122 "Determines whether or not gaps (i.e. {nan} or missing values) in the `z` data have hover labels associated with them.",
123 );
124  
125 has hovertemplate => (
126 is => "rw",
127 isa => "Str|ArrayRef[Str]",
128 documentation =>
129 "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>`.",
130 );
131  
132 has hovertemplatesrc => ( is => "rw",
133 isa => "Str",
134 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
135 );
136  
137 has hovertext => ( is => "rw",
138 isa => "ArrayRef|PDL",
139 documentation => "Same as `text`.",
140 );
141  
142 has hovertextsrc => ( is => "rw",
143 isa => "Str",
144 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
145 );
146  
147 has ids => (
148 is => "rw",
149 isa => "ArrayRef|PDL",
150 documentation =>
151 "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.",
152 );
153  
154 has idssrc => ( is => "rw",
155 isa => "Str",
156 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
157 );
158  
159 has legendgroup => (
160 is => "rw",
161 isa => "Str",
162 documentation =>
163 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
164 );
165  
166 has legendgrouptitle => ( is => "rw",
167 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Heatmap::Legendgrouptitle", );
168  
169 has legendrank => (
170 is => "rw",
171 isa => "Num",
172 documentation =>
173 "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.",
174 );
175  
176 has pmeta => (
177 is => "rw",
178 isa => "Any|ArrayRef[Any]",
179 documentation =>
180 "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.",
181 );
182  
183 has metasrc => ( is => "rw",
184 isa => "Str",
185 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
186 );
187  
188 has name => ( is => "rw",
189 isa => "Str",
190 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
191 );
192  
193 has opacity => ( is => "rw",
194 isa => "Num",
195 documentation => "Sets the opacity of the trace.",
196 );
197  
198 has reversescale => (
199 is => "rw",
200 isa => "Bool",
201 documentation =>
202 "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.",
203 );
204  
205 has showlegend => (
206 is => "rw",
207 isa => "Bool",
208 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
209 );
210  
211 has showscale => ( is => "rw",
212 isa => "Bool",
213 documentation => "Determines whether or not a colorbar is displayed for this trace.",
214 );
215  
216 has stream => ( is => "rw",
217 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Heatmap::Stream", );
218  
219 has text => ( is => "rw",
220 isa => "ArrayRef|PDL",
221 documentation => "Sets the text elements associated with each z value.",
222 );
223  
224 has textfont => ( is => "rw",
225 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Heatmap::Textfont", );
226  
227 has textsrc => ( is => "rw",
228 isa => "Str",
229 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
230 );
231  
232 has texttemplate => (
233 is => "rw",
234 isa => "Str",
235 documentation =>
236 "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`.",
237 );
238  
239 has transforms => ( is => "rw",
240 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Heatmap::Transform]", );
241  
242 has transpose => ( is => "rw",
243 isa => "Bool",
244 documentation => "Transposes the z data.",
245 );
246  
247 has uid => (
248 is => "rw",
249 isa => "Str",
250 documentation =>
251 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
252 );
253  
254 has uirevision => (
255 is => "rw",
256 isa => "Any",
257 documentation =>
258 "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.",
259 );
260  
261 has visible => (
262 is => "rw",
263 documentation =>
264 "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).",
265 );
266  
267 has x => ( is => "rw",
268 isa => "ArrayRef|PDL",
269 documentation => "Sets the x coordinates.",
270 );
271  
272 has x0 => (
273 is => "rw",
274 isa => "Any",
275 documentation =>
276 "Alternate to `x`. Builds a linear space of x coordinates. Use with `dx` where `x0` is the starting coordinate and `dx` the step.",
277 );
278  
279 has xaxis => (
280 is => "rw",
281 documentation =>
282 "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.",
283 );
284  
285 has xcalendar => ( is => "rw",
286 isa => enum(
287 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
288 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
289 ]
290 ),
291 documentation => "Sets the calendar system to use with `x` date data.",
292 );
293  
294 has xgap => ( is => "rw",
295 isa => "Num",
296 documentation => "Sets the horizontal gap (in pixels) between bricks.",
297 );
298  
299 has xhoverformat => (
300 is => "rw",
301 isa => "Str",
302 documentation =>
303 "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`.",
304 );
305  
306 has xperiod => (
307 is => "rw",
308 isa => "Any",
309 documentation =>
310 "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.",
311 );
312  
313 has xperiod0 => (
314 is => "rw",
315 isa => "Any",
316 documentation =>
317 "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.",
318 );
319  
320 has xperiodalignment => (
321 is => "rw",
322 isa => enum( [ "start", "middle", "end" ] ),
323 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the x axis.",
324 );
325  
326 has xsrc => ( is => "rw",
327 isa => "Str",
328 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
329 );
330  
331 has xtype => (
332 is => "rw",
333 isa => enum( [ "array", "scaled" ] ),
334 documentation =>
335 "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).",
336 );
337  
338 has y => ( is => "rw",
339 isa => "ArrayRef|PDL",
340 documentation => "Sets the y coordinates.",
341 );
342  
343 has y0 => (
344 is => "rw",
345 isa => "Any",
346 documentation =>
347 "Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step.",
348 );
349  
350 has yaxis => (
351 is => "rw",
352 documentation =>
353 "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.",
354 );
355  
356 has ycalendar => ( is => "rw",
357 isa => enum(
358 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
359 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
360 ]
361 ),
362 documentation => "Sets the calendar system to use with `y` date data.",
363 );
364  
365 has ygap => ( is => "rw",
366 isa => "Num",
367 documentation => "Sets the vertical gap (in pixels) between bricks.",
368 );
369  
370 has yhoverformat => (
371 is => "rw",
372 isa => "Str",
373 documentation =>
374 "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`.",
375 );
376  
377 has yperiod => (
378 is => "rw",
379 isa => "Any",
380 documentation =>
381 "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.",
382 );
383  
384 has yperiod0 => (
385 is => "rw",
386 isa => "Any",
387 documentation =>
388 "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.",
389 );
390  
391 has yperiodalignment => (
392 is => "rw",
393 isa => enum( [ "start", "middle", "end" ] ),
394 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the y axis.",
395 );
396  
397 has ysrc => ( is => "rw",
398 isa => "Str",
399 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
400 );
401  
402 has ytype => (
403 is => "rw",
404 isa => enum( [ "array", "scaled" ] ),
405 documentation =>
406 "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)",
407 );
408  
409 has z => ( is => "rw",
410 isa => "ArrayRef|PDL",
411 documentation => "Sets the z data.",
412 );
413  
414 has zauto => (
415 is => "rw",
416 isa => "Bool",
417 documentation =>
418 "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.",
419 );
420  
421 has zhoverformat => (
422 is => "rw",
423 isa => "Str",
424 documentation =>
425 "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.",
426 );
427  
428 has zmax => (
429 is => "rw",
430 isa => "Num",
431 documentation =>
432 "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.",
433 );
434  
435 has zmid => (
436 is => "rw",
437 isa => "Num",
438 documentation =>
439 "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`.",
440 );
441  
442 has zmin => (
443 is => "rw",
444 isa => "Num",
445 documentation =>
446 "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.",
447 );
448  
449 has zsmooth => ( is => "rw",
450 documentation => "Picks a smoothing algorithm use to smooth `z` data.", );
451  
452 has zsrc => ( is => "rw",
453 isa => "Str",
454 documentation => "Sets the source reference on Chart Studio Cloud for `z`.",
455 );
456  
457 __PACKAGE__->meta->make_immutable();
458 1;
459  
460 __END__