Chart-Clicker

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    exception (thanks omega!)

2.36
  - Fix some weird 'padding' in ranges and in Axis marking, fixes datasets
    with ranges less than 1.

2.35
  - Legend
    - Depend on Layout::Manager 0.29 and adjust Legend to use 
    - Remove lots of random crap from Legend that wasn't being used
  - Ditch Clicker's BUILD method for prepare-time work wrt plot & legend
    addition
  - Add has_name predicate to Series and use it in Legend
  - Bar
    - Fix overlap in borders
    - Fix stroking of translucent bars
    - Only stroke bars if their opacity is < 1 and the brush width > 0

2.34
  - Clean up some unnecessary POD
  - Add shape_brush to Point renderer

MANIFEST  view on Meta::CPAN

example/multiple-renderers.pl
example/overaxis-bar.pl
example/pie.pl
example/point.pl
example/share-axes.pl
example/simple.pl
example/skip_range.pl
example/sparkline.pl
example/stackedarea.pl
example/stackedbar.pl
example/tabularlegend.pl
example/tufte-whitegrid.pl
inc/ChClDistMakeMaker.pm
lib/Chart/Clicker.pm
lib/Chart/Clicker/Axis.pm
lib/Chart/Clicker/Axis/DateTime.pm
lib/Chart/Clicker/Axis/DivisionType.pm
lib/Chart/Clicker/Axis/DivisionType/Exact.pm
lib/Chart/Clicker/Axis/DivisionType/LinearExpandGraph.pm
lib/Chart/Clicker/Axis/DivisionType/LinearRounded.pm
lib/Chart/Clicker/Component.pm

MANIFEST  view on Meta::CPAN

t/axis.t
t/basic.t
t/context.t
t/data-dataset.t
t/data-marker.t
t/data-range.t
t/datetime.t
t/decoration-color_allocator.t
t/decoration-glass.t
t/decoration-grid.t
t/decoration-legend.t
t/decoration-markeroverlay.t
t/decoration-plot.t
t/decoration.t
t/drawing-colorallocator.t
t/example.t
t/invisible.t
t/renderer-area.t
t/renderer-bar.t
t/renderer-base.t
t/renderer-bubble.t

README.mkdn  view on Meta::CPAN

enable this flag.

## height

Set/Get the height.  Defaults to 300.

## layout\_manager

Set/Get the layout manager.  Defaults to [Layout::Manager::Compass](https://metacpan.org/pod/Layout::Manager::Compass).

## legend

Set/Get the [legend](https://metacpan.org/pod/Chart::Clicker::Decoration::Legend) that will be used with this chart.

## legend\_position

The position the legend will be added.  Should be one of north, south, east,
west or center as required by [Layout::Manager::Compass](https://metacpan.org/pod/Layout::Manager::Compass).

## marker\_overlay

Set/Get the [marker overlay](https://metacpan.org/pod/Chart::Clicker::Decoration::MarkerOverlay) object that will be used if this chart
has markers.  This is lazily constructed to save time.

## over\_decorations

Set/Get an arrayref of "over decorations", or things that are drawn OVER the

example/overaxis-bar.pl  view on Meta::CPAN

);


$cc->color_allocator->colors([ $grey, $red ]);
$cc->border->width(0);

$cc->background_color(
    Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
);
$cc->plot->grid->visible(0);
$cc->legend->visible(0);

$defctx->renderer(Chart::Clicker::Renderer::Bar->new);

$defctx->range_axis->baseline(0);
$defctx->range_axis->hidden(1);
$defctx->domain_axis->hidden(1);
$defctx->domain_axis->fudge_amount(.1);
$defctx->renderer->brush->width(1);
$defctx->domain_axis->tick_values([qw(2000 2002 2004 2006 2008)]);

example/sparkline.pl  view on Meta::CPAN

    Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .15)
);
$mark->inside_color(
    Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .15)
);
$defctx->add_marker($mark);

$cc->color_allocator->colors([ $grey, $red, $blue ]);

$cc->plot->grid->visible(0);
$cc->legend->visible(0);
$cc->padding(2);
$cc->border->width(0);

$defctx->range_axis->hidden(1);
$defctx->range_axis->fudge_amount(.2);
$defctx->domain_axis->hidden(1);
$defctx->domain_axis->fudge_amount(.1);
$defctx->renderer->brush->width(1);

