File Coverage

blib/lib/Chart/Plotly/Trace/Scatter/Stream.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::Stream;
2 4     4   34 use Moose;
  4         12  
  4         33  
3 4     4   26819 use MooseX::ExtraArgs;
  4         10  
  4         37  
4 4     4   8390 use Moose::Util::TypeConstraints qw(enum union);
  4         12  
  4         39  
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 maxpoints => (
37             is => "rw",
38             isa => "Num",
39             documentation =>
40             "Sets the maximum number of points to keep on the plots from an incoming stream. If `maxpoints` is set to *50*, only the newest 50 points will be displayed on the plot.",
41             );
42              
43             has token => (
44             is => "rw",
45             isa => "Str",
46             documentation =>
47             "The stream id number links a data trace on a plot with a stream. See https://plot.ly/settings for more details.",
48             );
49              
50             __PACKAGE__->meta->make_immutable();
51             1;
52              
53             __END__
54              
55             =pod
56              
57             =encoding utf-8
58              
59             =head1 NAME
60              
61             Chart::Plotly::Trace::Scatter::Stream - This attribute is one of the possible options for the trace scatter.
62              
63             =head1 VERSION
64              
65             version 0.041
66              
67             =head1 SYNOPSIS
68              
69             use HTML::Show;
70             use Chart::Plotly;
71             use Chart::Plotly::Trace::Scatter;
72             my $scatter = Chart::Plotly::Trace::Scatter->new( x => [ 1 .. 5 ], y => [ 1 .. 5 ] );
73            
74             HTML::Show::show( Chart::Plotly::render_full_html( data => [$scatter] ) );
75              
76             =head1 DESCRIPTION
77              
78             This attribute is part of the possible options for the trace scatter.
79              
80             This file has been autogenerated from the official plotly.js source.
81              
82             If you like Plotly, please support them: L<https://plot.ly/>
83             Open source announcement: L<https://plot.ly/javascript/open-source-announcement/>
84              
85             Full reference: L<https://plot.ly/javascript/reference/#scatter>
86              
87             =head1 DISCLAIMER
88              
89             This is an unofficial Plotly Perl module. Currently I'm not affiliated in any way with Plotly.
90             But I think plotly.js is a great library and I want to use it with perl.
91              
92             =head1 METHODS
93              
94             =head2 TO_JSON
95              
96             Serialize the trace to JSON. This method should be called only by L<JSON> serializer.
97              
98             =head1 ATTRIBUTES
99              
100             =over
101              
102             =item * maxpoints
103              
104             Sets the maximum number of points to keep on the plots from an incoming stream. If `maxpoints` is set to *50*, only the newest 50 points will be displayed on the plot.
105              
106             =item * token
107              
108             The stream id number links a data trace on a plot with a stream. See https://plot.ly/settings for more details.
109              
110             =back
111              
112             =head1 AUTHOR
113              
114             Pablo Rodríguez González <pablo.rodriguez.gonzalez@gmail.com>
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             This software is Copyright (c) 2020 by Pablo Rodríguez González.
119              
120             This is free software, licensed under:
121              
122             The MIT (X11) License
123              
124             =cut