Chart/Plotly/Trace/Bar.pm untested

filter: Statementstmt 0.0% 0 / 161 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 205 CC 6 SCAR 25.6
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 12.9
1 package Chart::Plotly::Trace::Bar;
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::Bar::Error_x;
10 use Chart::Plotly::Trace::Bar::Error_y;
11 use Chart::Plotly::Trace::Bar::Hoverlabel;
12 use Chart::Plotly::Trace::Bar::Insidetextfont;
13 use Chart::Plotly::Trace::Bar::Legendgrouptitle;
14 use Chart::Plotly::Trace::Bar::Marker;
15 use Chart::Plotly::Trace::Bar::Outsidetextfont;
16 use Chart::Plotly::Trace::Bar::Selected;
17 use Chart::Plotly::Trace::Bar::Stream;
18 use Chart::Plotly::Trace::Bar::Textfont;
19 use Chart::Plotly::Trace::Bar::Transform;
20 use Chart::Plotly::Trace::Bar::Unselected;
21  
22 our $VERSION = '0.042'; # VERSION
23  
24 # ABSTRACT: 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.
25  
26 sub TO_JSON {
27 my $self = shift;
28 my $extra_args = $self->extra_args // {};
29 my $meta = $self->meta;
30 my %hash = %$self;
31 for my $name ( sort keys %hash ) {
32 my $attr = $meta->get_attribute($name);
33 if ( defined $attr ) {
34 my $value = $hash{$name};
35 my $type = $attr->type_constraint;
36 if ( $type && $type->equals('Bool') ) {
37 $hash{$name} = $value ? \1 : \0;
38 }
39 }
40 }
41 my $plotly_meta = delete $hash{'pmeta'};
42 if ( defined $plotly_meta ) {
43 $hash{'meta'} = $plotly_meta;
44 }
45 %hash = ( %hash, %$extra_args );
46 delete $hash{'extra_args'};
47 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
48 $hash{type} = $self->type();
49 }
50 return \%hash;
51 }
52  
53 sub type {
54 my @components = split( /::/, __PACKAGE__ );
55 return lc( $components[-1] );
56 }
57  
58 has alignmentgroup => (
59 is => "rw",
60 isa => "Str",
61 documentation =>
62 "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.",
63 );
64  
65 has base => (
66 is => "rw",
67 isa => "Any|ArrayRef[Any]",
68 documentation =>
69 "Sets where the bar base is drawn (in position axis units). In *stack* or *relative* barmode, traces that set *base* will be excluded and drawn in *overlay* mode instead.",
70 );
71  
72 has basesrc => ( is => "rw",
73 isa => "Str",
74 documentation => "Sets the source reference on Chart Studio Cloud for `base`.",
75 );
76  
77 has cliponaxis => (
78 is => "rw",
79 isa => "Bool",
80 documentation =>
81 "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*.",
82 );
83  
84 has constraintext => (
85 is => "rw",
86 isa => enum( [ "inside", "outside", "both", "none" ] ),
87 documentation => "Constrain the size of text inside or outside a bar to be no larger than the bar itself.",
88 );
89  
90 has customdata => (
91 is => "rw",
92 isa => "ArrayRef|PDL",
93 documentation =>
94 "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",
95 );
96  
97 has customdatasrc => ( is => "rw",
98 isa => "Str",
99 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
100 );
101  
102 has dx => ( is => "rw",
103 isa => "Num",
104 documentation => "Sets the x coordinate step. See `x0` for more info.",
105 );
106  
107 has dy => ( is => "rw",
108 isa => "Num",
109 documentation => "Sets the y coordinate step. See `y0` for more info.",
110 );
111  
112 has error_x => ( is => "rw",
113 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Error_x", );
114  
115 has error_y => ( is => "rw",
116 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Error_y", );
117  
118 has hoverinfo => (
119 is => "rw",
120 isa => "Str|ArrayRef[Str]",
121 documentation =>
122 "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.",
123 );
124  
125 has hoverinfosrc => ( is => "rw",
126 isa => "Str",
127 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
128 );
129  
130 has hoverlabel => ( is => "rw",
131 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Hoverlabel", );
132  
133 has hovertemplate => (
134 is => "rw",
135 isa => "Str|ArrayRef[Str]",
136 documentation =>
137 "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 `value` and `label`. 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>`.",
138 );
139  
140 has hovertemplatesrc => ( is => "rw",
141 isa => "Str",
142 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
143 );
144  
145 has hovertext => (
146 is => "rw",
147 isa => "Str|ArrayRef[Str]",
148 documentation =>
149 "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.",
150 );
151  
152 has hovertextsrc => ( is => "rw",
153 isa => "Str",
154 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
155 );
156  
157 has ids => (
158 is => "rw",
159 isa => "ArrayRef|PDL",
160 documentation =>
161 "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.",
162 );
163  
164 has idssrc => ( is => "rw",
165 isa => "Str",
166 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
167 );
168  
169 has insidetextanchor => (
170 is => "rw",
171 isa => enum( [ "end", "middle", "start" ] ),
172 documentation => "Determines if texts are kept at center or start/end points in `textposition` *inside* mode.",
173 );
174  
175 has insidetextfont => ( is => "rw",
176 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Insidetextfont", );
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::Bar::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 marker => ( is => "rw",
196 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Marker", );
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 offset => (
216 is => "rw",
217 isa => "Num|ArrayRef[Num]",
218 documentation =>
219 "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.",
220 );
221  
222 has offsetgroup => (
223 is => "rw",
224 isa => "Str",
225 documentation =>
226 "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.",
227 );
228  
229 has offsetsrc => ( is => "rw",
230 isa => "Str",
231 documentation => "Sets the source reference on Chart Studio Cloud for `offset`.",
232 );
233  
234 has opacity => ( is => "rw",
235 isa => "Num",
236 documentation => "Sets the opacity of the trace.",
237 );
238  
239 has orientation => (
240 is => "rw",
241 isa => enum( [ "v", "h" ] ),
242 documentation =>
243 "Sets the orientation of the bars. With *v* (*h*), the value of the each bar spans along the vertical (horizontal).",
244 );
245  
246 has outsidetextfont => ( is => "rw",
247 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Outsidetextfont", );
248  
249 has selected => ( is => "rw",
250 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Selected", );
251  
252 has selectedpoints => (
253 is => "rw",
254 isa => "Any",
255 documentation =>
256 "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.",
257 );
258  
259 has showlegend => (
260 is => "rw",
261 isa => "Bool",
262 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
263 );
264  
265 has stream => ( is => "rw",
266 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Stream", );
267  
268 has text => (
269 is => "rw",
270 isa => "Str|ArrayRef[Str]",
271 documentation =>
272 "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.",
273 );
274  
275 has textangle => (
276 is => "rw",
277 documentation =>
278 "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.",
279 );
280  
281 has textfont => ( is => "rw",
282 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Textfont", );
283  
284 has textposition => (
285 is => "rw",
286 isa => union( [ enum( [ "inside", "outside", "auto", "none" ] ), "ArrayRef" ] ),
287 documentation =>
288 "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.",
289 );
290  
291 has textpositionsrc => ( is => "rw",
292 isa => "Str",
293 documentation => "Sets the source reference on Chart Studio Cloud for `textposition`.",
294 );
295  
296 has textsrc => ( is => "rw",
297 isa => "Str",
298 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
299 );
300  
301 has texttemplate => (
302 is => "rw",
303 isa => "Str|ArrayRef[Str]",
304 documentation =>
305 "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 `value` and `label`.",
306 );
307  
308 has texttemplatesrc => ( is => "rw",
309 isa => "Str",
310 documentation => "Sets the source reference on Chart Studio Cloud for `texttemplate`.",
311 );
312  
313 has transforms => ( is => "rw",
314 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Bar::Transform]", );
315  
316 has uid => (
317 is => "rw",
318 isa => "Str",
319 documentation =>
320 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
321 );
322  
323 has uirevision => (
324 is => "rw",
325 isa => "Any",
326 documentation =>
327 "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.",
328 );
329  
330 has unselected => ( is => "rw",
331 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Bar::Unselected", );
332  
333 has visible => (
334 is => "rw",
335 documentation =>
336 "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).",
337 );
338  
339 has width => ( is => "rw",
340 isa => "Num|ArrayRef[Num]",
341 documentation => "Sets the bar width (in position axis units).",
342 );
343  
344 has widthsrc => ( is => "rw",
345 isa => "Str",
346 documentation => "Sets the source reference on Chart Studio Cloud for `width`.",
347 );
348  
349 has x => ( is => "rw",
350 isa => "ArrayRef|PDL",
351 documentation => "Sets the x coordinates.",
352 );
353  
354 has x0 => (
355 is => "rw",
356 isa => "Any",
357 documentation =>
358 "Alternate to `x`. Builds a linear space of x coordinates. Use with `dx` where `x0` is the starting coordinate and `dx` the step.",
359 );
360  
361 has xaxis => (
362 is => "rw",
363 documentation =>
364 "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.",
365 );
366  
367 has xcalendar => ( is => "rw",
368 isa => enum(
369 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
370 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
371 ]
372 ),
373 documentation => "Sets the calendar system to use with `x` date data.",
374 );
375  
376 has xhoverformat => (
377 is => "rw",
378 isa => "Str",
379 documentation =>
380 "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`.",
381 );
382  
383 has xperiod => (
384 is => "rw",
385 isa => "Any",
386 documentation =>
387 "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.",
388 );
389  
390 has xperiod0 => (
391 is => "rw",
392 isa => "Any",
393 documentation =>
394 "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.",
395 );
396  
397 has xperiodalignment => (
398 is => "rw",
399 isa => enum( [ "start", "middle", "end" ] ),
400 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the x axis.",
401 );
402  
403 has xsrc => ( is => "rw",
404 isa => "Str",
405 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
406 );
407  
408 has y => ( is => "rw",
409 isa => "ArrayRef|PDL",
410 documentation => "Sets the y coordinates.",
411 );
412  
413 has y0 => (
414 is => "rw",
415 isa => "Any",
416 documentation =>
417 "Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step.",
418 );
419  
420 has yaxis => (
421 is => "rw",
422 documentation =>
423 "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.",
424 );
425  
426 has ycalendar => ( is => "rw",
427 isa => enum(
428 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
429 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
430 ]
431 ),
432 documentation => "Sets the calendar system to use with `y` date data.",
433 );
434  
435 has yhoverformat => (
436 is => "rw",
437 isa => "Str",
438 documentation =>
439 "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`.",
440 );
441  
442 has yperiod => (
443 is => "rw",
444 isa => "Any",
445 documentation =>
446 "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.",
447 );
448  
449 has yperiod0 => (
450 is => "rw",
451 isa => "Any",
452 documentation =>
453 "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.",
454 );
455  
456 has yperiodalignment => (
457 is => "rw",
458 isa => enum( [ "start", "middle", "end" ] ),
459 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the y axis.",
460 );
461  
462 has ysrc => ( is => "rw",
463 isa => "Str",
464 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
465 );
466  
467 __PACKAGE__->meta->make_immutable();
468 1;
469  
470 __END__