Chart/Plotly/Trace/Sunburst.pm untested

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