Chart/Plotly/Trace/Candlestick.pm untested

filter: Statementstmt 0.0% 0 / 107 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 146 CC 6 SCAR 27.8
CC
6
Cov
0%
TO_JSON
42.0
type
2.0
BEGIN
2.0
CRAP 16.1
1 package Chart::Plotly::Trace::Candlestick;
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::Candlestick::Decreasing;
10 use Chart::Plotly::Trace::Candlestick::Hoverlabel;
11 use Chart::Plotly::Trace::Candlestick::Increasing;
12 use Chart::Plotly::Trace::Candlestick::Legendgrouptitle;
13 use Chart::Plotly::Trace::Candlestick::Line;
14 use Chart::Plotly::Trace::Candlestick::Stream;
15 use Chart::Plotly::Trace::Candlestick::Transform;
16  
17 our $VERSION = '0.042'; # VERSION
18  
19 # ABSTRACT: The candlestick is a style of financial chart describing open, high, low and close for a given `x` coordinate (most likely time). The boxes represent the spread between the `open` and `close` values and the lines represent the spread between the `low` and `high` values Sample points where the close value is higher (lower) then the open value are called increasing (decreasing). By default, increasing candles are drawn in green whereas decreasing are drawn in red.
20  
21 sub TO_JSON {
22 my $self = shift;
23 my $extra_args = $self->extra_args // {};
24 my $meta = $self->meta;
25 my %hash = %$self;
26 for my $name ( sort keys %hash ) {
27 my $attr = $meta->get_attribute($name);
28 if ( defined $attr ) {
29 my $value = $hash{$name};
30 my $type = $attr->type_constraint;
31 if ( $type && $type->equals('Bool') ) {
32 $hash{$name} = $value ? \1 : \0;
33 }
34 }
35 }
36 my $plotly_meta = delete $hash{'pmeta'};
37 if ( defined $plotly_meta ) {
38 $hash{'meta'} = $plotly_meta;
39 }
40 %hash = ( %hash, %$extra_args );
41 delete $hash{'extra_args'};
42 if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
43 $hash{type} = $self->type();
44 }
45 return \%hash;
46 }
47  
48 sub type {
49 my @components = split( /::/, __PACKAGE__ );
50 return lc( $components[-1] );
51 }
52  
53 has close => ( is => "rw",
54 isa => "ArrayRef|PDL",
55 documentation => "Sets the close values.",
56 );
57  
58 has closesrc => ( is => "rw",
59 isa => "Str",
60 documentation => "Sets the source reference on Chart Studio Cloud for `close`.",
61 );
62  
63 has customdata => (
64 is => "rw",
65 isa => "ArrayRef|PDL",
66 documentation =>
67 "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",
68 );
69  
70 has customdatasrc => ( is => "rw",
71 isa => "Str",
72 documentation => "Sets the source reference on Chart Studio Cloud for `customdata`.",
73 );
74  
75 has decreasing => ( is => "rw",
76 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Candlestick::Decreasing", );
77  
78 has high => ( is => "rw",
79 isa => "ArrayRef|PDL",
80 documentation => "Sets the high values.",
81 );
82  
83 has highsrc => ( is => "rw",
84 isa => "Str",
85 documentation => "Sets the source reference on Chart Studio Cloud for `high`.",
86 );
87  
88 has hoverinfo => (
89 is => "rw",
90 isa => "Str|ArrayRef[Str]",
91 documentation =>
92 "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.",
93 );
94  
95 has hoverinfosrc => ( is => "rw",
96 isa => "Str",
97 documentation => "Sets the source reference on Chart Studio Cloud for `hoverinfo`.",
98 );
99  
100 has hoverlabel => ( is => "rw",
101 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Candlestick::Hoverlabel", );
102  
103 has hovertext => ( is => "rw",
104 isa => "Str|ArrayRef[Str]",
105 documentation => "Same as `text`.",
106 );
107  
108 has hovertextsrc => ( is => "rw",
109 isa => "Str",
110 documentation => "Sets the source reference on Chart Studio Cloud for `hovertext`.",
111 );
112  
113 has ids => (
114 is => "rw",
115 isa => "ArrayRef|PDL",
116 documentation =>
117 "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.",
118 );
119  
120 has idssrc => ( is => "rw",
121 isa => "Str",
122 documentation => "Sets the source reference on Chart Studio Cloud for `ids`.",
123 );
124  
125 has increasing => ( is => "rw",
126 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Candlestick::Increasing", );
127  
128 has legendgroup => (
129 is => "rw",
130 isa => "Str",
131 documentation =>
132 "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.",
133 );
134  
135 has legendgrouptitle => ( is => "rw",
136 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Candlestick::Legendgrouptitle", );
137  
138 has legendrank => (
139 is => "rw",
140 isa => "Num",
141 documentation =>
142 "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.",
143 );
144  
145 has line => ( is => "rw",
146 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Candlestick::Line", );
147  
148 has low => ( is => "rw",
149 isa => "ArrayRef|PDL",
150 documentation => "Sets the low values.",
151 );
152  
153 has lowsrc => ( is => "rw",
154 isa => "Str",
155 documentation => "Sets the source reference on Chart Studio Cloud for `low`.",
156 );
157  
158 has pmeta => (
159 is => "rw",
160 isa => "Any|ArrayRef[Any]",
161 documentation =>
162 "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.",
163 );
164  
165 has metasrc => ( is => "rw",
166 isa => "Str",
167 documentation => "Sets the source reference on Chart Studio Cloud for `meta`.",
168 );
169  
170 has name => ( is => "rw",
171 isa => "Str",
172 documentation => "Sets the trace name. The trace name appear as the legend item and on hover.",
173 );
174  
175 has opacity => ( is => "rw",
176 isa => "Num",
177 documentation => "Sets the opacity of the trace.",
178 );
179  
180 has open => ( is => "rw",
181 isa => "ArrayRef|PDL",
182 documentation => "Sets the open values.",
183 );
184  
185 has opensrc => ( is => "rw",
186 isa => "Str",
187 documentation => "Sets the source reference on Chart Studio Cloud for `open`.",
188 );
189  
190 has selectedpoints => (
191 is => "rw",
192 isa => "Any",
193 documentation =>
194 "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.",
195 );
196  
197 has showlegend => (
198 is => "rw",
199 isa => "Bool",
200 documentation => "Determines whether or not an item corresponding to this trace is shown in the legend.",
201 );
202  
203 has stream => ( is => "rw",
204 isa => "Maybe[HashRef]|Chart::Plotly::Trace::Candlestick::Stream", );
205  
206 has text => (
207 is => "rw",
208 isa => "Str|ArrayRef[Str]",
209 documentation =>
210 "Sets hover text elements associated with each sample point. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to this trace's sample points.",
211 );
212  
213 has textsrc => ( is => "rw",
214 isa => "Str",
215 documentation => "Sets the source reference on Chart Studio Cloud for `text`.",
216 );
217  
218 has transforms => ( is => "rw",
219 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Candlestick::Transform]", );
220  
221 has uid => (
222 is => "rw",
223 isa => "Str",
224 documentation =>
225 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
226 );
227  
228 has uirevision => (
229 is => "rw",
230 isa => "Any",
231 documentation =>
232 "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.",
233 );
234  
235 has visible => (
236 is => "rw",
237 documentation =>
238 "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).",
239 );
240  
241 has whiskerwidth => (
242 is => "rw",
243 isa => "Num",
244 documentation =>
245 "Sets the width of the whiskers relative to the box' width. For example, with 1, the whiskers are as wide as the box(es).",
246 );
247  
248 has x => ( is => "rw",
249 isa => "ArrayRef|PDL",
250 documentation => "Sets the x coordinates. If absent, linear coordinate will be generated.",
251 );
252  
253 has xaxis => (
254 is => "rw",
255 documentation =>
256 "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.",
257 );
258  
259 has xcalendar => ( is => "rw",
260 isa => enum(
261 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
262 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
263 ]
264 ),
265 documentation => "Sets the calendar system to use with `x` date data.",
266 );
267  
268 has xhoverformat => (
269 is => "rw",
270 isa => "Str",
271 documentation =>
272 "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`.",
273 );
274  
275 has xperiod => (
276 is => "rw",
277 isa => "Any",
278 documentation =>
279 "Only relevant when the axis `type` is *date*. Sets the period positioning in milliseconds or *n* on the x axis. Special values in the form of *n* could be used to declare the number of months. In this case `n` must be a positive integer.",
280 );
281  
282 has xperiod0 => (
283 is => "rw",
284 isa => "Any",
285 documentation =>
286 "Only relevant when the axis `type` is *date*. Sets the base for period positioning in milliseconds or date string on the x0 axis. When `x0period` is round number of weeks, the `x0period0` by default would be on a Sunday i.e. 2000-01-02, otherwise it would be at 2000-01-01.",
287 );
288  
289 has xperiodalignment => (
290 is => "rw",
291 isa => enum( [ "start", "middle", "end" ] ),
292 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the x axis.",
293 );
294  
295 has xsrc => ( is => "rw",
296 isa => "Str",
297 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
298 );
299  
300 has yaxis => (
301 is => "rw",
302 documentation =>
303 "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.",
304 );
305  
306 has yhoverformat => (
307 is => "rw",
308 isa => "Str",
309 documentation =>
310 "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`.",
311 );
312  
313 __PACKAGE__->meta->make_immutable();
314 1;
315  
316 __END__