$cc->write_output('foo.png')

example/tabularlegend.pl  view on Meta::CPAN

    keys    => [qw(1 2 3 4 5 6 7 8 9 10 11 12)],
    values  => [qw(5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8)]
);
my $series2 = Chart::Clicker::Data::Series->new(
    keys    => [qw(1 2 3 4 5 6 7 8 9 10 11 12)],
    values  => [qw(8.5 0.5 9.4 8.4 5.4 2.5 5.3 9.2 5.2 8.1 1.9 1.8)]
);

my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2 ]);

$cc->legend(Chart::Clicker::Decoration::Legend::Tabular->new(
    header => [ qw(Name Min Max Median Mean) ],
    data => [
        [ min(@{ $series1->values }), max(@{ $series1->values }), median($series1->values)."", mean($series1->values)."" ],
        [ min(@{ $series2->values }), max(@{ $series2->values }), median($series2->values)."", mean($series2->values)."" ]
    ]
));

$cc->add_to_datasets($ds);

$cc->write_output('foo.png');

example/tufte-whitegrid.pl  view on Meta::CPAN


$cc->color_allocator->colors([ $grey ]);

$cc->grid_over(1);
$cc->plot->grid->range_brush->width(5);
$cc->plot->grid->show_domain(1);
$cc->plot->grid->domain_brush->color(
    Graphics::Color::RGB->new(red => 0, green => 0, blue => 0, alpha => .10)
);

$cc->legend->visible(0);

$cc->border->width(0);
$cc->background_color(
    Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
);
$cc->plot->grid->range_brush->color(
    Graphics::Color::RGB->new(red => .95, green => .94, blue => .92)
);

$cc->legend_position('n');
$defctx->range_axis->fudge_amount(.015);
$defctx->range_axis->tick_values([qw(1 2 3 4 5)]);
$defctx->range_axis->format('%d');
$defctx->domain_axis->brush->width(0);
$defctx->domain_axis->tick_values([qw(3 6 9 12 15 18 21)]);
$defctx->domain_axis->format('%d');

$defctx->domain_axis->fudge_amount(.015);
$defctx->range_axis->brush->width(0);

lib/Chart/Clicker.pm  view on Meta::CPAN

has '+height' => (
    default => 300
);


has '+layout_manager' => (
    default => sub { Layout::Manager::Compass->new }
);


has 'legend' => (
    is => 'rw',
    isa => 'Chart::Clicker::Decoration::Legend',
    default => sub {
        Chart::Clicker::Decoration::Legend->new(
            name => 'legend',
        );
    }
);


has 'legend_position' => (
    is => 'rw',
    isa => 'Str',
    default => 's'
);


