Chart/Plotly/Trace/Histogram2d.pm untested

filter: Statementstmt 0.0% 0 / 132 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 173 CC 6 SCAR 26.8
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 14.6
1 package Chart::Plotly::Trace::Histogram2d;
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::Histogram2d::Colorbar;
10 use Chart::Plotly::Trace::Histogram2d::Hoverlabel;
11 use Chart::Plotly::Trace::Histogram2d::Legendgrouptitle;
12 use Chart::Plotly::Trace::Histogram2d::Marker;
13 use Chart::Plotly::Trace::Histogram2d::Stream;
14 use Chart::Plotly::Trace::Histogram2d::Textfont;
15 use Chart::Plotly::Trace::Histogram2d::Transform;
16 use Chart::Plotly::Trace::Histogram2d::Xbins;
17 use Chart::Plotly::Trace::Histogram2d::Ybins;
18  
19 our $VERSION = '0.042'; # VERSION
20  
21 # ABSTRACT: The sample data from which statistics are computed is set in `x` and `y` (where `x` and `y` represent marginal distributions, binning is set in `xbins` and `ybins` in this case) or `z` (where `z` represent the 2D distribution and binning set, binning is set by `x` and `y` in this case). The resulting distribution is visualized as a heatmap.
22  
23 sub TO_JSON {
24 my $self = shift;
25 my $extra_args = $self->extra_args // {};
26 my $meta = $self->meta;
27 my %hash = %$self;
28 for my $name ( sort keys %hash ) {
29 my $attr = $meta->get_attribute($name);
30 if ( defined $attr ) {
31 my $value = $hash{$name};
32 my $type = $attr->type_constraint;
33 if ( $type && $type->equals('Bool') ) {
34 $hash{$name} = $value ? \1 : \0;
35 }
36 }
37 }
38 my $plotly_meta = delete $hash{'pmeta'};
39 if ( defined $plotly_meta ) {
40 $hash{'meta'} = $plotly_meta;
41 }
42 %hash = ( %hash, %$extra_args );
43 delete $hash{'extra_args'};
44 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
45 $hash{type} = $self->type();
46 }
47 return \%hash;
48 }
49  
50 sub type {
51 my @components = split( /::/, __PACKAGE__ );
52 return lc( $components[-1] );
53 }
54  
55 has autobinx => (
56 is => "rw",
57 isa => "Bool",
58 documentation =>
59 "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.",
60 );
61  
62 has autobiny => (
63 is => "rw",
64 isa => "Bool",
65 documentation =>
66 "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.",
67 );
68  
69 has autocolorscale => (
70 is => "rw",
71 isa => "Bool",
72 documentation =>
73 "Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.",
74 );
75  
76 has bingroup => (
77 is => "rw",
78 isa => "Str",
79 documentation =>
80 "Set the `xbingroup` and `ybingroup` default prefix For example, setting a `bingroup` of *1* on two histogram2d traces will make them their x-bins and y-bins match separately.",
81 );
82  
83 has coloraxis => (
84 is => "rw",
85 documentation =>
86 "Sets a reference to a shared color axis. References to these shared color axes are *coloraxis*, *coloraxis2*, *coloraxis3*, etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.",
87 );
88  
89 has colorbar => ( is => "rw",
90 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Colorbar", );
91  
92 has colorscale => (
93 is => "rw",
94 documentation =>
95 "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `zmin` and `zmax`. Alternatively, `colorscale` may be a palette name string of the following list: Blackbody,Bluered,Blues,Cividis,Earth,Electric,Greens,Greys,Hot,Jet,Picnic,Portland,Rainbow,RdBu,Reds,Viridis,YlGnBu,YlOrRd.",
96 );
97  
98 has customdata => (
99 is => "rw",
100 isa => "ArrayRef|PDL",
101 documentation =>
102 "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",
103 );
104  
105 has customdatasrc => ( is => "rw",
106 isa => "Str",
107 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
108 );
109  
110 has histfunc => (
111 is => "rw",
112 isa => enum( [ "count", "sum", "avg", "min", "max" ] ),
113 documentation =>
114 "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.",
115 );
116  
117 has histnorm => (
118 is => "rw",
119 isa => enum( [ "", "percent", "probability", "density", "probability density" ] ),
120 documentation =>
121 "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).",
122 );
123  
124 has hoverinfo => (
125 is => "rw",
126 isa => "Str|ArrayRef[Str]",
127 documentation =>
128 "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.",
129 );
130  
131 has hoverinfosrc => ( is => "rw",
132 isa => "Str",
133 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
134 );
135  
136 has hoverlabel => ( is => "rw",
137 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Hoverlabel", );
138  
139 has hovertemplate => (
140 is => "rw",
141 isa => "Str|ArrayRef[Str]",
142 documentation =>
143 "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 `z` 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>`.",
144 );
145  
146 has hovertemplatesrc => ( is => "rw",
147 isa => "Str",
148 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
149 );
150  
151 has ids => (
152 is => "rw",
153 isa => "ArrayRef|PDL",
154 documentation =>
155 "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.",
156 );
157  
158 has idssrc => ( is => "rw",
159 isa => "Str",
160 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
161 );
162  
163 has legendgroup => (
164 is => "rw",
165 isa => "Str",
166 documentation =>
167 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
168 );
169  
170 has legendgrouptitle => ( is => "rw",
171 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Legendgrouptitle", );
172  
173 has legendrank => (
174 is => "rw",
175 isa => "Num",
176 documentation =>
177 "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.",
178 );
179  
180 has marker => ( is => "rw",
181 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Marker", );
182  
183 has pmeta => (
184 is => "rw",
185 isa => "Any|ArrayRef[Any]",
186 documentation =>
187 "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.",
188 );
189  
190 has metasrc => ( is => "rw",
191 isa => "Str",
192 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
193 );
194  
195 has name => ( is => "rw",
196 isa => "Str",
197 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
198 );
199  
200 has nbinsx => (
201 is => "rw",
202 isa => "Int",
203 documentation =>
204 "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.",
205 );
206  
207 has nbinsy => (
208 is => "rw",
209 isa => "Int",
210 documentation =>
211 "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.",
212 );
213  
214 has opacity => ( is => "rw",
215 isa => "Num",
216 documentation => "Sets the opacity of the trace.",
217 );
218  
219 has reversescale => (
220 is => "rw",
221 isa => "Bool",
222 documentation =>
223 "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color.",
224 );
225  
226 has showlegend => (
227 is => "rw",
228 isa => "Bool",
229 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
230 );
231  
232 has showscale => ( is => "rw",
233 isa => "Bool",
234 documentation => "Determines whether or not a colorbar is displayed for this trace.",
235 );
236  
237 has stream => ( is => "rw",
238 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Stream", );
239  
240 has textfont => ( is => "rw",
241 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Textfont", );
242  
243 has texttemplate => (
244 is => "rw",
245 isa => "Str",
246 documentation =>
247 "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. variable `z`",
248 );
249  
250 has transforms => ( is => "rw",
251 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Histogram2d::Transform]", );
252  
253 has uid => (
254 is => "rw",
255 isa => "Str",
256 documentation =>
257 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
258 );
259  
260 has uirevision => (
261 is => "rw",
262 isa => "Any",
263 documentation =>
264 "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.",
265 );
266  
267 has visible => (
268 is => "rw",
269 documentation =>
270 "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).",
271 );
272  
273 has x => ( is => "rw",
274 isa => "ArrayRef|PDL",
275 documentation => "Sets the sample data to be binned on the x axis.",
276 );
277  
278 has xaxis => (
279 is => "rw",
280 documentation =>
281 "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.",
282 );
283  
284 has xbingroup => (
285 is => "rw",
286 isa => "Str",
287 documentation =>
288 "Set a group of histogram traces which will have compatible x-bin settings. Using `xbingroup`, histogram2d and histogram2dcontour traces (on axes of the same axis type) can have compatible x-bin settings. Note that the same `xbingroup` value can be used to set (1D) histogram `bingroup`",
289 );
290  
291 has xbins => ( is => "rw",
292 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Xbins", );
293  
294 has xcalendar => ( is => "rw",
295 isa => enum(
296 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
297 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
298 ]
299 ),
300 documentation => "Sets the calendar system to use with `x` date data.",
301 );
302  
303 has xgap => ( is => "rw",
304 isa => "Num",
305 documentation => "Sets the horizontal gap (in pixels) between bricks.",
306 );
307  
308 has xhoverformat => (
309 is => "rw",
310 isa => "Str",
311 documentation =>
312 "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`.",
313 );
314  
315 has xsrc => ( is => "rw",
316 isa => "Str",
317 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
318 );
319  
320 has y => ( is => "rw",
321 isa => "ArrayRef|PDL",
322 documentation => "Sets the sample data to be binned on the y axis.",
323 );
324  
325 has yaxis => (
326 is => "rw",
327 documentation =>
328 "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.",
329 );
330  
331 has ybingroup => (
332 is => "rw",
333 isa => "Str",
334 documentation =>
335 "Set a group of histogram traces which will have compatible y-bin settings. Using `ybingroup`, histogram2d and histogram2dcontour traces (on axes of the same axis type) can have compatible y-bin settings. Note that the same `ybingroup` value can be used to set (1D) histogram `bingroup`",
336 );
337  
338 has ybins => ( is => "rw",
339 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Histogram2d::Ybins", );
340  
341 has ycalendar => ( is => "rw",
342 isa => enum(
343 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
344 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
345 ]
346 ),
347 documentation => "Sets the calendar system to use with `y` date data.",
348 );
349  
350 has ygap => ( is => "rw",
351 isa => "Num",
352 documentation => "Sets the vertical gap (in pixels) between bricks.",
353 );
354  
355 has yhoverformat => (
356 is => "rw",
357 isa => "Str",
358 documentation =>
359 "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`.",
360 );
361  
362 has ysrc => ( is => "rw",
363 isa => "Str",
364 documentation => "Sets the source reference on Chart Studio Cloud for `y`.",
365 );
366  
367 has z => ( is => "rw",
368 isa => "ArrayRef|PDL",
369 documentation => "Sets the aggregation data.",
370 );
371  
372 has zauto => (
373 is => "rw",
374 isa => "Bool",
375 documentation =>
376 "Determines whether or not the color domain is computed with respect to the input data (here in `z`) or the bounds set in `zmin` and `zmax` Defaults to `false` when `zmin` and `zmax` are set by the user.",
377 );
378  
379 has zhoverformat => (
380 is => "rw",
381 isa => "Str",
382 documentation =>
383 "Sets the hover text formatting rulefor `z` 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.By default the values are formatted using generic number format.",
384 );
385  
386 has zmax => (
387 is => "rw",
388 isa => "Num",
389 documentation =>
390 "Sets the upper bound of the color domain. Value should have the same units as in `z` and if set, `zmin` must be set as well.",
391 );
392  
393 has zmid => (
394 is => "rw",
395 isa => "Num",
396 documentation =>
397 "Sets the mid-point of the color domain by scaling `zmin` and/or `zmax` to be equidistant to this point. Value should have the same units as in `z`. Has no effect when `zauto` is `false`.",
398 );
399  
400 has zmin => (
401 is => "rw",
402 isa => "Num",
403 documentation =>
404 "Sets the lower bound of the color domain. Value should have the same units as in `z` and if set, `zmax` must be set as well.",
405 );
406  
407 has zsmooth => ( is => "rw",
408 documentation => "Picks a smoothing algorithm use to smooth `z` data.", );
409  
410 has zsrc => ( is => "rw",
411 isa => "Str",
412 documentation => "Sets the source reference on Chart Studio Cloud for `z`.",
413 );
414  
415 __PACKAGE__->meta->make_immutable();
416 1;
417  
418 __END__