Chart/Plotly/Trace/Pie.pm untested

filter: Statementstmt 0.0% 0 / 125 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 167 CC 6 SCAR 26.4
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 14.0
1 package Chart::Plotly::Trace::Pie;
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::Pie::Domain;
10 use Chart::Plotly::Trace::Pie::Hoverlabel;
11 use Chart::Plotly::Trace::Pie::Insidetextfont;
12 use Chart::Plotly::Trace::Pie::Legendgrouptitle;
13 use Chart::Plotly::Trace::Pie::Marker;
14 use Chart::Plotly::Trace::Pie::Outsidetextfont;
15 use Chart::Plotly::Trace::Pie::Stream;
16 use Chart::Plotly::Trace::Pie::Textfont;
17 use Chart::Plotly::Trace::Pie::Title;
18 use Chart::Plotly::Trace::Pie::Transform;
19  
20 our $VERSION = '0.042'; # VERSION
21  
22 # ABSTRACT: A data visualized by the sectors of the pie is set in `values`. The sector labels are set in `labels`. The sector colors are set in `marker.colors`
23  
24 sub TO_JSON {
25 my $self = shift;
26 my $extra_args = $self->extra_args // {};
27 my $meta = $self->meta;
28 my %hash = %$self;
29 for my $name ( sort keys %hash ) {
30 my $attr = $meta->get_attribute($name);
31 if ( defined $attr ) {
32 my $value = $hash{$name};
33 my $type = $attr->type_constraint;
34 if ( $type && $type->equals('Bool') ) {
35 $hash{$name} = $value ? \1 : \0;
36 }
37 }
38 }
39 my $plotly_meta = delete $hash{'pmeta'};
40 if ( defined $plotly_meta ) {
41 $hash{'meta'} = $plotly_meta;
42 }
43 %hash = ( %hash, %$extra_args );
44 delete $hash{'extra_args'};
45 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
46 $hash{type} = $self->type();
47 }
48 return \%hash;
49 }
50  
51 sub type {
52 my @components = split( /::/, __PACKAGE__ );
53 return lc( $components[-1] );
54 }
55  
56 has automargin => ( is => "rw",
57 isa => "Bool",
58 documentation => "Determines whether outside text labels can push the margins.",
59 );
60  
61 has customdata => (
62 is => "rw",
63 isa => "ArrayRef|PDL",
64 documentation =>
65 "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",
66 );
67  
68 has customdatasrc => ( is => "rw",
69 isa => "Str",
70 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
71 );
72  
73 has direction => ( is => "rw",
74 isa => enum( [ "clockwise", "counterclockwise" ] ),
75 documentation => "Specifies the direction at which succeeding sectors follow one another.",
76 );
77  
78 has dlabel => ( is => "rw",
79 isa => "Num",
80 documentation => "Sets the label step. See `label0` for more info.",
81 );
82  
83 has domain => ( is => "rw",
84 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Domain", );
85  
86 has hole => ( is => "rw",
87 isa => "Num",
88 documentation => "Sets the fraction of the radius to cut out of the pie. Use this to make a donut chart.",
89 );
90  
91 has hoverinfo => (
92 is => "rw",
93 isa => "Str|ArrayRef[Str]",
94 documentation =>
95 "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.",
96 );
97  
98 has hoverinfosrc => ( is => "rw",
99 isa => "Str",
100 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
101 );
102  
103 has hoverlabel => ( is => "rw",
104 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Hoverlabel", );
105  
106 has hovertemplate => (
107 is => "rw",
108 isa => "Str|ArrayRef[Str]",
109 documentation =>
110 "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 `label`, `color`, `value`, `percent` and `text`. 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>`.",
111 );
112  
113 has hovertemplatesrc => ( is => "rw",
114 isa => "Str",
115 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
116 );
117  
118 has hovertext => (
119 is => "rw",
120 isa => "Str|ArrayRef[Str]",
121 documentation =>
122 "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.",
123 );
124  
125 has hovertextsrc => ( is => "rw",
126 isa => "Str",
127 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
128 );
129  
130 has ids => (
131 is => "rw",
132 isa => "ArrayRef|PDL",
133 documentation =>
134 "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.",
135 );
136  
137 has idssrc => ( is => "rw",
138 isa => "Str",
139 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
140 );
141  
142 has insidetextfont => ( is => "rw",
143 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Insidetextfont", );
144  
145 has insidetextorientation => (
146 is => "rw",
147 isa => enum( [ "horizontal", "radial", "tangential", "auto" ] ),
148 documentation =>
149 "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.",
150 );
151  
152 has label0 => (
153 is => "rw",
154 isa => "Num",
155 documentation =>
156 "Alternate to `labels`. Builds a numeric set of labels. Use with `dlabel` where `label0` is the starting label and `dlabel` the step.",
157 );
158  
159 has labels => (
160 is => "rw",
161 isa => "ArrayRef|PDL",
162 documentation =>
163 "Sets the sector labels. If `labels` entries are duplicated, we sum associated `values` or simply count occurrences if `values` is not provided. For other array attributes (including color) we use the first non-empty entry among all occurrences of the label.",
164 );
165  
166 has labelssrc => ( is => "rw",
167 isa => "Str",
168 documentation => "Sets the source reference on Chart Studio Cloud for `labels`.",
169 );
170  
171 has legendgroup => (
172 is => "rw",
173 isa => "Str",
174 documentation =>
175 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
176 );
177  
178 has legendgrouptitle => ( is => "rw",
179 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Legendgrouptitle", );
180  
181 has legendrank => (
182 is => "rw",
183 isa => "Num",
184 documentation =>
185 "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.",
186 );
187  
188 has marker => ( is => "rw",
189 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Marker", );
190  
191 has pmeta => (
192 is => "rw",
193 isa => "Any|ArrayRef[Any]",
194 documentation =>
195 "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.",
196 );
197  
198 has metasrc => ( is => "rw",
199 isa => "Str",
200 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
201 );
202  
203 has name => ( is => "rw",
204 isa => "Str",
205 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
206 );
207  
208 has opacity => ( is => "rw",
209 isa => "Num",
210 documentation => "Sets the opacity of the trace.",
211 );
212  
213 has outsidetextfont => ( is => "rw",
214 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Outsidetextfont", );
215  
216 has pull => (
217 is => "rw",
218 isa => "Num|ArrayRef[Num]",
219 documentation =>
220 "Sets the fraction of larger radius to pull the sectors out from the center. This can be a constant to pull all slices apart from each other equally or an array to highlight one or more slices.",
221 );
222  
223 has pullsrc => ( is => "rw",
224 isa => "Str",
225 documentation => "Sets the source reference on Chart Studio Cloud for `pull`.",
226 );
227  
228 has rotation => ( is => "rw",
229 isa => "Num",
230 documentation => "Instead of the first slice starting at 12 o'clock, rotate to some other angle.",
231 );
232  
233 has scalegroup => (
234 is => "rw",
235 isa => "Str",
236 documentation =>
237 "If there are multiple pie charts that should be sized according to their totals, link them by providing a non-empty group id here shared by every trace in the same group.",
238 );
239  
240 has showlegend => (
241 is => "rw",
242 isa => "Bool",
243 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
244 );
245  
246 has sort => ( is => "rw",
247 isa => "Bool",
248 documentation => "Determines whether or not the sectors are reordered from largest to smallest.",
249 );
250  
251 has stream => ( is => "rw",
252 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Stream", );
253  
254 has text => (
255 is => "rw",
256 isa => "ArrayRef|PDL",
257 documentation =>
258 "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.",
259 );
260  
261 has textfont => ( is => "rw",
262 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Textfont", );
263  
264 has textinfo => ( is => "rw",
265 isa => "Str",
266 documentation => "Determines which trace information appear on the graph.",
267 );
268  
269 has textposition => ( is => "rw",
270 isa => union( [ enum( [ "inside", "outside", "auto", "none" ] ), "ArrayRef" ] ),
271 documentation => "Specifies the location of the `textinfo`.",
272 );
273  
274 has textpositionsrc => ( is => "rw",
275 isa => "Str",
276 documentation => "Sets the source reference on Chart Studio Cloud for `textposition`.",
277 );
278  
279 has textsrc => ( is => "rw",
280 isa => "Str",
281 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
282 );
283  
284 has texttemplate => (
285 is => "rw",
286 isa => "Str|ArrayRef[Str]",
287 documentation =>
288 "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 `label`, `color`, `value`, `percent` and `text`.",
289 );
290  
291 has texttemplatesrc => ( is => "rw",
292 isa => "Str",
293 documentation => "Sets the source reference on Chart Studio Cloud for `texttemplate`.",
294 );
295  
296 has title => ( is => "rw",
297 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Pie::Title", );
298  
299 has transforms => ( is => "rw",
300 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Pie::Transform]", );
301  
302 has uid => (
303 is => "rw",
304 isa => "Str",
305 documentation =>
306 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
307 );
308  
309 has uirevision => (
310 is => "rw",
311 isa => "Any",
312 documentation =>
313 "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.",
314 );
315  
316 has values => ( is => "rw",
317 isa => "ArrayRef|PDL",
318 documentation => "Sets the values of the sectors. If omitted, we count occurrences of each label.",
319 );
320  
321 has valuessrc => ( is => "rw",
322 isa => "Str",
323 documentation => "Sets the source reference on Chart Studio Cloud for `values`.",
324 );
325  
326 has visible => (
327 is => "rw",
328 documentation =>
329 "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).",
330 );
331  
332 __PACKAGE__->meta->make_immutable();
333 1;
334  
335 __END__