Chart/Plotly/Trace/Ohlc.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::Ohlc;
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::Ohlc::Decreasing;
10 use Chart::Plotly::Trace::Ohlc::Hoverlabel;
11 use Chart::Plotly::Trace::Ohlc::Increasing;
12 use Chart::Plotly::Trace::Ohlc::Legendgrouptitle;
13 use Chart::Plotly::Trace::Ohlc::Line;
14 use Chart::Plotly::Trace::Ohlc::Stream;
15 use Chart::Plotly::Trace::Ohlc::Transform;
16  
17 our $VERSION = '0.042'; # VERSION
18  
19 # ABSTRACT: The ohlc (short for Open-High-Low-Close) is a style of financial chart describing open, high, low and close for a given `x` coordinate (most likely time). The tip of the lines represent the `low` and `high` values and the horizontal segments represent the `open` and `close` values. Sample points where the close value is higher (lower) then the open value are called increasing (decreasing). By default, increasing items 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::Ohlc::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::Ohlc::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::Ohlc::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::Ohlc::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::Ohlc::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::Ohlc::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 tickwidth => ( is => "rw",
219 isa => "Num",
220 documentation => "Sets the width of the open/close tick marks relative to the *x* minimal interval.",
221 );
222  
223 has transforms => ( is => "rw",
224 isa => "ArrayRef|ArrayRef[Chart::Plotly::Trace::Ohlc::Transform]", );
225  
226 has uid => (
227 is => "rw",
228 isa => "Str",
229 documentation =>
230 "Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.",
231 );
232  
233 has uirevision => (
234 is => "rw",
235 isa => "Any",
236 documentation =>
237 "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.",
238 );
239  
240 has visible => (
241 is => "rw",
242 documentation =>
243 "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).",
244 );
245  
246 has x => ( is => "rw",
247 isa => "ArrayRef|PDL",
248 documentation => "Sets the x coordinates. If absent, linear coordinate will be generated.",
249 );
250  
251 has xaxis => (
252 is => "rw",
253 documentation =>
254 "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.",
255 );
256  
257 has xcalendar => ( is => "rw",
258 isa => enum(
259 [ "chinese", "coptic", "discworld", "ethiopian", "gregorian", "hebrew", "islamic", "jalali",
260 "julian", "mayan", "nanakshahi", "nepali", "persian", "taiwan", "thai", "ummalqura"
261 ]
262 ),
263 documentation => "Sets the calendar system to use with `x` date data.",
264 );
265  
266 has xhoverformat => (
267 is => "rw",
268 isa => "Str",
269 documentation =>
270 "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`.",
271 );
272  
273 has xperiod => (
274 is => "rw",
275 isa => "Any",
276 documentation =>
277 "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.",
278 );
279  
280 has xperiod0 => (
281 is => "rw",
282 isa => "Any",
283 documentation =>
284 "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.",
285 );
286  
287 has xperiodalignment => (
288 is => "rw",
289 isa => enum( [ "start", "middle", "end" ] ),
290 documentation => "Only relevant when the axis `type` is *date*. Sets the alignment of data points on the x axis.",
291 );
292  
293 has xsrc => ( is => "rw",
294 isa => "Str",
295 documentation => "Sets the source reference on Chart Studio Cloud for `x`.",
296 );
297  
298 has yaxis => (
299 is => "rw",
300 documentation =>
301 "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.",
302 );
303  
304 has yhoverformat => (
305 is => "rw",
306 isa => "Str",
307 documentation =>
308 "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`.",
309 );
310  
311 __PACKAGE__->meta->make_immutable();
312 1;
313  
314 __END__