The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SVG::Graph::Kit - Simplified data plotting with SVG

VERSION

version 0.0401

SYNOPSIS

  use SVG::Graph::Kit;
  my $data = [ [ 1,  2, 0 ],
               [ 2,  3, 1 ],
               [ 3,  5, 1 ],
               [ 4,  7, 2 ],
               [ 5, 11, 3 ],
               [ 6, 13, 5 ], ];
  my $g = SVG::Graph::Kit->new(data => $data);
  print $g->draw;
  my $n;
  for my $dim (qw(x y z)) {
    for my $stat (qw(min max mean mode median range stdv percentile)) {
      $n = $stat eq 'percentile' ? 90 : undef; # Inspect the 90th percentile.
      printf "%s %s = %0.2f\n", $dim, $stat, $g->stat($dim, $stat, $n);
    }
  }

DESCRIPTION

An SVG::Graph::Kit object is an automated data plotter that is a subclass of SVG::Graph.

NAME

SVG::Graph::Kit - Simplified data plotting with SVG

METHODS

new()

  $g = SVG::Graph::Kit->new();
  $g = SVG::Graph::Kit->new(data => \@numeric);
  $g = SVG::Graph::Kit->new(data => \@numeric, axis => 0);
  # Custom:
  $g = SVG::Graph::Kit->new(
    data => \@numeric,
    axis => { xticks => 10, yticks => 20 },
  );
  $g = SVG::Graph::Kit->new(
    width => 300, height => 300, margin => 20,
    data => [[0,2], [1,3] ... ],
    plot => {
      type => 'line', # default: scatter
      'fill-opacity' => 0.5, # etc.
    },
    axis => {
      'stroke-width' => 2, # etc.
      ticks => scalar @$data, # default: 30
      log => 2, # Default factor 10
    },
  );

Return a new SVG::Graph::Kit instance.

Optional arguments:

  data => Numeric vectors (the datapoints)
  plot => Chart type and data rendering properties
  axis => Axis rendering properties or 0 for off

Except for the plot type, axis => 0 and axis ticks, the plot and axis arguments are ordinary CSS, 'a la SVG::Graph.

The plot type is given in SVG::Graph. axis => 0 turns off the rendering of the axis. The axis ticks, xticks and yticks values represent the number of labeled tick marks displayed on a scaled graph axis.

stat()

  $g->stat($dimension, $name);
  $g->stat('x', 'mean');
  $g->stat('y', 'stdv');
  $g->stat('z', 'percentile');
  # etc.

This method is a direct call to the appropriate SVG::Graph::Data "x-method" (i.e. min, max, mean, mode, median, range, stdv and percentile).

TO DO

Allow log scaling.

Position axis origin.

Call any Statistics::Descriptive method, not just those given by SVG::Graph.

Highlight data points or areas.

Draw grid lines.

Add an SVG::Graph::polar chart?

SEE ALSO

The code in t/*.

SVG::Graph

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.