package Chart::OFC::Dataset::Line; use strict; use warnings; use MooseX::StrictConstructor; use Chart::OFC::Types; extends 'Chart::OFC::Dataset'; # Cannot do has '+values' because the new type is not a subtype of the # type in the parent class. has 'values' => ( is => 'ro', isa => 'Chart::OFC::Type::NonEmptyArrayRefOfNumsOrUndefs', required => 1, auto_deref => 1, ); has width => ( is => 'ro', isa => 'Chart::OFC::Type::PosInt', default => 2, ); has color => ( is => 'ro', isa => 'Chart::OFC::Type::Color', coerce => 1, default => '#000000', ); has label => ( is => 'ro', isa => 'Str', predicate => '_has_label', ); has text_size => ( is => 'ro', isa => 'Chart::OFC::Type::Size', default => 10, ); sub type { return 'line'; } sub _parameters_for_type { my $self = shift; my @p = ( $self->width(), $self->color() ); push @p, ( $self->label(), $self->text_size() ) if $self->_has_label(); return @p; } no Moose; __PACKAGE__->meta()->make_immutable(); 1; __END__ =pod =head1 NAME Chart::OFC::Dataset::Line - A dataset represented as a line =head1 SYNOPSIS my $line = Chart::OFC::Dataset::Line->new( values => \@numbers, width => 5, color => 'purple', label => 'Daily Sales in $', text_size => 12, ); =head1 DESCRIPTION This class contains values to be charted as a line on a grid chart. =head1 ATTRIBUTES This class has several attributes which may be passed to the C method. It is a subclass of C and accepts all of that class's attributes as well as its own. =head2 values For this class, the values array may contain some undefined values. These are simply skipped in the resulting chart. =head2 links Just as with values, this may contain some undefined values. =head2 width The width of the line in pixels. Defaults to 2. =head2 color The color of the line, and of the text in the chart key, if a label is specified. Defaults to #999999 (medium grey). =head2 label If provided, this will be shown as part of the chart key. This attribute is optional. =head2 text_size This is the size of the text in the key. Defaults to 10 (pixels). =head1 ROLES This class does the C role. =head1 COPYRIGHT & LICENSE Copyright 2007-2008 Dave Rolsky, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut