Chart/Plotly/Trace/Waterfall.pm untested

filter: Statementstmt 0.0% 0 / 153 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 196 CC 6 SCAR 26.0
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 13.4
1 package Chart::Plotly::Trace::Waterfall;
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::Waterfall::Connector;
10 use Chart::Plotly::Trace::Waterfall::Decreasing;
11 use Chart::Plotly::Trace::Waterfall::Hoverlabel;
12 use Chart::Plotly::Trace::Waterfall::Increasing;
13 use Chart::Plotly::Trace::Waterfall::Insidetextfont;
14 use Chart::Plotly::Trace::Waterfall::Legendgrouptitle;
15 use Chart::Plotly::Trace::Waterfall::Outsidetextfont;
16 use Chart::Plotly::Trace::Waterfall::Stream;
17 use Chart::Plotly::Trace::Waterfall::Textfont;
18 use Chart::Plotly::Trace::Waterfall::Totals;
19 use Chart::Plotly::Trace::Waterfall::Transform;
20  
21 our $VERSION = '0.042'; # VERSION
22  
23 # ABSTRACT: Draws waterfall trace which is useful graph to displays the contribution of various elements (either positive or negative) in a bar chart. The data visualized by the span of the bars is set in `y` if `orientation` is set th *v* (the default) and the labels are set in `x`. By setting `orientation` to *h*, the roles are interchanged.
24  
25 sub TO_JSON {
26 my $self = shift;
27 my $extra_args = $self->extra_args // {};
28 my $meta = $self->meta;
29 my %hash = %$self;
30 for my $name ( sort keys %hash ) {
31 my $attr = $meta->get_attribute($name);
32 if ( defined $attr ) {
33 my $value = $hash{$name};
34 my $type = $attr->type_constraint;
35 if ( $type && $type->equals('Bool') ) {
36 $hash{$name} = $value ? \1 : \0;
37 }
38 }
39 }
40 my $plotly_meta = delete $hash{'pmeta'};
41 if ( defined $plotly_meta ) {
42 $hash{'meta'} = $plotly_meta;
43 }
44 %hash = ( %hash, %$extra_args );
45 delete $hash{'extra_args'};
46 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
47 $hash{type} = $self->type();
48 }
49 return \%hash;
50 }
51  
52 sub type {
53 my @components = split( /::/, __PACKAGE__ );
54 return lc( $components[-1] );
55 }
56  
57 has alignmentgroup => (
58 is => "rw",
59 isa => "Str",
60 documentation =>
61 "Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently.",
62 );
63  
64 has base => ( is => "rw",
65 isa => "Num",
66 documentation => "Sets where the bar base is drawn (in position axis units).",
67 );
68  
69 has cliponaxis => (
70 is => "rw",
71 isa => "Bool",
72 documentation =>
73 "Determines whether the text nodes are clipped about the subplot axes. To show the text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
74 );
75  
76 has connector => ( is => "rw",
77 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Connector", );
78  
79 has constraintext => (
80 is => "rw",
81 isa => enum( [ "inside", "outside", "both", "none" ] ),
82 documentation => "Constrain the size of text inside or outside a bar to be no larger than the bar itself.",
83 );
84  
85 has customdata => (
86 is => "rw",
87 isa => "ArrayRef|PDL",
88 documentation =>
89 "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",
90 );
91  
92 has customdatasrc => ( is => "rw",
93 isa => "Str",
94 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
95 );
96  
97 has decreasing => ( is => "rw",
98 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Decreasing", );
99  
100 has dx => ( is => "rw",
101 isa => "Num",
102 documentation => "Sets the x coordinate step. See `x0` for more info.",
103 );
104  
105 has dy => ( is => "rw",
106 isa => "Num",
107 documentation => "Sets the y coordinate step. See `y0` for more info.",
108 );
109  
110 has hoverinfo => (
111 is => "rw",
112 isa => "Str|ArrayRef[Str]",
113 documentation =>
114 "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.",
115 );
116  
117 has hoverinfosrc => ( is => "rw",
118 isa => "Str",
119 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
120 );
121  
122 has hoverlabel => ( is => "rw",
123 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Hoverlabel", );
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. variables `initial`, `delta` and `final`. 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 => (
138 is => "rw",
139 isa => "Str|ArrayRef[Str]",
140 documentation =>
141 "Sets hover text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. To be seen, trace `hoverinfo` must contain a *text* flag.",
142 );
143  
144 has hovertextsrc => ( is => "rw",
145 isa => "Str",
146 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
147 );
148  
149 has ids => (
150 is => "rw",
151 isa => "ArrayRef|PDL",
152 documentation =>
153 "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.",
154 );
155  
156 has idssrc => ( is => "rw",
157 isa => "Str",
158 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
159 );
160  
161 has increasing => ( is => "rw",
162 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Increasing", );
163  
164 has insidetextanchor => (
165 is => "rw",
166 isa => enum( [ "end", "middle", "start" ] ),
167 documentation => "Determines if texts are kept at center or start/end points in `textposition` *inside* mode.",
168 );
169  
170 has insidetextfont => ( is => "rw",
171 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Insidetextfont", );
172  
173 has legendgroup => (
174 is => "rw",
175 isa => "Str",
176 documentation =>
177 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
178 );
179  
180 has legendgrouptitle => ( is => "rw",
181 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Legendgrouptitle", );
182  
183 has legendrank => (
184 is => "rw",
185 isa => "Num",
186 documentation =>
187 "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.",
188 );
189  
190 has measure => (
191 is => "rw",
192 isa => "ArrayRef|PDL",
193 documentation =>
194 "An array containing types of values. By default the values are considered as 'relative'. However; it is possible to use 'total' to compute the sums. Also 'absolute' could be applied to reset the computed total or to declare an initial value where needed.",
195 );
196  
197 has measuresrc => ( is => "rw",
198 isa => "Str",
199 documentation => "Sets the source reference on Chart Studio Cloud for `measure`.",
200 );
201  
202 has pmeta => (
203 is => "rw",
204 isa => "Any|ArrayRef[Any]",
205 documentation =>
206 "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.",
207 );
208  
209 has metasrc => ( is => "rw",
210 isa => "Str",
211 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
212 );
213  
214 has name => ( is => "rw",
215 isa => "Str",
216 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
217 );
218  
219 has offset => (
220 is => "rw",
221 isa => "Num|ArrayRef[Num]",
222 documentation =>
223 "Shifts the position where the bar is drawn (in position axis units). In *group* barmode, traces that set *offset* will be excluded and drawn in *overlay* mode instead.",
224 );
225  
226 has offsetgroup => (
227 is => "rw",
228 isa => "Str",
229 documentation =>
230 "Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up.",
231 );
232  
233 has offsetsrc => ( is => "rw",
234 isa => "Str",
235 documentation => "Sets the source reference on Chart Studio Cloud for `offset`.",
236 );
237  
238 has opacity => ( is => "rw",
239 isa => "Num",
240 documentation => "Sets the opacity of the trace.",
241 );
242  
243 has orientation => (
244 is => "rw",
245 isa => enum( [ "v", "h" ] ),
246 documentation =>
247 "Sets the orientation of the bars. With *v* (*h*), the value of the each bar spans along the vertical (horizontal).",
248 );
249  
250 has outsidetextfont => ( is => "rw",
251 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Outsidetextfont", );
252  
253 has selectedpoints => (
254 is => "rw",
255 isa => "Any",
256 documentation =>
257 "Array containing integer indices of selected points. Has an effect only for traces that support selections. Note that an empty array means an empty selection where the `unselected` are turned on for all points, whereas, any other non-array values means no selection all where the `selected` and `unselected` styles have no effect.",
258 );
259  
260 has showlegend => (
261 is => "rw",
262 isa => "Bool",
263 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
264 );
265  
266 has stream => ( is => "rw",
267 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Stream", );
268  
269 has text => (
270 is => "rw",
271 isa => "Str|ArrayRef[Str]",
272 documentation =>
273 "Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a *text* flag and *hovertext* is not set, these elements will be seen in the hover labels.",
274 );
275  
276 has textangle => (
277 is => "rw",
278 documentation =>
279 "Sets the angle of the tick labels with respect to the bar. For example, a `tickangle` of -90 draws the tick labels vertically. With *auto* the texts may automatically be rotated to fit with the maximum size in bars.",
280 );
281  
282 has textfont => ( is => "rw",
283 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Textfont", );
284  
285 has textinfo => (
286 is => "rw",
287 isa => "Str",
288 documentation =>
289 "Determines which trace information appear on the graph. In the case of having multiple waterfalls, totals are computed separately (per trace).",
290 );
291  
292 has textposition => (
293 is => "rw",
294 isa => union( [ enum( [ "inside", "outside", "auto", "none" ] ), "ArrayRef" ] ),
295 documentation =>
296 "Specifies the location of the `text`. *inside* positions `text` inside, next to the bar end (rotated and scaled if needed). *outside* positions `text` outside, next to the bar end (scaled if needed), unless there is another bar stacked on this one, then the text gets pushed inside. *auto* tries to position `text` inside the bar, but if the bar is too small and no bar is stacked on this one the text is moved outside. If *none*, no text appears.",
297 );
298  
299 has textpositionsrc => ( is => "rw",
300 isa => "Str",
301 documentation => "Sets the source reference on Chart Studio Cloud for `textposition`.",
302 );
303  
304 has textsrc => ( is => "rw",
305 isa => "Str",
306 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
307 );
308  
309 has texttemplate => (
310 is => "rw",
311 isa => "Str|ArrayRef[Str]",
312 documentation =>
313 "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 `initial`, `delta`, `final` and `label`.",
314 );
315  
316 has texttemplatesrc => ( is => "rw",
317 isa => "Str",
318 documentation => "Sets the source reference on Chart Studio Cloud for `texttemplate`.",
319 );
320  
321 has totals => ( is => "rw",
322 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Waterfall::Totals", );
323  
324 has transforms => ( is => "rw",
325 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Waterfall::Transform]", );
326  
327 has uid => (
328 is => "rw",
329 isa => "Str",
330 documentation =>
331 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
332 );
333  
334 has uirevision => (
335 is => "rw",
336 isa => "Any",
337 documentation =>
338 "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.",
339 );
340  
341 has visible => (
342 is => "rw",
343 documentation =>
344 "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).",
345 );
346  
347 has width => ( is => "rw",
348 isa => "Num|ArrayRef[Num]",
349 documentation => "Sets the bar width (in position axis units).",
350 );
351  
352 has widthsrc => ( is => "rw",
353 isa => "Str",
354 documentation => "Sets the source reference on Chart Studio Cloud for `width`.",
355 );
356  
357 has x => ( is => "rw",
358 isa => "ArrayRef|PDL",
359 documentation => "Sets the x coordinates.",
360 );
361  
362 has x0 => (
363 is => "rw",
364 isa => "Any",
365 documentation =>
366 "Alternate to `x`. Builds a linear space of x coordinates. Use with `dx` where `x0` is the starting coordinate and `dx` the step.",
367 );
368  
369 has xaxis => (
370 is => "rw",
371 documentation =>
372 "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.",
373 );
374  
375 has xhoverformat => (
376 is => "rw",
377 isa => "Str",
378 documentation =>
379 "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`.",
380 );
381  
382 has xperiod => (
383 is => "rw",
384 isa => "Any",
385 documentation =>
386 "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.",
387 );
388  
389 has xperiod0 => (
390 is => "rw",
391 isa => "Any",
392 documentation =>
393 "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.",
394 );
395  
396 has xperiodalignment => (
397 is => "rw",
398 isa => enum( [ "start", "middle", "end" ] ),
399 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the x axis.",
400 );
401  
402 has xsrc => ( is => "rw",
403 isa => "Str",
404 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
405 );
406  
407 has y => ( is => "rw",
408 isa => "ArrayRef|PDL",
409 documentation => "Sets the y coordinates.",
410 );
411  
412 has y0 => (
413 is => "rw",
414 isa => "Any",
415 documentation =>
416 "Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step.",
417 );
418  
419 has yaxis => (
420 is => "rw",
421 documentation =>
422 "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.",
423 );
424  
425 has yhoverformat => (
426 is => "rw",
427 isa => "Str",
428 documentation =>
429 "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`.",
430 );
431  
432 has yperiod => (
433 is => "rw",
434 isa => "Any",
435 documentation =>
436 "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.",
437 );
438  
439 has yperiod0 => (
440 is => "rw",
441 isa => "Any",
442 documentation =>
443 "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.",
444 );
445  
446 has yperiodalignment => (
447 is => "rw",
448 isa => enum( [ "start", "middle", "end" ] ),
449 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the y axis.",
450 );
451  
452 has ysrc => ( is => "rw",
453 isa => "Str",
454 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
455 );
456  
457 __PACKAGE__->meta->make_immutable();
458 1;
459  
460 __END__