has 'marker_overlay' => (
    is => 'rw',
    isa => 'Chart::Clicker::Decoration::MarkerOverlay',
    lazy => 1,

lib/Chart/Clicker.pm  view on Meta::CPAN

                    )
                );
            }
        }
        $self->add_to_datasets($ds);
    }

    unless(scalar(@{ $self->components })) {
        $self->add_component($self->plot, 'c');

        my $lp = lc($self->legend_position);
        if($self->legend->visible) {
            if(($lp =~ /^e/) || ($lp =~ /^w/)) {
                $self->legend->orientation('vertical');
            }
            $self->add_component($self->legend, $self->legend_position);
        }

        # Add subgraphs
        if($self->has_subgraphs) {
            for my $subgraph (@{$self->subgraphs}) {
                $subgraph->border->width(0);
                $subgraph->padding(0);

                $self->add_component($subgraph, 'south');
            }

lib/Chart/Clicker.pm  view on Meta::CPAN

enable this flag.

=head2 height

Set/Get the height.  Defaults to 300.

=head2 layout_manager

Set/Get the layout manager.  Defaults to L<Layout::Manager::Compass>.

=head2 legend

Set/Get the L<legend|Chart::Clicker::Decoration::Legend> that will be used with this chart.

=head2 legend_position

The position the legend will be added.  Should be one of north, south, east,
west or center as required by L<Layout::Manager::Compass>.

=head2 marker_overlay

Set/Get the L<marker overlay|Chart::Clicker::Decoration::MarkerOverlay> object that will be used if this chart
has markers.  This is lazily constructed to save time.

=head2 over_decorations

Set/Get an arrayref of "over decorations", or things that are drawn OVER the

lib/Chart/Clicker/Decoration/Legend.pm  view on Meta::CPAN

=head1 NAME

Chart::Clicker::Decoration::Legend - Series name, color key

=head1 VERSION

version 2.90

=head1 DESCRIPTION

Chart::Clicker::Decoration::Legend draws a legend on a Chart.

=head1 ATTRIBUTES

=head2 border

Set/Get this Legend's L<border|Graphics::Primitive::Border>.

=head2 font

Set/Get the L<font|Graphics::Primitive::Font> used for this legend's items.

=head2 insets

Set/Get this Legend's L<insets|Graphics::Primitive::Insets>.

=head2 item_padding

Set/Get the L<padding|Graphics::Primitive::Insets> for this legend's items.

=head2 layout_manager

Set/Get the layout manager for this lagend.  Defaults to
L<Layout::Manager::Flow> with an anchor of C<west> and a C<wrap> of 1.

=head1 AUTHOR

Cory G Watson <gphat@cpan.org>

lib/Chart/Clicker/Decoration/Legend/Tabular.pm  view on Meta::CPAN


version 2.90

=head1 SYNOPSIS

    my $cc = Chart::Clicker->new;

    my $series1 = Chart::Clicker::Data::Series->new;
    my $series2 = Chart::Clicker::Data::Series->new;

    $cc->legend(Chart::Clicker::Decoration::Legend::Tabular->new(
        header => [ qw(Name Min Max) ],
        data => [
            [ min(@{ $series1->values }), max(@{ $series1->values }) ],
            [ min(@{ $series2->values }), max(@{ $series2->values }) ]
        ]
    ));

=head1 DESCRIPTION

Chart::Clicker::Decoration::Legend::Tabular draws a legend on a Chart with
tabular data display.

The Tabular legend is a legend with a few extra attributes that allow you to
pass it data to display.  The attributes are c<header> and c<data>.  The
C<header> (optional) allows you to specify the strings to display at the top
of the table and the C<data> attribute allows you to pass in arrayrefs of
strings for display aside each of the series.

B<Note>: The first string in the C<header> arrayref should be the header for
the column above the name of the series.  This code does not do anything
to verify that you've given the appropriate counts of data.  It is expected
that you will provide C<data> with one arrayref for every series, each
containing n elements.  Having that, C<header> will expect n + 1 elements

lib/Chart/Clicker/Decoration/Legend/Tabular.pm  view on Meta::CPAN

elements in each of C<data>'s arrayrefs.

=head1 ATTRIBUTES

=head2 border

Set/Get this Legend's L<border|Graphics::Primitive::Border>.

=head2 color

Set/Get the L<color|Graphics::Color::RGB> to use as the foreground for the legend.

=head2 data

Set/Get the data for this legend.  Expects an arrayref of arrayrefs, with
one inner arrayref for every series charted.

=head2 font

Set/Get the L<font|Graphics::Primitive::Font> used for this legend's items.

=head2 header

Set/Get the header data used for this legend.  Expects an arrayref of Strings.

=head2 insets

Set/Get this Legend's insets.

=head2 item_padding

Set/Get the L<padding|Graphics::Primitive::Insets> for this legend's items.

=head1 METHODS

=head2 has_header

Predicate returning true of this legend has a header, else 1.

=head1 AUTHOR

Cory G Watson <gphat@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Cory G Watson.

This is free software; you can redistribute it and/or modify it under

lib/Chart/Clicker/Tutorial.pm  view on Meta::CPAN

  my $chart = Chart::Clicker->new(format => 'pdf');

  # Create the rest of your chart normally

  $chart->write_output('chart.pdf');

=head2 Example 7 : Hide the Legend and X-Axis

  my $chart = Chart::Clicker->new;

  # hide the legend
  $chart->legend->visible(0);

  # hide the X-Axis
  $chart->get_context('default')->domain_axis->hidden(1);

=head2 Example 8 : Change the display format of the Y-Axis

  my $chart = Chart::Clicker->new;

  # a sprintf format to have 3 decimal places showing on the Y-Axis
  $chart->get_context('default')->range_axis->format('%.3f');



( run in 1.213 second using v1.01-cache-2.11-cpan-49f99fa48dc )