Chart/Plotly/Trace/Treemap.pm untested

filter: Statementstmt 0.0% 0 / 122 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 / 166 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::Treemap;
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::Treemap::Domain;
10 use Chart::Plotly::Trace::Treemap::Hoverlabel;
11 use Chart::Plotly::Trace::Treemap::Insidetextfont;
12 use Chart::Plotly::Trace::Treemap::Legendgrouptitle;
13 use Chart::Plotly::Trace::Treemap::Marker;
14 use Chart::Plotly::Trace::Treemap::Outsidetextfont;
15 use Chart::Plotly::Trace::Treemap::Pathbar;
16 use Chart::Plotly::Trace::Treemap::Root;
17 use Chart::Plotly::Trace::Treemap::Stream;
18 use Chart::Plotly::Trace::Treemap::Textfont;
19 use Chart::Plotly::Trace::Treemap::Tiling;
20 use Chart::Plotly::Trace::Treemap::Transform;
21  
22 our $VERSION = '0.042'; # VERSION
23  
24 # ABSTRACT: Visualize hierarchal data from leaves (and/or outer branches) towards root with rectangles. The treemap sectors are determined by the entries in *labels* or *ids* and in *parents*.
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 branchvalues => (
59 is => "rw",
60 isa => enum( [ "remainder", "total" ] ),
61 documentation =>
62 "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.",
63 );
64  
65 has count => (
66 is => "rw",
67 isa => "Str",
68 documentation =>
69 "Determines default for `values` when it is not provided, by inferring a 1 for each of the *leaves* and/or *branches*, otherwise 0.",
70 );
71  
72 has customdata => (
73 is => "rw",
74 isa => "ArrayRef|PDL",
75 documentation =>
76 "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",
77 );
78  
79 has customdatasrc => ( is => "rw",
80 isa => "Str",
81 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
82 );
83  
84 has domain => ( is => "rw",
85 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Domain", );
86  
87 has hoverinfo => (
88 is => "rw",
89 isa => "Str|ArrayRef[Str]",
90 documentation =>
91 "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.",
92 );
93  
94 has hoverinfosrc => ( is => "rw",
95 isa => "Str",
96 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
97 );
98  
99 has hoverlabel => ( is => "rw",
100 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Hoverlabel", );
101  
102 has hovertemplate => (
103 is => "rw",
104 isa => "Str|ArrayRef[Str]",
105 documentation =>
106 "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>`.",
107 );
108  
109 has hovertemplatesrc => ( is => "rw",
110 isa => "Str",
111 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
112 );
113  
114 has hovertext => (
115 is => "rw",
116 isa => "Str|ArrayRef[Str]",
117 documentation =>
118 "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.",
119 );
120  
121 has hovertextsrc => ( is => "rw",
122 isa => "Str",
123 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
124 );
125  
126 has ids => (
127 is => "rw",
128 isa => "ArrayRef|PDL",
129 documentation =>
130 "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.",
131 );
132  
133 has idssrc => ( is => "rw",
134 isa => "Str",
135 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
136 );
137  
138 has insidetextfont => ( is => "rw",
139 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Insidetextfont", );
140  
141 has labels => ( is => "rw",
142 isa => "ArrayRef|PDL",
143 documentation => "Sets the labels of each of the sectors.",
144 );
145  
146 has labelssrc => ( is => "rw",
147 isa => "Str",
148 documentation => "Sets the source reference on Chart Studio Cloud for `labels`.",
149 );
150  
151 has legendgrouptitle => ( is => "rw",
152 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Legendgrouptitle", );
153  
154 has legendrank => (
155 is => "rw",
156 isa => "Num",
157 documentation =>
158 "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.",
159 );
160  
161 has level => (
162 is => "rw",
163 isa => "Any",
164 documentation =>
165 "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`.",
166 );
167  
168 has marker => ( is => "rw",
169 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Marker", );
170  
171 has maxdepth => (
172 is => "rw",
173 isa => "Int",
174 documentation =>
175 "Sets the number of rendered sectors from any given `level`. Set `maxdepth` to *-1* to render all the levels in the hierarchy.",
176 );
177  
178 has pmeta => (
179 is => "rw",
180 isa => "Any|ArrayRef[Any]",
181 documentation =>
182 "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.",
183 );
184  
185 has metasrc => ( is => "rw",
186 isa => "Str",
187 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
188 );
189  
190 has name => ( is => "rw",
191 isa => "Str",
192 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
193 );
194  
195 has opacity => ( is => "rw",
196 isa => "Num",
197 documentation => "Sets the opacity of the trace.",
198 );
199  
200 has outsidetextfont => ( is => "rw",
201 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Outsidetextfont", );
202  
203 has parents => (
204 is => "rw",
205 isa => "ArrayRef|PDL",
206 documentation =>
207 "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.",
208 );
209  
210 has parentssrc => ( is => "rw",
211 isa => "Str",
212 documentation => "Sets the source reference on Chart Studio Cloud for `parents`.",
213 );
214  
215 has pathbar => ( is => "rw",
216 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Pathbar", );
217  
218 has root => ( is => "rw",
219 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Root", );
220  
221 has sort => ( is => "rw",
222 isa => "Bool",
223 documentation => "Determines whether or not the sectors are reordered from largest to smallest.",
224 );
225  
226 has stream => ( is => "rw",
227 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Stream", );
228  
229 has text => (
230 is => "rw",
231 isa => "ArrayRef|PDL",
232 documentation =>
233 "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.",
234 );
235  
236 has textfont => ( is => "rw",
237 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Textfont", );
238  
239 has textinfo => ( is => "rw",
240 isa => "Str",
241 documentation => "Determines which trace information appear on the graph.",
242 );
243  
244 has textposition => ( is => "rw",
245 isa => enum(
246 [ "top left",
247 "top center",
248 "top right",
249 "middle left",
250 "middle center",
251 "middle right",
252 "bottom left",
253 "bottom center",
254 "bottom right"
255 ]
256 ),
257 documentation => "Sets the positions of the `text` elements.",
258 );
259  
260 has textsrc => ( is => "rw",
261 isa => "Str",
262 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
263 );
264  
265 has texttemplate => (
266 is => "rw",
267 isa => "Str|ArrayRef[Str]",
268 documentation =>
269 "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`.",
270 );
271  
272 has texttemplatesrc => ( is => "rw",
273 isa => "Str",
274 documentation => "Sets the source reference on Chart Studio Cloud for `texttemplate`.",
275 );
276  
277 has tiling => ( is => "rw",
278 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Treemap::Tiling", );
279  
280 has transforms => ( is => "rw",
281 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Treemap::Transform]", );
282  
283 has uid => (
284 is => "rw",
285 isa => "Str",
286 documentation =>
287 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
288 );
289  
290 has uirevision => (
291 is => "rw",
292 isa => "Any",
293 documentation =>
294 "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.",
295 );
296  
297 has values => (
298 is => "rw",
299 isa => "ArrayRef|PDL",
300 documentation =>
301 "Sets the values associated with each of the sectors. Use with `branchvalues` to determine how the values are summed.",
302 );
303  
304 has valuessrc => ( is => "rw",
305 isa => "Str",
306 documentation => "Sets the source reference on Chart Studio Cloud for `values`.",
307 );
308  
309 has visible => (
310 is => "rw",
311 documentation =>
312 "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).",
313 );
314  
315 __PACKAGE__->meta->make_immutable();
316 1;
317  
318 __END__