| 1 | package Chart::GGPlot::Backend::Plotly::Geom::Bar; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Chart::GGPlot's Plotly implementation for Geom::Bar | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 1 | ▶ | use Chart::GGPlot::Class; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | our $VERSION = '0.002003'; # VERSION | |||||||||||||
| 8 | |||||||||||||||
| 9 | 1 | with qw(Chart::GGPlot::Backend::Plotly::Geom); | |||||||||||||
| 10 | |||||||||||||||
| 11 | 1 | ▶ | use Module::Load; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | ▶ | use Chart::GGPlot::Backend::Plotly::Util qw(to_rgb pdl_to_plotly); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 0 | ▶ | classmethod split_on () { [qw(fill)] } | ||||||||||||
|
Subroutine
split_on: not called CC=3 SCAR=22.6
Pod
undocumented
Branch: 2 branches
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | 0 | ▶ | classmethod to_traces ($df, $params, $plot) { | ||||||||||||
|
Subroutine
to_traces: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||
| 18 | 0 | load Chart::Plotly::Trace::Bar; | |||||||||||||
| 19 | 0 | load Chart::Plotly::Trace::Bar::Marker; | |||||||||||||
| 20 | |||||||||||||||
| 21 | 0 | my $fill = to_rgb( $df->at('fill') ); | |||||||||||||
| 22 | 0 | my $opacity = $df->at('alpha')->setbadtoval(1); | |||||||||||||
| 23 | |||||||||||||||
| 24 | 0 | my $marker = Chart::Plotly::Trace::Bar::Marker->new( | |||||||||||||
| 25 | color => pdl_to_plotly( $fill, true ), | ||||||||||||||
| 26 | opacity => pdl_to_plotly( $opacity, true ), | ||||||||||||||
| 27 | ); | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 0 | my $x = $df->at('x'); | |||||||||||||
| 30 | 0 | my $base = $df->at('ymin'); | |||||||||||||
| 31 | 0 | my $y = $df->at('ymax') - $base; | |||||||||||||
| 32 | 0 | my $width = $df->at('xmax') - $df->at('xmin'); | |||||||||||||
| 33 | |||||||||||||||
| 34 | 0 | my $trace = Chart::Plotly::Trace::Bar->new( | |||||||||||||
| 35 | x => pdl_to_plotly($x), | ||||||||||||||
| 36 | y => pdl_to_plotly($y), | ||||||||||||||
| 37 | base => pdl_to_plotly( $base, true ), | ||||||||||||||
| 38 | width => pdl_to_plotly( $width, true ), | ||||||||||||||
| 39 | marker => $marker, | ||||||||||||||
| 40 | hovertext => pdl_to_plotly( $df->at('hovertext') ), | ||||||||||||||
| 41 | hoverinfo => 'text', | ||||||||||||||
| 42 | hoveron => $class->hover_on, | ||||||||||||||
| 43 | ); | ||||||||||||||
| 44 | 0 | return [ $class->_adjust_trace_for_flip($trace, $plot) ]; | |||||||||||||
| 45 | 1 | } | |||||||||||||
| 46 | |||||||||||||||
| 47 | 0 | ▶ | around _hovertext_data_for_aes( $orig, $class : $df, $aes ) { | ||||||||||||
|
Subroutine
:around: not called CC=4 SCAR=30.0
Branch: 2 branches
| |||||||||||||||
| 48 | return ( | ||||||||||||||
| 49 | 0 | ▶ | $aes eq 'y' | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | ? $df->at('ymax') - $df->at('ymin') | ||||||||||||||
| 51 | : $class->$orig( $df, $aes ) | ||||||||||||||
| 52 | ); | ||||||||||||||
| 53 | 1 | } | |||||||||||||
| 54 | |||||||||||||||
| 55 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 56 | |||||||||||||||
| 57 | 1 | 1; | |||||||||||||
| 58 | |||||||||||||||
| 59 | __END__ | ||||||||||||||