Chart/Plotly/Trace/Icicle.pm untested

filter: Statementstmt 0.0% 0 / 126 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 171 CC 6 SCAR 25.2
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 12.4
1 package Chart::Plotly::Trace::Icicle;
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::Icicle::Domain;
10 use Chart::Plotly::Trace::Icicle::Hoverlabel;
11 use Chart::Plotly::Trace::Icicle::Insidetextfont;
12 use Chart::Plotly::Trace::Icicle::Leaf;
13 use Chart::Plotly::Trace::Icicle::Legendgrouptitle;
14 use Chart::Plotly::Trace::Icicle::Marker;
15 use Chart::Plotly::Trace::Icicle::Outsidetextfont;
16 use Chart::Plotly::Trace::Icicle::Pathbar;
17 use Chart::Plotly::Trace::Icicle::Root;
18 use Chart::Plotly::Trace::Icicle::Stream;
19 use Chart::Plotly::Trace::Icicle::Textfont;
20 use Chart::Plotly::Trace::Icicle::Tiling;
21 use Chart::Plotly::Trace::Icicle::Transform;
22  
23 our $VERSION = '0.042'; # VERSION
24  
25 # ABSTRACT: Visualize hierarchal data from leaves (and/or outer branches) towards root with rectangles. The icicle sectors are determined by the entries in *labels* or *ids* and in *parents*.
26  
27 sub TO_JSON {
28 my $self = shift;
29 my $extra_args = $self->extra_args // {};
30 my $meta = $self->meta;
31 my %hash = %$self;
32 for my $name ( sort keys %hash ) {
33 my $attr = $meta->get_attribute($name);
34 if ( defined $attr ) {
35 my $value = $hash{$name};
36 my $type = $attr->type_constraint;
37 if ( $type && $type->equals('Bool') ) {
38 $hash{$name} = $value ? \1 : \0;
39 }
40 }
41 }
42 my $plotly_meta = delete $hash{'pmeta'};
43 if ( defined $plotly_meta ) {
44 $hash{'meta'} = $plotly_meta;
45 }
46 %hash = ( %hash, %$extra_args );
47 delete $hash{'extra_args'};
48 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
49 $hash{type} = $self->type();
50 }
51 return \%hash;
52 }
53  
54 sub type {
55 my @components = split( /::/, __PACKAGE__ );
56 return lc( $components[-1] );
57 }
58  
59 has branchvalues => (
60 is => "rw",
61 isa => enum( [ "remainder", "total" ] ),
62 documentation =>
63 "Determines how the items in `values` are summed. When set to *total*, items in `values` are taken to be value of all its descendants. When set to *remainder*, items in `values` corresponding to the root and the branches sectors are taken to be the extra part not part of the sum of the values at their leaves.",
64 );
65  
66 has count => (
67 is => "rw",
68 isa => "Str",
69 documentation =>
70 "Determines default for `values` when it is not provided, by inferring a 1 for each of the *leaves* and/or *branches*, otherwise 0.",
71 );
72  
73 has customdata => (
74 is => "rw",
75 isa => "ArrayRef|PDL",
76 documentation =>
77 "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",
78 );
79  
80 has customdatasrc => ( is => "rw",
81 isa => "Str",
82 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
83 );
84  
85 has domain => ( is => "rw",
86 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Domain", );
87  
88 has hoverinfo => (
89 is => "rw",
90 isa => "Str|ArrayRef[Str]",
91 documentation =>
92 "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.",
93 );
94  
95 has hoverinfosrc => ( is => "rw",
96 isa => "Str",
97 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
98 );
99  
100 has hoverlabel => ( is => "rw",
101 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Hoverlabel", );
102  
103 has hovertemplate => (
104 is => "rw",
105 isa => "Str|ArrayRef[Str]",
106 documentation =>
107 "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 `currentPath`, `root`, `entry`, `percentRoot`, `percentEntry` and `percentParent`. 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>`.",
108 );
109  
110 has hovertemplatesrc => ( is => "rw",
111 isa => "Str",
112 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
113 );
114  
115 has hovertext => (
116 is => "rw",
117 isa => "Str|ArrayRef[Str]",
118 documentation =>
119 "Sets hover text elements associated with each sector. If a single string, the same string appears for all data points. If an array of string, the items are mapped in order of this trace's sectors. To be seen, trace `hoverinfo` must contain a *text* flag.",
120 );
121  
122 has hovertextsrc => ( is => "rw",
123 isa => "Str",
124 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
125 );
126  
127 has ids => (
128 is => "rw",
129 isa => "ArrayRef|PDL",
130 documentation =>
131 "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.",
132 );
133  
134 has idssrc => ( is => "rw",
135 isa => "Str",
136 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
137 );
138  
139 has insidetextfont => ( is => "rw",
140 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Insidetextfont", );
141  
142 has labels => ( is => "rw",
143 isa => "ArrayRef|PDL",
144 documentation => "Sets the labels of each of the sectors.",
145 );
146  
147 has labelssrc => ( is => "rw",
148 isa => "Str",
149 documentation => "Sets the source reference on Chart Studio Cloud for `labels`.",
150 );
151  
152 has leaf => ( is => "rw",
153 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Leaf", );
154  
155 has legendgrouptitle => ( is => "rw",
156 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Legendgrouptitle", );
157  
158 has legendrank => (
159 is => "rw",
160 isa => "Num",
161 documentation =>
162 "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.",
163 );
164  
165 has level => (
166 is => "rw",
167 isa => "Any",
168 documentation =>
169 "Sets the level from which this trace hierarchy is rendered. Set `level` to `''` to start from the root node in the hierarchy. Must be an \"id\" if `ids` is filled in, otherwise plotly attempts to find a matching item in `labels`.",
170 );
171  
172 has marker => ( is => "rw",
173 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Marker", );
174  
175 has maxdepth => (
176 is => "rw",
177 isa => "Int",
178 documentation =>
179 "Sets the number of rendered sectors from any given `level`. Set `maxdepth` to *-1* to render all the levels in the hierarchy.",
180 );
181  
182 has pmeta => (
183 is => "rw",
184 isa => "Any|ArrayRef[Any]",
185 documentation =>
186 "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.",
187 );
188  
189 has metasrc => ( is => "rw",
190 isa => "Str",
191 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
192 );
193  
194 has name => ( is => "rw",
195 isa => "Str",
196 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
197 );
198  
199 has opacity => ( is => "rw",
200 isa => "Num",
201 documentation => "Sets the opacity of the trace.",
202 );
203  
204 has outsidetextfont => ( is => "rw",
205 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Outsidetextfont", );
206  
207 has parents => (
208 is => "rw",
209 isa => "ArrayRef|PDL",
210 documentation =>
211 "Sets the parent sectors for each of the sectors. Empty string items '' are understood to reference the root node in the hierarchy. If `ids` is filled, `parents` items are understood to be \"ids\" themselves. When `ids` is not set, plotly attempts to find matching items in `labels`, but beware they must be unique.",
212 );
213  
214 has parentssrc => ( is => "rw",
215 isa => "Str",
216 documentation => "Sets the source reference on Chart Studio Cloud for `parents`.",
217 );
218  
219 has pathbar => ( is => "rw",
220 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Pathbar", );
221  
222 has root => ( is => "rw",
223 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Root", );
224  
225 has sort => ( is => "rw",
226 isa => "Bool",
227 documentation => "Determines whether or not the sectors are reordered from largest to smallest.",
228 );
229  
230 has stream => ( is => "rw",
231 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Stream", );
232  
233 has text => (
234 is => "rw",
235 isa => "ArrayRef|PDL",
236 documentation =>
237 "Sets text elements associated with each sector. If trace `textinfo` contains a *text* flag, these elements will be seen on the chart. If trace `hoverinfo` contains a *text* flag and *hovertext* is not set, these elements will be seen in the hover labels.",
238 );
239  
240 has textfont => ( is => "rw",
241 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Textfont", );
242  
243 has textinfo => ( is => "rw",
244 isa => "Str",
245 documentation => "Determines which trace information appear on the graph.",
246 );
247  
248 has textposition => ( is => "rw",
249 isa => enum(
250 [ "top left",
251 "top center",
252 "top right",
253 "middle left",
254 "middle center",
255 "middle right",
256 "bottom left",
257 "bottom center",
258 "bottom right"
259 ]
260 ),
261 documentation => "Sets the positions of the `text` elements.",
262 );
263  
264 has textsrc => ( is => "rw",
265 isa => "Str",
266 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
267 );
268  
269 has texttemplate => (
270 is => "rw",
271 isa => "Str|ArrayRef[Str]",
272 documentation =>
273 "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 `currentPath`, `root`, `entry`, `percentRoot`, `percentEntry`, `percentParent`, `label` and `value`.",
274 );
275  
276 has texttemplatesrc => ( is => "rw",
277 isa => "Str",
278 documentation => "Sets the source reference on Chart Studio Cloud for `texttemplate`.",
279 );
280  
281 has tiling => ( is => "rw",
282 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Icicle::Tiling", );
283  
284 has transforms => ( is => "rw",
285 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Icicle::Transform]", );
286  
287 has uid => (
288 is => "rw",
289 isa => "Str",
290 documentation =>
291 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
292 );
293  
294 has uirevision => (
295 is => "rw",
296 isa => "Any",
297 documentation =>
298 "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.",
299 );
300  
301 has values => (
302 is => "rw",
303 isa => "ArrayRef|PDL",
304 documentation =>
305 "Sets the values associated with each of the sectors. Use with `branchvalues` to determine how the values are summed.",
306 );
307  
308 has valuessrc => ( is => "rw",
309 isa => "Str",
310 documentation => "Sets the source reference on Chart Studio Cloud for `values`.",
311 );
312  
313 has visible => (
314 is => "rw",
315 documentation =>
316 "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).",
317 );
318  
319 __PACKAGE__->meta->make_immutable();
320 1;
321  
322 __END__