Chart/Plotly/Trace/Violin.pm untested

filter: Statementstmt 0.0% 0 / 134 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 / 176 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::Violin;
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::Violin::Box;
10 use Chart::Plotly::Trace::Violin::Hoverlabel;
11 use Chart::Plotly::Trace::Violin::Legendgrouptitle;
12 use Chart::Plotly::Trace::Violin::Line;
13 use Chart::Plotly::Trace::Violin::Marker;
14 use Chart::Plotly::Trace::Violin::Meanline;
15 use Chart::Plotly::Trace::Violin::Selected;
16 use Chart::Plotly::Trace::Violin::Stream;
17 use Chart::Plotly::Trace::Violin::Transform;
18 use Chart::Plotly::Trace::Violin::Unselected;
19  
20 our $VERSION = '0.042'; # VERSION
21  
22 # ABSTRACT: In vertical (horizontal) violin plots, statistics are computed using `y` (`x`) values. By supplying an `x` (`y`) array, one violin per distinct x (y) value is drawn If no `x` (`y`) {array} is provided, a single violin is drawn. That violin position is then positioned with with `name` or with `x0` (`y0`) if provided.
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 alignmentgroup => (
57 is => "rw",
58 isa => "Str",
59 documentation =>
60 "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.",
61 );
62  
63 has bandwidth => (
64 is => "rw",
65 isa => "Num",
66 documentation =>
67 "Sets the bandwidth used to compute the kernel density estimate. By default, the bandwidth is determined by Silverman's rule of thumb.",
68 );
69  
70 has box => ( is => "rw",
71 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Box", );
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 fillcolor => (
86 is => "rw",
87 isa => "Str",
88 documentation =>
89 "Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.",
90 );
91  
92 has hoverinfo => (
93 is => "rw",
94 isa => "Str|ArrayRef[Str]",
95 documentation =>
96 "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.",
97 );
98  
99 has hoverinfosrc => ( is => "rw",
100 isa => "Str",
101 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
102 );
103  
104 has hoverlabel => ( is => "rw",
105 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Hoverlabel", );
106  
107 has hoveron => (
108 is => "rw",
109 isa => "Str",
110 documentation =>
111 "Do the hover effects highlight individual violins or sample points or the kernel density estimate or any combination of them?",
112 );
113  
114 has hovertemplate => (
115 is => "rw",
116 isa => "Str|ArrayRef[Str]",
117 documentation =>
118 "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. 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>`.",
119 );
120  
121 has hovertemplatesrc => ( is => "rw",
122 isa => "Str",
123 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
124 );
125  
126 has hovertext => ( is => "rw",
127 isa => "Str|ArrayRef[Str]",
128 documentation => "Same as `text`.",
129 );
130  
131 has hovertextsrc => ( is => "rw",
132 isa => "Str",
133 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
134 );
135  
136 has ids => (
137 is => "rw",
138 isa => "ArrayRef|PDL",
139 documentation =>
140 "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.",
141 );
142  
143 has idssrc => ( is => "rw",
144 isa => "Str",
145 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
146 );
147  
148 has jitter => (
149 is => "rw",
150 isa => "Num",
151 documentation =>
152 "Sets the amount of jitter in the sample points drawn. If *0*, the sample points align along the distribution axis. If *1*, the sample points are drawn in a random jitter of width equal to the width of the violins.",
153 );
154  
155 has legendgroup => (
156 is => "rw",
157 isa => "Str",
158 documentation =>
159 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
160 );
161  
162 has legendgrouptitle => ( is => "rw",
163 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Legendgrouptitle", );
164  
165 has legendrank => (
166 is => "rw",
167 isa => "Num",
168 documentation =>
169 "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.",
170 );
171  
172 has line => ( is => "rw",
173 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Line", );
174  
175 has marker => ( is => "rw",
176 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Marker", );
177  
178 has meanline => ( is => "rw",
179 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Meanline", );
180  
181 has pmeta => (
182 is => "rw",
183 isa => "Any|ArrayRef[Any]",
184 documentation =>
185 "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.",
186 );
187  
188 has metasrc => ( is => "rw",
189 isa => "Str",
190 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
191 );
192  
193 has name => (
194 is => "rw",
195 isa => "Str",
196 documentation =>
197 "Sets the trace name. The trace name appear as the legend item and on hover. For violin traces, the name will also be used for the position coordinate, if `x` and `x0` (`y` and `y0` if horizontal) are missing and the position axis is categorical. Note that the trace name is also used as a default value for attribute `scalegroup` (please see its description for details).",
198 );
199  
200 has offsetgroup => (
201 is => "rw",
202 isa => "Str",
203 documentation =>
204 "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.",
205 );
206  
207 has opacity => ( is => "rw",
208 isa => "Num",
209 documentation => "Sets the opacity of the trace.",
210 );
211  
212 has orientation => (
213 is => "rw",
214 isa => enum( [ "v", "h" ] ),
215 documentation =>
216 "Sets the orientation of the violin(s). If *v* (*h*), the distribution is visualized along the vertical (horizontal).",
217 );
218  
219 has pointpos => (
220 is => "rw",
221 isa => "Num",
222 documentation =>
223 "Sets the position of the sample points in relation to the violins. If *0*, the sample points are places over the center of the violins. Positive (negative) values correspond to positions to the right (left) for vertical violins and above (below) for horizontal violins.",
224 );
225  
226 has points => (
227 is => "rw",
228 documentation =>
229 "If *outliers*, only the sample points lying outside the whiskers are shown If *suspectedoutliers*, the outlier points are shown and points either less than 4*Q1-3*Q3 or greater than 4*Q3-3*Q1 are highlighted (see `outliercolor`) If *all*, all sample points are shown If *false*, only the violins are shown with no sample points. Defaults to *suspectedoutliers* when `marker.outliercolor` or `marker.line.outliercolor` is set, otherwise defaults to *outliers*.",
230 );
231  
232 has quartilemethod => (
233 is => "rw",
234 isa => enum( [ "linear", "exclusive", "inclusive" ] ),
235 documentation =>
236 "Sets the method used to compute the sample's Q1 and Q3 quartiles. The *linear* method uses the 25th percentile for Q1 and 75th percentile for Q3 as computed using method #10 (listed on http://jse.amstat.org/v14n3/langford.html). The *exclusive* method uses the median to divide the ordered dataset into two halves if the sample is odd, it does not include the median in either half - Q1 is then the median of the lower half and Q3 the median of the upper half. The *inclusive* method also uses the median to divide the ordered dataset into two halves but if the sample is odd, it includes the median in both halves - Q1 is then the median of the lower half and Q3 the median of the upper half.",
237 );
238  
239 has scalegroup => (
240 is => "rw",
241 isa => "Str",
242 documentation =>
243 "If there are multiple violins that should be sized according to to some metric (see `scalemode`), link them by providing a non-empty group id here shared by every trace in the same group. If a violin's `width` is undefined, `scalegroup` will default to the trace's name. In this case, violins with the same names will be linked together",
244 );
245  
246 has scalemode => (
247 is => "rw",
248 isa => enum( [ "width", "count" ] ),
249 documentation =>
250 "Sets the metric by which the width of each violin is determined. *width* means each violin has the same (max) width *count* means the violins are scaled by the number of sample points making up each violin.",
251 );
252  
253 has selected => ( is => "rw",
254 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Selected", );
255  
256 has selectedpoints => (
257 is => "rw",
258 isa => "Any",
259 documentation =>
260 "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.",
261 );
262  
263 has showlegend => (
264 is => "rw",
265 isa => "Bool",
266 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
267 );
268  
269 has side => (
270 is => "rw",
271 isa => enum( [ "both", "positive", "negative" ] ),
272 documentation =>
273 "Determines on which side of the position value the density function making up one half of a violin is plotted. Useful when comparing two violin traces under *overlay* mode, where one trace has `side` set to *positive* and the other to *negative*.",
274 );
275  
276 has span => (
277 is => "rw",
278 isa => "ArrayRef|PDL",
279 documentation =>
280 "Sets the span in data space for which the density function will be computed. Has an effect only when `spanmode` is set to *manual*.",
281 );
282  
283 has spanmode => (
284 is => "rw",
285 isa => enum( [ "soft", "hard", "manual" ] ),
286 documentation =>
287 "Sets the method by which the span in data space where the density function will be computed. *soft* means the span goes from the sample's minimum value minus two bandwidths to the sample's maximum value plus two bandwidths. *hard* means the span goes from the sample's minimum to its maximum value. For custom span settings, use mode *manual* and fill in the `span` attribute.",
288 );
289  
290 has stream => ( is => "rw",
291 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Stream", );
292  
293 has text => (
294 is => "rw",
295 isa => "Str|ArrayRef[Str]",
296 documentation =>
297 "Sets the text elements associated with each sample value. 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.",
298 );
299  
300 has textsrc => ( is => "rw",
301 isa => "Str",
302 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
303 );
304  
305 has transforms => ( is => "rw",
306 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Violin::Transform]", );
307  
308 has uid => (
309 is => "rw",
310 isa => "Str",
311 documentation =>
312 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
313 );
314  
315 has uirevision => (
316 is => "rw",
317 isa => "Any",
318 documentation =>
319 "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.",
320 );
321  
322 has unselected => ( is => "rw",
323 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Violin::Unselected", );
324  
325 has visible => (
326 is => "rw",
327 documentation =>
328 "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).",
329 );
330  
331 has width => (
332 is => "rw",
333 isa => "Num",
334 documentation =>
335 "Sets the width of the violin in data coordinates. If *0* (default value) the width is automatically selected based on the positions of other violin traces in the same subplot.",
336 );
337  
338 has x => ( is => "rw",
339 isa => "ArrayRef|PDL",
340 documentation => "Sets the x sample data or coordinates. See overview for more info.",
341 );
342  
343 has x0 => (
344 is => "rw",
345 isa => "Any",
346 documentation =>
347 "Sets the x coordinate for single-box traces or the starting coordinate for multi-box traces set using q1/median/q3. See overview for more info.",
348 );
349  
350 has xaxis => (
351 is => "rw",
352 documentation =>
353 "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.",
354 );
355  
356 has xhoverformat => (
357 is => "rw",
358 isa => "Str",
359 documentation =>
360 "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`.",
361 );
362  
363 has xsrc => ( is => "rw",
364 isa => "Str",
365 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
366 );
367  
368 has y => ( is => "rw",
369 isa => "ArrayRef|PDL",
370 documentation => "Sets the y sample data or coordinates. See overview for more info.",
371 );
372  
373 has y0 => (
374 is => "rw",
375 isa => "Any",
376 documentation =>
377 "Sets the y coordinate for single-box traces or the starting coordinate for multi-box traces set using q1/median/q3. See overview for more info.",
378 );
379  
380 has yaxis => (
381 is => "rw",
382 documentation =>
383 "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.",
384 );
385  
386 has yhoverformat => (
387 is => "rw",
388 isa => "Str",
389 documentation =>
390 "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`.",
391 );
392  
393 has ysrc => ( is => "rw",
394 isa => "Str",
395 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
396 );
397  
398 __PACKAGE__->meta->make_immutable();
399 1;
400  
401 __END__