Chart/Plotly/Trace/Scatterternary.pm untested

filter: Statementstmt 0.0% 0 / 118 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 / 159 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::Scatterternary;
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::Scatterternary::Hoverlabel;
10 use Chart::Plotly::Trace::Scatterternary::Legendgrouptitle;
11 use Chart::Plotly::Trace::Scatterternary::Line;
12 use Chart::Plotly::Trace::Scatterternary::Marker;
13 use Chart::Plotly::Trace::Scatterternary::Selected;
14 use Chart::Plotly::Trace::Scatterternary::Stream;
15 use Chart::Plotly::Trace::Scatterternary::Textfont;
16 use Chart::Plotly::Trace::Scatterternary::Transform;
17 use Chart::Plotly::Trace::Scatterternary::Unselected;
18  
19 our $VERSION = '0.042'; # VERSION
20  
21 # ABSTRACT: Provides similar functionality to the *scatter* type but on a ternary phase diagram. The data is provided by at least two arrays out of `a`, `b`, `c` triplets.
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 a => (
56 is => "rw",
57 isa => "ArrayRef|PDL",
58 documentation =>
59 "Sets the quantity of component `a` in each data point. If `a`, `b`, and `c` are all provided, they need not be normalized, only the relative values matter. If only two arrays are provided they must be normalized to match `ternary<i>.sum`.",
60 );
61  
62 has asrc => ( is => "rw",
63 isa => "Str",
64 documentation => "Sets the source reference on Chart Studio Cloud for `a`.",
65 );
66  
67 has b => (
68 is => "rw",
69 isa => "ArrayRef|PDL",
70 documentation =>
71 "Sets the quantity of component `a` in each data point. If `a`, `b`, and `c` are all provided, they need not be normalized, only the relative values matter. If only two arrays are provided they must be normalized to match `ternary<i>.sum`.",
72 );
73  
74 has bsrc => ( is => "rw",
75 isa => "Str",
76 documentation => "Sets the source reference on Chart Studio Cloud for `b`.",
77 );
78  
79 has c => (
80 is => "rw",
81 isa => "ArrayRef|PDL",
82 documentation =>
83 "Sets the quantity of component `a` in each data point. If `a`, `b`, and `c` are all provided, they need not be normalized, only the relative values matter. If only two arrays are provided they must be normalized to match `ternary<i>.sum`.",
84 );
85  
86 has cliponaxis => (
87 is => "rw",
88 isa => "Bool",
89 documentation =>
90 "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
91 );
92  
93 has connectgaps => (
94 is => "rw",
95 isa => "Bool",
96 documentation =>
97 "Determines whether or not gaps (i.e. {nan} or missing values) in the provided data arrays are connected.",
98 );
99  
100 has csrc => ( is => "rw",
101 isa => "Str",
102 documentation => "Sets the source reference on Chart Studio Cloud for `c`.",
103 );
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 fill => (
118 is => "rw",
119 isa => enum( [ "none", "toself", "tonext" ] ),
120 documentation =>
121 "Sets the area to fill with a solid color. Use with `fillcolor` if not *none*. scatterternary has a subset of the options available to scatter. *toself* connects the endpoints of the trace (or each segment of the trace if it has gaps) into a closed shape. *tonext* fills the space between two traces if one completely encloses the other (eg consecutive contour lines), and behaves like *toself* if there is no trace before it. *tonext* should not be used if one trace does not enclose the other.",
122 );
123  
124 has fillcolor => (
125 is => "rw",
126 isa => "Str",
127 documentation =>
128 "Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.",
129 );
130  
131 has hoverinfo => (
132 is => "rw",
133 isa => "Str|ArrayRef[Str]",
134 documentation =>
135 "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.",
136 );
137  
138 has hoverinfosrc => ( is => "rw",
139 isa => "Str",
140 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
141 );
142  
143 has hoverlabel => ( is => "rw",
144 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Hoverlabel", );
145  
146 has hoveron => (
147 is => "rw",
148 isa => "Str",
149 documentation =>
150 "Do the hover effects highlight individual points (markers or line points) or do they highlight filled regions? If the fill is *toself* or *tonext* and there are no markers or text, then the default is *fills*, otherwise it is *points*.",
151 );
152  
153 has hovertemplate => (
154 is => "rw",
155 isa => "Str|ArrayRef[Str]",
156 documentation =>
157 "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>`.",
158 );
159  
160 has hovertemplatesrc => ( is => "rw",
161 isa => "Str",
162 documentation => "Sets the source reference on Chart Studio Cloud for `hovertemplate`.",
163 );
164  
165 has hovertext => (
166 is => "rw",
167 isa => "Str|ArrayRef[Str]",
168 documentation =>
169 "Sets hover text elements associated with each (a,b,c) point. If a single string, the same string appears over all the data points. If an array of strings, the items are mapped in order to the the data points in (a,b,c). To be seen, trace `hoverinfo` must contain a *text* flag.",
170 );
171  
172 has hovertextsrc => ( is => "rw",
173 isa => "Str",
174 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
175 );
176  
177 has ids => (
178 is => "rw",
179 isa => "ArrayRef|PDL",
180 documentation =>
181 "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.",
182 );
183  
184 has idssrc => ( is => "rw",
185 isa => "Str",
186 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
187 );
188  
189 has legendgroup => (
190 is => "rw",
191 isa => "Str",
192 documentation =>
193 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
194 );
195  
196 has legendgrouptitle => ( is => "rw",
197 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Legendgrouptitle", );
198  
199 has legendrank => (
200 is => "rw",
201 isa => "Num",
202 documentation =>
203 "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.",
204 );
205  
206 has line => ( is => "rw",
207 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Line", );
208  
209 has marker => ( is => "rw",
210 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Marker", );
211  
212 has pmeta => (
213 is => "rw",
214 isa => "Any|ArrayRef[Any]",
215 documentation =>
216 "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.",
217 );
218  
219 has metasrc => ( is => "rw",
220 isa => "Str",
221 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
222 );
223  
224 has mode => (
225 is => "rw",
226 isa => "Str",
227 documentation =>
228 "Determines the drawing mode for this scatter trace. If the provided `mode` includes *text* then the `text` elements appear at the coordinates. Otherwise, the `text` elements appear on hover. If there are less than 20 points and the trace is not stacked then the default is *lines+markers*. Otherwise, *lines*.",
229 );
230  
231 has name => ( is => "rw",
232 isa => "Str",
233 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
234 );
235  
236 has opacity => ( is => "rw",
237 isa => "Num",
238 documentation => "Sets the opacity of the trace.",
239 );
240  
241 has selected => ( is => "rw",
242 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Selected", );
243  
244 has selectedpoints => (
245 is => "rw",
246 isa => "Any",
247 documentation =>
248 "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.",
249 );
250  
251 has showlegend => (
252 is => "rw",
253 isa => "Bool",
254 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
255 );
256  
257 has stream => ( is => "rw",
258 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Stream", );
259  
260 has subplot => (
261 is => "rw",
262 documentation =>
263 "Sets a reference between this trace's data coordinates and a ternary subplot. If *ternary* (the default value), the data refer to `layout.ternary`. If *ternary2*, the data refer to `layout.ternary2`, and so on.",
264 );
265  
266 has sum => (
267 is => "rw",
268 isa => "Num",
269 documentation =>
270 "The number each triplet should sum to, if only two of `a`, `b`, and `c` are provided. This overrides `ternary<i>.sum` to normalize this specific trace, but does not affect the values displayed on the axes. 0 (or missing) means to use ternary<i>.sum",
271 );
272  
273 has text => (
274 is => "rw",
275 isa => "Str|ArrayRef[Str]",
276 documentation =>
277 "Sets text elements associated with each (a,b,c) point. If a single string, the same string appears over all the data points. If an array of strings, the items are mapped in order to the the data points in (a,b,c). If trace `hoverinfo` contains a *text* flag and *hovertext* is not set, these elements will be seen in the hover labels.",
278 );
279  
280 has textfont => ( is => "rw",
281 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Textfont", );
282  
283 has textposition => (
284 is => "rw",
285 isa => union(
286 [
287 enum(
288 [ "top left",
289 "top center",
290 "top right",
291 "middle left",
292 "middle center",
293 "middle right",
294 "bottom left",
295 "bottom center",
296 "bottom right"
297 ]
298 ),
299 "ArrayRef"
300 ]
301 ),
302 documentation => "Sets the positions of the `text` elements with respects to the (x,y) coordinates.",
303 );
304  
305 has textpositionsrc => ( is => "rw",
306 isa => "Str",
307 documentation => "Sets the source reference on Chart Studio Cloud for `textposition`.",
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|ArrayRef[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 `a`, `b`, `c` and `text`.",
320 );
321  
322 has texttemplatesrc => ( is => "rw",
323 isa => "Str",
324 documentation => "Sets the source reference on Chart Studio Cloud for `texttemplate`.",
325 );
326  
327 has transforms => ( is => "rw",
328 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Scatterternary::Transform]", );
329  
330 has uid => (
331 is => "rw",
332 isa => "Str",
333 documentation =>
334 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
335 );
336  
337 has uirevision => (
338 is => "rw",
339 isa => "Any",
340 documentation =>
341 "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.",
342 );
343  
344 has unselected => ( is => "rw",
345 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Scatterternary::Unselected", );
346  
347 has visible => (
348 is => "rw",
349 documentation =>
350 "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).",
351 );
352  
353 __PACKAGE__->meta->make_immutable();
354 1;
355  
356 __END__