Chart/Plotly/Trace/Choroplethmapbox.pm untested

filter: Statementstmt 0.0% 0 / 106 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 / 146 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::Choroplethmapbox;
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::Choroplethmapbox::Colorbar;
10 use Chart::Plotly::Trace::Choroplethmapbox::Hoverlabel;
11 use Chart::Plotly::Trace::Choroplethmapbox::Legendgrouptitle;
12 use Chart::Plotly::Trace::Choroplethmapbox::Marker;
13 use Chart::Plotly::Trace::Choroplethmapbox::Selected;
14 use Chart::Plotly::Trace::Choroplethmapbox::Stream;
15 use Chart::Plotly::Trace::Choroplethmapbox::Transform;
16 use Chart::Plotly::Trace::Choroplethmapbox::Unselected;
17  
18 our $VERSION = '0.042'; # VERSION
19  
20 # ABSTRACT: GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.
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 below => (
62 is => "rw",
63 isa => "Str",
64 documentation =>
65 "Determines if the choropleth polygons will be inserted before the layer with the specified ID. By default, choroplethmapbox traces are placed above the water layers. If set to '', the layer will be inserted above every existing layer.",
66 );
67  
68 has coloraxis => (
69 is => "rw",
70 documentation =>
71 "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.",
72 );
73  
74 has colorbar => ( is => "rw",
75 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choroplethmapbox::Colorbar", );
76  
77 has colorscale => (
78 is => "rw",
79 documentation =>
80 "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.",
81 );
82  
83 has customdata => (
84 is => "rw",
85 isa => "ArrayRef|PDL",
86 documentation =>
87 "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",
88 );
89  
90 has customdatasrc => ( is => "rw",
91 isa => "Str",
92 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
93 );
94  
95 has featureidkey => (
96 is => "rw",
97 isa => "Str",
98 documentation =>
99 "Sets the key in GeoJSON features which is used as id to match the items included in the `locations` array. Support nested property, for example *properties.name*.",
100 );
101  
102 has geojson => (
103 is => "rw",
104 isa => "Any",
105 documentation =>
106 "Sets the GeoJSON data associated with this trace. 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*.",
107 );
108  
109 has hoverinfo => (
110 is => "rw",
111 isa => "Str|ArrayRef[Str]",
112 documentation =>
113 "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.",
114 );
115  
116 has hoverinfosrc => ( is => "rw",
117 isa => "Str",
118 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
119 );
120  
121 has hoverlabel => ( is => "rw",
122 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choroplethmapbox::Hoverlabel", );
123  
124 has hovertemplate => (
125 is => "rw",
126 isa => "Str|ArrayRef[Str]",
127 documentation =>
128 "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 `properties` 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>`.",
129 );
130  
131 has hovertemplatesrc => ( is => "rw",
132 isa => "Str",
133 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
134 );
135  
136 has hovertext => ( is => "rw",
137 isa => "Str|ArrayRef[Str]",
138 documentation => "Same as `text`.",
139 );
140  
141 has hovertextsrc => ( is => "rw",
142 isa => "Str",
143 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
144 );
145  
146 has ids => (
147 is => "rw",
148 isa => "ArrayRef|PDL",
149 documentation =>
150 "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.",
151 );
152  
153 has idssrc => ( is => "rw",
154 isa => "Str",
155 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
156 );
157  
158 has legendgroup => (
159 is => "rw",
160 isa => "Str",
161 documentation =>
162 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
163 );
164  
165 has legendgrouptitle => ( is => "rw",
166 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choroplethmapbox::Legendgrouptitle", );
167  
168 has legendrank => (
169 is => "rw",
170 isa => "Num",
171 documentation =>
172 "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.",
173 );
174  
175 has locations => ( is => "rw",
176 isa => "ArrayRef|PDL",
177 documentation => "Sets which features found in *geojson* to plot using their feature `id` field.",
178 );
179  
180 has locationssrc => ( is => "rw",
181 isa => "Str",
182 documentation => "Sets the source reference on Chart Studio Cloud for `locations`.",
183 );
184  
185 has marker => ( is => "rw",
186 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choroplethmapbox::Marker", );
187  
188 has pmeta => (
189 is => "rw",
190 isa => "Any|ArrayRef[Any]",
191 documentation =>
192 "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.",
193 );
194  
195 has metasrc => ( is => "rw",
196 isa => "Str",
197 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
198 );
199  
200 has name => ( is => "rw",
201 isa => "Str",
202 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
203 );
204  
205 has reversescale => (
206 is => "rw",
207 isa => "Bool",
208 documentation =>
209 "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.",
210 );
211  
212 has selected => ( is => "rw",
213 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choroplethmapbox::Selected", );
214  
215 has selectedpoints => (
216 is => "rw",
217 isa => "Any",
218 documentation =>
219 "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.",
220 );
221  
222 has showlegend => (
223 is => "rw",
224 isa => "Bool",
225 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
226 );
227  
228 has showscale => ( is => "rw",
229 isa => "Bool",
230 documentation => "Determines whether or not a colorbar is displayed for this trace.",
231 );
232  
233 has stream => ( is => "rw",
234 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Choroplethmapbox::Stream", );
235  
236 has subplot => (
237 is => "rw",
238 documentation =>
239 "Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.",
240 );
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::Choroplethmapbox::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::Choroplethmapbox::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__