File Coverage

blib/lib/Chart/Plotly/Trace/Scatter/Line.pm
Criterion Covered Total %
statement 9 25 36.0
branch 0 8 0.0
condition 0 8 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 46 28.2


line stmt bran cond sub pod time code
1             package Chart::Plotly::Trace::Scatter::Line;
2 4     4   30 use Moose;
  4         14  
  4         38  
3 4     4   27960 use MooseX::ExtraArgs;
  4         11  
  4         36  
4 4     4   8660 use Moose::Util::TypeConstraints qw(enum union);
  4         9  
  4         47  
5             if ( !defined Moose::Util::TypeConstraints::find_type_constraint('PDL') ) {
6             Moose::Util::TypeConstraints::type('PDL');
7             }
8              
9             our $VERSION = '0.041'; # VERSION
10              
11             # ABSTRACT: This attribute is one of the possible options for the trace scatter.
12              
13             sub TO_JSON {
14 0     0 1   my $self = shift;
15 0   0       my $extra_args = $self->extra_args // {};
16 0           my $meta = $self->meta;
17 0           my %hash = %$self;
18 0           for my $name ( sort keys %hash ) {
19 0           my $attr = $meta->get_attribute($name);
20 0 0         if ( defined $attr ) {
21 0           my $value = $hash{$name};
22 0           my $type = $attr->type_constraint;
23 0 0 0       if ( $type && $type->equals('Bool') ) {
24 0 0         $hash{$name} = $value ? \1 : \0;
25             }
26             }
27             }
28 0           %hash = ( %hash, %$extra_args );
29 0           delete $hash{'extra_args'};
30 0 0 0       if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
31 0           $hash{type} = $self->type();
32             }
33 0           return \%hash;
34             }
35              
36             has color => ( is => "rw",
37             isa => "Str",
38             documentation => "Sets the line color.",
39             );
40              
41             has dash => (
42             is => "rw",
43             isa => "Str",
44             documentation =>
45             "Sets the dash style of lines. Set to a dash type string (*solid*, *dot*, *dash*, *longdash*, *dashdot*, or *longdashdot*) or a dash length list in px (eg *5px,10px,2px,2px*).",
46             );
47              
48             has shape => (
49             is => "rw",
50             isa => enum( [ "linear", "spline", "hv", "vh", "hvh", "vhv" ] ),
51             documentation =>
52             "Determines the line shape. With *spline* the lines are drawn using spline interpolation. The other available values correspond to step-wise line shapes.",
53             );
54              
55             has simplify => (
56             is => "rw",
57             isa => "Bool",
58             documentation =>
59             "Simplifies lines by removing nearly-collinear points. When transitioning lines, it may be desirable to disable this so that the number of points along the resulting SVG path is unaffected.",
60             );
61              
62             has smoothing => (
63             is => "rw",
64             isa => "Num",
65             documentation =>
66             "Has an effect only if `shape` is set to *spline* Sets the amount of smoothing. *0* corresponds to no smoothing (equivalent to a *linear* shape).",
67             );
68              
69             has width => ( is => "rw",
70             isa => "Num",
71             documentation => "Sets the line width (in px).",
72             );
73              
74             __PACKAGE__->meta->make_immutable();
75             1;
76              
77             __END__
78              
79             =pod
80              
81             =encoding utf-8
82              
83             =head1 NAME
84              
85             Chart::Plotly::Trace::Scatter::Line - This attribute is one of the possible options for the trace scatter.
86              
87             =head1 VERSION
88              
89             version 0.041
90              
91             =head1 SYNOPSIS
92              
93             use HTML::Show;
94             use Chart::Plotly;
95             use Chart::Plotly::Trace::Scatter;
96             my $scatter = Chart::Plotly::Trace::Scatter->new( x => [ 1 .. 5 ], y => [ 1 .. 5 ] );
97            
98             HTML::Show::show( Chart::Plotly::render_full_html( data => [$scatter] ) );
99              
100             =head1 DESCRIPTION
101              
102             This attribute is part of the possible options for the trace scatter.
103              
104             This file has been autogenerated from the official plotly.js source.
105              
106             If you like Plotly, please support them: L<https://plot.ly/>
107             Open source announcement: L<https://plot.ly/javascript/open-source-announcement/>
108              
109             Full reference: L<https://plot.ly/javascript/reference/#scatter>
110              
111             =head1 DISCLAIMER
112              
113             This is an unofficial Plotly Perl module. Currently I'm not affiliated in any way with Plotly.
114             But I think plotly.js is a great library and I want to use it with perl.
115              
116             =head1 METHODS
117              
118             =head2 TO_JSON
119              
120             Serialize the trace to JSON. This method should be called only by L<JSON> serializer.
121              
122             =head1 ATTRIBUTES
123              
124             =over
125              
126             =item * color
127              
128             Sets the line color.
129              
130             =item * dash
131              
132             Sets the dash style of lines. Set to a dash type string (*solid*, *dot*, *dash*, *longdash*, *dashdot*, or *longdashdot*) or a dash length list in px (eg *5px,10px,2px,2px*).
133              
134             =item * shape
135              
136             Determines the line shape. With *spline* the lines are drawn using spline interpolation. The other available values correspond to step-wise line shapes.
137              
138             =item * simplify
139              
140             Simplifies lines by removing nearly-collinear points. When transitioning lines, it may be desirable to disable this so that the number of points along the resulting SVG path is unaffected.
141              
142             =item * smoothing
143              
144             Has an effect only if `shape` is set to *spline* Sets the amount of smoothing. *0* corresponds to no smoothing (equivalent to a *linear* shape).
145              
146             =item * width
147              
148             Sets the line width (in px).
149              
150             =back
151              
152             =head1 AUTHOR
153              
154             Pablo Rodríguez González <pablo.rodriguez.gonzalez@gmail.com>
155              
156             =head1 COPYRIGHT AND LICENSE
157              
158             This software is Copyright (c) 2020 by Pablo Rodríguez González.
159              
160             This is free software, licensed under:
161              
162             The MIT (X11) License
163              
164             =cut