File Coverage

blib/lib/Chart/Plotly/Trace/Funnel/Marker.pm
Criterion Covered Total %
statement 15 31 48.3
branch 0 8 0.0
condition 0 8 0.0
subroutine 5 6 83.3
pod 1 1 100.0
total 21 54 38.8


line stmt bran cond sub pod time code
1             package Chart::Plotly::Trace::Funnel::Marker;
2 1     1   8 use Moose;
  1         3  
  1         9  
3 1     1   19756 use MooseX::ExtraArgs;
  1         3  
  1         12  
4 1     1   2368 use Moose::Util::TypeConstraints qw(enum union);
  1         2  
  1         10  
5             if ( !defined Moose::Util::TypeConstraints::find_type_constraint('PDL') ) {
6             Moose::Util::TypeConstraints::type('PDL');
7             }
8              
9 1     1   1378 use Chart::Plotly::Trace::Funnel::Marker::Colorbar;
  1         4  
  1         43  
10 1     1   583 use Chart::Plotly::Trace::Funnel::Marker::Line;
  1         3  
  1         393  
11              
12             our $VERSION = '0.041'; # VERSION
13              
14             # ABSTRACT: This attribute is one of the possible options for the trace funnel.
15              
16             sub TO_JSON {
17 0     0 1   my $self = shift;
18 0   0       my $extra_args = $self->extra_args // {};
19 0           my $meta = $self->meta;
20 0           my %hash = %$self;
21 0           for my $name ( sort keys %hash ) {
22 0           my $attr = $meta->get_attribute($name);
23 0 0         if ( defined $attr ) {
24 0           my $value = $hash{$name};
25 0           my $type = $attr->type_constraint;
26 0 0 0       if ( $type && $type->equals('Bool') ) {
27 0 0         $hash{$name} = $value ? \1 : \0;
28             }
29             }
30             }
31 0           %hash = ( %hash, %$extra_args );
32 0           delete $hash{'extra_args'};
33 0 0 0       if ( $self->can('type') && ( !defined $hash{'type'} ) ) {
34 0           $hash{type} = $self->type();
35             }
36 0           return \%hash;
37             }
38              
39             has autocolorscale => (
40             is => "rw",
41             isa => "Bool",
42             documentation =>
43             "Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. Has an effect only if in `marker.color`is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.",
44             );
45              
46             has cauto => (
47             is => "rw",
48             isa => "Bool",
49             documentation =>
50             "Determines whether or not the color domain is computed with respect to the input data (here in `marker.color`) or the bounds set in `marker.cmin` and `marker.cmax` Has an effect only if in `marker.color`is set to a numerical array. Defaults to `false` when `marker.cmin` and `marker.cmax` are set by the user.",
51             );
52              
53             has cmax => (
54             is => "rw",
55             isa => "Num",
56             documentation =>
57             "Sets the upper bound of the color domain. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmin` must be set as well.",
58             );
59              
60             has cmid => (
61             is => "rw",
62             isa => "Num",
63             documentation =>
64             "Sets the mid-point of the color domain by scaling `marker.cmin` and/or `marker.cmax` to be equidistant to this point. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color`. Has no effect when `marker.cauto` is `false`.",
65             );
66              
67             has cmin => (
68             is => "rw",
69             isa => "Num",
70             documentation =>
71             "Sets the lower bound of the color domain. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmax` must be set as well.",
72             );
73              
74             has color => (
75             is => "rw",
76             isa => "Str|ArrayRef[Str]",
77             documentation =>
78             "Sets themarkercolor. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `marker.cmin` and `marker.cmax` if set.",
79             );
80              
81             has coloraxis => (
82             is => "rw",
83             documentation =>
84             "Sets a reference to a shared color axis. References to these shared color axes are *coloraxis*, *coloraxis2*, *coloraxis3*, etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.",
85             );
86              
87             has colorbar => ( is => "rw",
88             isa => "Maybe[HashRef]|Chart::Plotly::Trace::Funnel::Marker::Colorbar", );
89              
90             has colorscale => (
91             is => "rw",
92             documentation =>
93             "Sets the colorscale. Has an effect only if in `marker.color`is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use`marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys,YlGnBu,Greens,YlOrRd,Bluered,RdBu,Reds,Blues,Picnic,Rainbow,Portland,Jet,Hot,Blackbody,Earth,Electric,Viridis,Cividis.",
94             );
95              
96             has colorsrc => ( is => "rw",
97             isa => "Str",
98             documentation => "Sets the source reference on plot.ly for color .",
99             );
100              
101             has line => ( is => "rw",
102             isa => "Maybe[HashRef]|Chart::Plotly::Trace::Funnel::Marker::Line", );
103              
104             has opacity => ( is => "rw",
105             isa => "Num|ArrayRef[Num]",
106             documentation => "Sets the opacity of the bars.",
107             );
108              
109             has opacitysrc => ( is => "rw",
110             isa => "Str",
111             documentation => "Sets the source reference on plot.ly for opacity .",
112             );
113              
114             has reversescale => (
115             is => "rw",
116             isa => "Bool",
117             documentation =>
118             "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color.",
119             );
120              
121             has showscale => (
122             is => "rw",
123             isa => "Bool",
124             documentation =>
125             "Determines whether or not a colorbar is displayed for this trace. Has an effect only if in `marker.color`is set to a numerical array.",
126             );
127              
128             __PACKAGE__->meta->make_immutable();
129             1;
130              
131             __END__
132              
133             =pod
134              
135             =encoding utf-8
136              
137             =head1 NAME
138              
139             Chart::Plotly::Trace::Funnel::Marker - This attribute is one of the possible options for the trace funnel.
140              
141             =head1 VERSION
142              
143             version 0.041
144              
145             =head1 SYNOPSIS
146              
147             use Chart::Plotly;
148             use Chart::Plotly::Plot;
149             use JSON;
150             use Chart::Plotly::Trace::Funnel;
151            
152             # Example from https://github.com/plotly/plotly.js/blob/b93e3a5a83b6561ac6258a59f274b5fc87630c3e/test/image/mocks/funnel_11.json
153             my $trace1 = Chart::Plotly::Trace::Funnel->new({'orientation' => 'v', 'marker' => {'color' => 'rgb(255, 102, 97)', }, 'y' => [13.23, 22.7, 26.06, ], 'x' => ['Half Dose', 'Full Dose', 'Double Dose', ], 'name' => 'Orange Juice', });
154            
155             my $trace2 = Chart::Plotly::Trace::Funnel->new({'name' => 'Vitamin C', 'marker' => {'color' => 'rgb(0, 196, 200)', }, 'y' => [7.98, 16.77, 26.14, ], 'x' => ['Half Dose', 'Full Dose', 'Double Dose', ], 'orientation' => 'v', });
156            
157             my $trace3 = Chart::Plotly::Trace::Funnel->new({'name' => 'Std Dev - OJ', 'x' => ['Half Dose', 'Full Dose', 'Double Dose', ], 'y' => [1.4102837, 1.236752, 0.8396031, ], 'visible' => JSON::false, 'orientation' => 'v', });
158            
159             my $trace4 = Chart::Plotly::Trace::Funnel->new({'y' => [0.868562, 0.7954104, 1.5171757, ], 'x' => ['Half Dose', 'Full Dose', 'Double Dose', ], 'name' => 'Std Dev - VC', 'orientation' => 'v', 'visible' => JSON::false, });
160            
161            
162             my $plot = Chart::Plotly::Plot->new(
163             traces => [$trace1, $trace2, $trace3, $trace4, ],
164             layout =>
165             {'autosize' => JSON::false, 'hidesources' => JSON::false, 'plot_bgcolor' => 'rgb(217, 217, 217)', 'font' => {'color' => '#000', 'size' => 12, 'family' => 'Arial, sans-serif', }, 'width' => 600, 'separators' => '.,', 'legend' => {'xanchor' => 'left', 'font' => {'size' => 16, 'family' => '', 'color' => 'rgb(0, 0, 0)', }, 'bgcolor' => 'rgba(255, 255, 255, 0)', 'bordercolor' => 'rgba(0, 0, 0, 0)', 'yanchor' => 'auto', 'x' => 1.02, 'y' => 0.931907250442406, 'borderwidth' => 1, 'traceorder' => 'normal', }, 'funnelgroupgap' => 0, 'funnelgap' => 0.2, 'annotations' => [{'tag' => '', 'yatype' => 'linear', 'showarrow' => JSON::false, 'xanchor' => 'auto', 'bgcolor' => 'rgba(0,0,0,0)', 'arrowhead' => 1, 'yref' => 'paper', 'ax' => -10, 'align' => 'center', 'yanchor' => 'auto', 'xatype' => 'category', 'bordercolor' => '', 'ref' => 'paper', 'text' => '<b>Supplement</b>', 'x' => 1.3479735318445, 'y' => 0.998214285714286, 'opacity' => 1, 'arrowwidth' => 0, 'font' => {'size' => 18, 'family' => '', 'color' => '', }, 'ay' => -26.7109375, 'arrowcolor' => '', 'borderpad' => 1, 'borderwidth' => 1, 'xref' => 'paper', 'arrowsize' => 1, }, ], 'height' => 440, 'dragmode' => 'zoom', 'hovermode' => 'x', 'paper_bgcolor' => '#fff', 'boxmode' => 'overlay', 'showlegend' => JSON::true, 'titlefont' => {'family' => '', 'size' => 16, 'color' => '', }, 'title' => 'Grouped Funnel Chart', 'margin' => {'r' => 0, 't' => 80, 'b' => 80, 'l' => 80, 'autoexpand' => JSON::true, 'pad' => 2, }, 'yaxis' => {'gridcolor' => 'rgb(255, 255, 255)', 'autotick' => JSON::true, 'ticks' => '', 'tickfont' => {'color' => '', 'size' => 16, 'family' => '', }, 'mirror' => JSON::true, 'tickangle' => 0, 'domain' => [0, 1, ], 'anchor' => 'x', 'showgrid' => JSON::true, 'exponentformat' => 'e', 'tick0' => 0, 'showticklabels' => JSON::true, 'nticks' => 0, 'zerolinewidth' => 1, 'zeroline' => JSON::false, 'position' => 0, 'range' => [0, 29.1128165263158, ], 'dtick' => 5, 'showexponent' => 'all', 'showline' => JSON::false, 'linecolor' => '#000', 'type' => 'linear', 'linewidth' => 0.1, 'overlaying' => JSON::false, 'ticklen' => 5, 'rangemode' => 'normal', 'tickwidth' => 1, 'tickcolor' => '#000', 'title' => 'Length', 'autorange' => JSON::true, 'titlefont' => {'size' => 16, 'family' => '', 'color' => '', }, 'zerolinecolor' => '#000', 'gridwidth' => 1.9, }, 'funnelmode' => 'group', 'xaxis' => {'ticks' => '', 'autotick' => JSON::true, 'gridcolor' => 'rgb(255, 255, 255)', 'tickfont' => {'color' => '', 'family' => '', 'size' => 16, }, 'mirror' => JSON::true, 'anchor' => 'y', 'tickangle' => 0, 'domain' => [0, 1, ], 'showgrid' => JSON::true, 'exponentformat' => 'e', 'tick0' => 0, 'showticklabels' => JSON::true, 'range' => [-0.5, 2.5, ], 'nticks' => 0, 'zerolinewidth' => 1, 'zeroline' => JSON::false, 'position' => 0, 'showexponent' => 'all', 'dtick' => 1, 'showline' => JSON::false, 'type' => 'category', 'linecolor' => '#000', 'overlaying' => JSON::false, 'linewidth' => 0.1, 'ticklen' => 5, 'rangemode' => 'normal', 'titlefont' => {'size' => 16, 'family' => '', 'color' => '', }, 'autorange' => JSON::true, 'title' => 'Dose (mg)', 'tickwidth' => 1, 'tickcolor' => '#000', 'gridwidth' => 1.9, 'zerolinecolor' => '#000', }, }
166             );
167            
168             Chart::Plotly::show_plot($plot);
169              
170             =head1 DESCRIPTION
171              
172             This attribute is part of the possible options for the trace funnel.
173              
174             This file has been autogenerated from the official plotly.js source.
175              
176             If you like Plotly, please support them: L<https://plot.ly/>
177             Open source announcement: L<https://plot.ly/javascript/open-source-announcement/>
178              
179             Full reference: L<https://plot.ly/javascript/reference/#funnel>
180              
181             =head1 DISCLAIMER
182              
183             This is an unofficial Plotly Perl module. Currently I'm not affiliated in any way with Plotly.
184             But I think plotly.js is a great library and I want to use it with perl.
185              
186             =head1 METHODS
187              
188             =head2 TO_JSON
189              
190             Serialize the trace to JSON. This method should be called only by L<JSON> serializer.
191              
192             =head1 ATTRIBUTES
193              
194             =over
195              
196             =item * autocolorscale
197              
198             Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. Has an effect only if in `marker.color`is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.
199              
200             =item * cauto
201              
202             Determines whether or not the color domain is computed with respect to the input data (here in `marker.color`) or the bounds set in `marker.cmin` and `marker.cmax` Has an effect only if in `marker.color`is set to a numerical array. Defaults to `false` when `marker.cmin` and `marker.cmax` are set by the user.
203              
204             =item * cmax
205              
206             Sets the upper bound of the color domain. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmin` must be set as well.
207              
208             =item * cmid
209              
210             Sets the mid-point of the color domain by scaling `marker.cmin` and/or `marker.cmax` to be equidistant to this point. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color`. Has no effect when `marker.cauto` is `false`.
211              
212             =item * cmin
213              
214             Sets the lower bound of the color domain. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmax` must be set as well.
215              
216             =item * color
217              
218             Sets themarkercolor. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `marker.cmin` and `marker.cmax` if set.
219              
220             =item * coloraxis
221              
222             Sets a reference to a shared color axis. References to these shared color axes are *coloraxis*, *coloraxis2*, *coloraxis3*, etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.
223              
224             =item * colorbar
225              
226             =item * colorscale
227              
228             Sets the colorscale. Has an effect only if in `marker.color`is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use`marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys,YlGnBu,Greens,YlOrRd,Bluered,RdBu,Reds,Blues,Picnic,Rainbow,Portland,Jet,Hot,Blackbody,Earth,Electric,Viridis,Cividis.
229              
230             =item * colorsrc
231              
232             Sets the source reference on plot.ly for color .
233              
234             =item * line
235              
236             =item * opacity
237              
238             Sets the opacity of the bars.
239              
240             =item * opacitysrc
241              
242             Sets the source reference on plot.ly for opacity .
243              
244             =item * reversescale
245              
246             Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color.
247              
248             =item * showscale
249              
250             Determines whether or not a colorbar is displayed for this trace. Has an effect only if in `marker.color`is set to a numerical array.
251              
252             =back
253              
254             =head1 AUTHOR
255              
256             Pablo Rodríguez González <pablo.rodriguez.gonzalez@gmail.com>
257              
258             =head1 COPYRIGHT AND LICENSE
259              
260             This software is Copyright (c) 2020 by Pablo Rodríguez González.
261              
262             This is free software, licensed under:
263              
264             The MIT (X11) License
265              
266             =cut