Chart/Plotly/Trace/Histogram.pm untested

filter: Statementstmt 0.0% 0 / 160 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 20 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 207 CC 6 SCAR 24.5
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 11.6
1 package Chart::Plotly::Trace::Histogram;
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::Histogram::Cumulative;
10 use Chart::Plotly::Trace::Histogram::Error_x;
11 use Chart::Plotly::Trace::Histogram::Error_y;
12 use Chart::Plotly::Trace::Histogram::Hoverlabel;
13 use Chart::Plotly::Trace::Histogram::Insidetextfont;
14 use Chart::Plotly::Trace::Histogram::Legendgrouptitle;
15 use Chart::Plotly::Trace::Histogram::Marker;
16 use Chart::Plotly::Trace::Histogram::Outsidetextfont;
17 use Chart::Plotly::Trace::Histogram::Selected;
18 use Chart::Plotly::Trace::Histogram::Stream;
19 use Chart::Plotly::Trace::Histogram::Textfont;
20 use Chart::Plotly::Trace::Histogram::Transform;
21 use Chart::Plotly::Trace::Histogram::Unselected;
22 use Chart::Plotly::Trace::Histogram::Xbins;
23 use Chart::Plotly::Trace::Histogram::Ybins;
24  
25 our $VERSION = '0.042'; # VERSION
26  
27 # ABSTRACT: The sample data from which statistics are computed is set in `x` for vertically spanning histograms and in `y` for horizontally spanning histograms. Binning options are set `xbins` and `ybins` respectively if no aggregation data is provided.
28  
29 sub TO_JSON {
30 my $self = shift;
31 my $extra_args = $self->extra_args // {};
32 my $meta = $self->meta;
33 my %hash = %$self;
34 for my $name ( sort keys %hash ) {
35 my $attr = $meta->get_attribute($name);
36 if ( defined $attr ) {
37 my $value = $hash{$name};
38 my $type = $attr->type_constraint;
39 if ( $type && $type->equals('Bool') ) {
40 $hash{$name} = $value ? \1 : \0;
41 }
42 }
43 }
44 my $plotly_meta = delete $hash{'pmeta'};
45 if ( defined $plotly_meta ) {
46 $hash{'meta'} = $plotly_meta;
47 }
48 %hash = ( %hash, %$extra_args );
49 delete $hash{'extra_args'};
50 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
51 $hash{type} = $self->type();
52 }
53 return \%hash;
54 }
55  
56 sub type {
57 my @components = split( /::/, __PACKAGE__ );
58 return lc( $components[-1] );
59 }
60  
61 has alignmentgroup => (
62 is => "rw",
63 isa => "Str",
64 documentation =>
65 "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.",
66 );
67  
68 has autobinx => (
69 is => "rw",
70 isa => "Bool",
71 documentation =>
72 "Obsolete: since v1.42 each bin attribute is auto-determined separately and `autobinx` is not needed. However, we accept `autobinx: true` or `false` and will update `xbins` accordingly before deleting `autobinx` from the trace.",
73 );
74  
75 has autobiny => (
76 is => "rw",
77 isa => "Bool",
78 documentation =>
79 "Obsolete: since v1.42 each bin attribute is auto-determined separately and `autobiny` is not needed. However, we accept `autobiny: true` or `false` and will update `ybins` accordingly before deleting `autobiny` from the trace.",
80 );
81  
82 has bingroup => (
83 is => "rw",
84 isa => "Str",
85 documentation =>
86 "Set a group of histogram traces which will have compatible bin settings. Note that traces on the same subplot and with the same *orientation* under `barmode` *stack*, *relative* and *group* are forced into the same bingroup, Using `bingroup`, traces under `barmode` *overlay* and on different axes (of the same axis type) can have compatible bin settings. Note that histogram and histogram2d* trace can share the same `bingroup`",
87 );
88  
89 has cliponaxis => (
90 is => "rw",
91 isa => "Bool",
92 documentation =>
93 "Determines whether the text nodes are clipped about the subplot axes. To show the text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
94 );
95  
96 has constraintext => (
97 is => "rw",
98 isa => enum( [ "inside", "outside", "both", "none" ] ),
99 documentation => "Constrain the size of text inside or outside a bar to be no larger than the bar itself.",
100 );
101  
102 has cumulative => ( is => "rw",
103 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Cumulative", );
104  
105 has customdata => (
106 is => "rw",
107 isa => "ArrayRef|PDL",
108 documentation =>
109 "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",
110 );
111  
112 has customdatasrc => ( is => "rw",
113 isa => "Str",
114 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
115 );
116  
117 has error_x => ( is => "rw",
118 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Error_x", );
119  
120 has error_y => ( is => "rw",
121 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Error_y", );
122  
123 has histfunc => (
124 is => "rw",
125 isa => enum( [ "count", "sum", "avg", "min", "max" ] ),
126 documentation =>
127 "Specifies the binning function used for this histogram trace. If *count*, the histogram values are computed by counting the number of values lying inside each bin. If *sum*, *avg*, *min*, *max*, the histogram values are computed using the sum, the average, the minimum or the maximum of the values lying inside each bin respectively.",
128 );
129  
130 has histnorm => (
131 is => "rw",
132 isa => enum( [ "", "percent", "probability", "density", "probability density" ] ),
133 documentation =>
134 "Specifies the type of normalization used for this histogram trace. If **, the span of each bar corresponds to the number of occurrences (i.e. the number of data points lying inside the bins). If *percent* / *probability*, the span of each bar corresponds to the percentage / fraction of occurrences with respect to the total number of sample points (here, the sum of all bin HEIGHTS equals 100% / 1). If *density*, the span of each bar corresponds to the number of occurrences in a bin divided by the size of the bin interval (here, the sum of all bin AREAS equals the total number of sample points). If *probability density*, the area of each bar corresponds to the probability that an event will fall into the corresponding bin (here, the sum of all bin AREAS equals 1).",
135 );
136  
137 has hoverinfo => (
138 is => "rw",
139 isa => "Str|ArrayRef[Str]",
140 documentation =>
141 "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.",
142 );
143  
144 has hoverinfosrc => ( is => "rw",
145 isa => "Str",
146 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
147 );
148  
149 has hoverlabel => ( is => "rw",
150 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Hoverlabel", );
151  
152 has hovertemplate => (
153 is => "rw",
154 isa => "Str|ArrayRef[Str]",
155 documentation =>
156 "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. variable `binNumber` 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>`.",
157 );
158  
159 has hovertemplatesrc => ( is => "rw",
160 isa => "Str",
161 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
162 );
163  
164 has hovertext => ( is => "rw",
165 isa => "Str|ArrayRef[Str]",
166 documentation => "Same as `text`.",
167 );
168  
169 has hovertextsrc => ( is => "rw",
170 isa => "Str",
171 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
172 );
173  
174 has ids => (
175 is => "rw",
176 isa => "ArrayRef|PDL",
177 documentation =>
178 "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.",
179 );
180  
181 has idssrc => ( is => "rw",
182 isa => "Str",
183 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
184 );
185  
186 has insidetextanchor => (
187 is => "rw",
188 isa => enum( [ "end", "middle", "start" ] ),
189 documentation => "Determines if texts are kept at center or start/end points in `textposition` *inside* mode.",
190 );
191  
192 has insidetextfont => ( is => "rw",
193 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Insidetextfont", );
194  
195 has legendgroup => (
196 is => "rw",
197 isa => "Str",
198 documentation =>
199 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
200 );
201  
202 has legendgrouptitle => ( is => "rw",
203 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Legendgrouptitle", );
204  
205 has legendrank => (
206 is => "rw",
207 isa => "Num",
208 documentation =>
209 "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.",
210 );
211  
212 has marker => ( is => "rw",
213 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Marker", );
214  
215 has pmeta => (
216 is => "rw",
217 isa => "Any|ArrayRef[Any]",
218 documentation =>
219 "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.",
220 );
221  
222 has metasrc => ( is => "rw",
223 isa => "Str",
224 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
225 );
226  
227 has name => ( is => "rw",
228 isa => "Str",
229 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
230 );
231  
232 has nbinsx => (
233 is => "rw",
234 isa => "Int",
235 documentation =>
236 "Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `xbins.size` is provided.",
237 );
238  
239 has nbinsy => (
240 is => "rw",
241 isa => "Int",
242 documentation =>
243 "Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `ybins.size` is provided.",
244 );
245  
246 has offsetgroup => (
247 is => "rw",
248 isa => "Str",
249 documentation =>
250 "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.",
251 );
252  
253 has opacity => ( is => "rw",
254 isa => "Num",
255 documentation => "Sets the opacity of the trace.",
256 );
257  
258 has orientation => (
259 is => "rw",
260 isa => enum( [ "v", "h" ] ),
261 documentation =>
262 "Sets the orientation of the bars. With *v* (*h*), the value of the each bar spans along the vertical (horizontal).",
263 );
264  
265 has outsidetextfont => ( is => "rw",
266 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Outsidetextfont", );
267  
268 has selected => ( is => "rw",
269 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Selected", );
270  
271 has selectedpoints => (
272 is => "rw",
273 isa => "Any",
274 documentation =>
275 "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.",
276 );
277  
278 has showlegend => (
279 is => "rw",
280 isa => "Bool",
281 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
282 );
283  
284 has stream => ( is => "rw",
285 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Stream", );
286  
287 has text => (
288 is => "rw",
289 isa => "Str|ArrayRef[Str]",
290 documentation =>
291 "Sets hover text elements associated with each bar. If a single string, the same string appears over all bars. If an array of string, the items are mapped in order to the this trace's coordinates.",
292 );
293  
294 has textangle => (
295 is => "rw",
296 documentation =>
297 "Sets the angle of the tick labels with respect to the bar. For example, a `tickangle` of -90 draws the tick labels vertically. With *auto* the texts may automatically be rotated to fit with the maximum size in bars.",
298 );
299  
300 has textfont => ( is => "rw",
301 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Textfont", );
302  
303 has textposition => (
304 is => "rw",
305 isa => enum( [ "inside", "outside", "auto", "none" ] ),
306 documentation =>
307 "Specifies the location of the `text`. *inside* positions `text` inside, next to the bar end (rotated and scaled if needed). *outside* positions `text` outside, next to the bar end (scaled if needed), unless there is another bar stacked on this one, then the text gets pushed inside. *auto* tries to position `text` inside the bar, but if the bar is too small and no bar is stacked on this one the text is moved outside. If *none*, no text appears.",
308 );
309  
310 has textsrc => ( is => "rw",
311 isa => "Str",
312 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
313 );
314  
315 has texttemplate => (
316 is => "rw",
317 isa => "Str",
318 documentation =>
319 "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` and `value`.",
320 );
321  
322 has transforms => ( is => "rw",
323 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Histogram::Transform]", );
324  
325 has uid => (
326 is => "rw",
327 isa => "Str",
328 documentation =>
329 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
330 );
331  
332 has uirevision => (
333 is => "rw",
334 isa => "Any",
335 documentation =>
336 "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.",
337 );
338  
339 has unselected => ( is => "rw",
340 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Unselected", );
341  
342 has visible => (
343 is => "rw",
344 documentation =>
345 "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).",
346 );
347  
348 has x => ( is => "rw",
349 isa => "ArrayRef|PDL",
350 documentation => "Sets the sample data to be binned on the x axis.",
351 );
352  
353 has xaxis => (
354 is => "rw",
355 documentation =>
356 "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.",
357 );
358  
359 has xbins => ( is => "rw",
360 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Xbins", );
361  
362 has xcalendar => ( is => "rw",
363 isa => enum(
364 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
365 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
366 ]
367 ),
368 documentation => "Sets the calendar system to use with `x` date data.",
369 );
370  
371 has xhoverformat => (
372 is => "rw",
373 isa => "Str",
374 documentation =>
375 "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`.",
376 );
377  
378 has xsrc => ( is => "rw",
379 isa => "Str",
380 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
381 );
382  
383 has y => ( is => "rw",
384 isa => "ArrayRef|PDL",
385 documentation => "Sets the sample data to be binned on the y axis.",
386 );
387  
388 has yaxis => (
389 is => "rw",
390 documentation =>
391 "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.",
392 );
393  
394 has ybins => ( is => "rw",
395 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram::Ybins", );
396  
397 has ycalendar => ( is => "rw",
398 isa => enum(
399 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
400 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
401 ]
402 ),
403 documentation => "Sets the calendar system to use with `y` date data.",
404 );
405  
406 has yhoverformat => (
407 is => "rw",
408 isa => "Str",
409 documentation =>
410 "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`.",
411 );
412  
413 has ysrc => ( is => "rw",
414 isa => "Str",
415 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
416 );
417  
418 __PACKAGE__->meta->make_immutable();
419 1;
420  
421 __END__