| 1 | package Chart::OFC2::Scatter; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Chart::OFC2::Scatter - OFC2 Scatter chart | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | extends 'Chart::OFC2::Element'; | ||
| 10 | |||
| 11 | =cut | ||
| 12 | |||
| 13 | 0 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 14 | use MooseX::StrictConstructor; | ||
| 15 | |||
| 16 | our $VERSION = '0.07'; | ||
| 17 | |||
| 18 | extends 'Chart::OFC2::Element'; | ||
| 19 | |||
| 20 | =head1 PROPERTIES | ||
| 21 | |||
| 22 | has '+type_name' => (default => 'scatter'); | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | has '+type_name' => (default => 'scatter'); | ||
| 27 | has '+use_extremes' => (default => 1); # scatter needs x-y min-maxes to print | ||
| 28 | has '+extremes' => (default => sub { $_[0]->set_extremes }, lazy => 1 ); # scatter needs x-y min-maxes to print | ||
| 29 | |||
| 30 | |||
| 31 | =head1 METHODS | ||
| 32 | |||
| 33 | =head2 set_extremes() | ||
| 34 | |||
| 35 | Set the chart element extremes. | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | sub set_extremes { | ||
| 40 | my ($self) = @_; | ||
| 41 | my $extremes = { | ||
| 42 | 'x_axis_max' => undef, | ||
| 43 | 'x_axis_min' => undef, | ||
| 44 | 'y_axis_max' => undef, | ||
| 45 | 'y_axis_min' => undef, | ||
| 46 | 'other' => undef | ||
| 47 | }; | ||
| 48 | for (@{ $self->values }) { | ||
| 49 | $extremes->{'y_axis_max'} = $_->{'y'} if !defined($extremes->{'y_axis_max'}); | ||
| 50 | if ($_->{'y'} > $extremes->{'y_axis_max'}) { | ||
| 51 | $extremes->{'y_axis_max'} = $_->{'y'}; | ||
| 52 | } | ||
| 53 | $extremes->{'y_axis_min'} = $_->{'y'} if !defined($extremes->{'y_axis_min'}); | ||
| 54 | if ($_->{'y'} < $extremes->{'y_axis_min'}) { | ||
| 55 | $extremes->{'y_axis_min'} = $_->{'y'}; | ||
| 56 | } | ||
| 57 | |||
| 58 | $extremes->{'x_axis_max'} = $_->{'x'} if !defined($extremes->{'x_axis_max'}); | ||
| 59 | if ($_->{'x'} > $extremes->{'x_axis_max'}) { | ||
| 60 | $extremes->{'x_axis_max'} = $_->{'x'}; | ||
| 61 | } | ||
| 62 | $extremes->{'x_axis_min'} = $_->{'x'} if !defined($extremes->{'x_axis_min'}); | ||
| 63 | if ($_->{'x'} < $extremes->{'x_axis_min'}) { | ||
| 64 | $extremes->{'x_axis_min'} = $_->{'x'}; | ||
| 65 | } | ||
| 66 | |||
| 67 | } | ||
| 68 | $self->extremes(Chart::OFC2::Extremes->new($extremes)); | ||
| 69 | } | ||
| 70 | |||
| 71 | 1; | ||