Chart/Plotly/Trace/Choropleth.pm untested

filter: Statementstmt 0.0% 0 / 108 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 148 CC 6 SCAR 27.3
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 15.3
1 package Chart::Plotly::Trace::Choropleth;
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::Choropleth::Colorbar;
10 use Chart::Plotly::Trace::Choropleth::Hoverlabel;
11 use Chart::Plotly::Trace::Choropleth::Legendgrouptitle;
12 use Chart::Plotly::Trace::Choropleth::Marker;
13 use Chart::Plotly::Trace::Choropleth::Selected;
14 use Chart::Plotly::Trace::Choropleth::Stream;
15 use Chart::Plotly::Trace::Choropleth::Transform;
16 use Chart::Plotly::Trace::Choropleth::Unselected;
17  
18 our $VERSION = '0.042'; # VERSION
19  
20 # ABSTRACT: The data that describes the choropleth value-to-color mapping is set in `z`. The geographic locations corresponding to each value in `z` are set in `locations`.
21  
22 sub TO_JSON {
23 my $self = shift;
24 my $extra_args = $self->extra_args // {};
25 my $meta = $self->meta;
26 my %hash = %$self;
27 for my $name ( sort keys %hash ) {
28 my $attr = $meta->get_attribute($name);
29 if ( defined $attr ) {
30 my $value = $hash{$name};
31 my $type = $attr->type_constraint;
32 if ( $type && $type->equals('Bool') ) {
33 $hash{$name} = $value ? \1 : \0;
34 }
35 }
36 }
37 my $plotly_meta = delete $hash{'pmeta'};
38 if ( defined $plotly_meta ) {
39 $hash{'meta'} = $plotly_meta;
40 }
41 %hash = ( %hash, %$extra_args );
42 delete $hash{'extra_args'};
43 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
44 $hash{type} = $self->type();
45 }
46 return \%hash;
47 }
48  
49 sub type {
50 my @components = split( /::/, __PACKAGE__ );
51 return lc( $components[-1] );
52 }
53  
54 has autocolorscale => (
55 is => "rw",
56 isa => "Bool",
57 documentation =>
58 "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.",
59 );
60  
61 has coloraxis => (
62 is => "rw",
63 documentation =>
64 "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.",
65 );
66  
67 has colorbar => ( is => "rw",
68 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Colorbar", );
69  
70 has colorscale => (
71 is => "rw",
72 documentation =>
73 "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.",
74 );
75  
76 has customdata => (
77 is => "rw",
78 isa => "ArrayRef|PDL",
79 documentation =>
80 "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",
81 );
82  
83 has customdatasrc => ( is => "rw",
84 isa => "Str",
85 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
86 );
87  
88 has featureidkey => (
89 is => "rw",
90 isa => "Str",
91 documentation =>
92 "Sets the key in GeoJSON features which is used as id to match the items included in the `locations` array. Only has an effect when `geojson` is set. Support nested property, for example *properties.name*.",
93 );
94  
95 has geo => (
96 is => "rw",
97 documentation =>
98 "Sets a reference between this trace's geospatial coordinates and a geographic map. If *geo* (the default value), the geospatial coordinates refer to `layout.geo`. If *geo2*, the geospatial coordinates refer to `layout.geo2`, and so on.",
99 );
100  
101 has geojson => (
102 is => "rw",
103 isa => "Any",
104 documentation =>
105 "Sets optional GeoJSON data associated with this trace. If not given, the features on the base map are used. It can be set as a valid GeoJSON object or as a URL string. Note that we only accept GeoJSONs of type *FeatureCollection* or *Feature* with geometries of type *Polygon* or *MultiPolygon*.",
106 );
107  
108 has hoverinfo => (
109 is => "rw",
110 isa => "Str|ArrayRef[Str]",
111 documentation =>
112 "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.",
113 );
114  
115 has hoverinfosrc => ( is => "rw",
116 isa => "Str",
117 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
118 );
119  
120 has hoverlabel => ( is => "rw",
121 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Hoverlabel", );
122  
123 has hovertemplate => (
124 is => "rw",
125 isa => "Str|ArrayRef[Str]",
126 documentation =>
127 "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>`.",
128 );
129  
130 has hovertemplatesrc => ( is => "rw",
131 isa => "Str",
132 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
133 );
134  
135 has hovertext => ( is => "rw",
136 isa => "Str|ArrayRef[Str]",
137 documentation => "Same as `text`.",
138 );
139  
140 has hovertextsrc => ( is => "rw",
141 isa => "Str",
142 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
143 );
144  
145 has ids => (
146 is => "rw",
147 isa => "ArrayRef|PDL",
148 documentation =>
149 "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.",
150 );
151  
152 has idssrc => ( is => "rw",
153 isa => "Str",
154 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
155 );
156  
157 has legendgroup => (
158 is => "rw",
159 isa => "Str",
160 documentation =>
161 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
162 );
163  
164 has legendgrouptitle => ( is => "rw",
165 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Legendgrouptitle", );
166  
167 has legendrank => (
168 is => "rw",
169 isa => "Num",
170 documentation =>
171 "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.",
172 );
173  
174 has locationmode => (
175 is => "rw",
176 isa => enum( [ "ISO-3", "USA-states", "country names", "geojson-id" ] ),
177 documentation =>
178 "Determines the set of locations used to match entries in `locations` to regions on the map. Values *ISO-3*, *USA-states*, *country names* correspond to features on the base map and value *geojson-id* corresponds to features from a custom GeoJSON linked to the `geojson` attribute.",
179 );
180  
181 has locations => ( is => "rw",
182 isa => "ArrayRef|PDL",
183 documentation => "Sets the coordinates via location IDs or names. See `locationmode` for more info.",
184 );
185  
186 has locationssrc => ( is => "rw",
187 isa => "Str",
188 documentation => "Sets the source reference on Chart Studio Cloud for `locations`.",
189 );
190  
191 has marker => ( is => "rw",
192 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Marker", );
193  
194 has pmeta => (
195 is => "rw",
196 isa => "Any|ArrayRef[Any]",
197 documentation =>
198 "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.",
199 );
200  
201 has metasrc => ( is => "rw",
202 isa => "Str",
203 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
204 );
205  
206 has name => ( is => "rw",
207 isa => "Str",
208 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
209 );
210  
211 has reversescale => (
212 is => "rw",
213 isa => "Bool",
214 documentation =>
215 "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.",
216 );
217  
218 has selected => ( is => "rw",
219 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Selected", );
220  
221 has selectedpoints => (
222 is => "rw",
223 isa => "Any",
224 documentation =>
225 "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.",
226 );
227  
228 has showlegend => (
229 is => "rw",
230 isa => "Bool",
231 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
232 );
233  
234 has showscale => ( is => "rw",
235 isa => "Bool",
236 documentation => "Determines whether or not a colorbar is displayed for this trace.",
237 );
238  
239 has stream => ( is => "rw",
240 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Stream", );
241  
242 has text => ( is => "rw",
243 isa => "Str|ArrayRef[Str]",
244 documentation => "Sets the text elements associated with each location.",
245 );
246  
247 has textsrc => ( is => "rw",
248 isa => "Str",
249 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
250 );
251  
252 has transforms => ( is => "rw",
253 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Choropleth::Transform]", );
254  
255 has uid => (
256 is => "rw",
257 isa => "Str",
258 documentation =>
259 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
260 );
261  
262 has uirevision => (
263 is => "rw",
264 isa => "Any",
265 documentation =>
266 "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.",
267 );
268  
269 has unselected => ( is => "rw",
270 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choropleth::Unselected", );
271  
272 has visible => (
273 is => "rw",
274 documentation =>
275 "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).",
276 );
277  
278 has z => ( is => "rw",
279 isa => "ArrayRef|PDL",
280 documentation => "Sets the color values.",
281 );
282  
283 has zauto => (
284 is => "rw",
285 isa => "Bool",
286 documentation =>
287 "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.",
288 );
289  
290 has zmax => (
291 is => "rw",
292 isa => "Num",
293 documentation =>
294 "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.",
295 );
296  
297 has zmid => (
298 is => "rw",
299 isa => "Num",
300 documentation =>
301 "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`.",
302 );
303  
304 has zmin => (
305 is => "rw",
306 isa => "Num",
307 documentation =>
308 "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.",
309 );
310  
311 has zsrc => ( is => "rw",
312 isa => "Str",
313 documentation => "Sets the source reference on Chart Studio Cloud for `z`.",
314 );
315  
316 __PACKAGE__->meta->make_immutable();
317 1;
318  
319 __END__