#!/usr/bin/perl
use strict;
use warnings;

use List::Util qw( max );
use Mock::Populate;
use SVG;

# Get the data!
my $n = 90;
my $x = Mock::Populate::distributor(type => 'u', prec => 4, dof => 2, N => $n);
my $y = Mock::Populate::distributor(type => 's', prec => 4, dof => 2, N => $n);
my $max = max @$x, @$y;

# Set the scaling factor.
my $factor = 50;

# Get a chart instance.
my $w = $max * $factor;
my $svg = SVG->new( width => $w, height => $w );
my $g = $svg->group(
    id    => 'group',
    style => {
        stroke           => 'gray',
        fill             => 'none',
        'stroke-width'   => '0.5',
        'stroke-opacity' => '0.5',
    },
);

# Add rectangular axes.
my $offset = $w / 2;
$g->rectangle(
    x      => 0,
    y      => 0,
    width  => $offset,
    height => $offset,
    id     => 'quadrant_2',
);
$g->rectangle(
    x      => $offset,
    y      => $offset,
    width  => $offset,
    height => $offset,
    id     => 'quadrant_4',
);
# Add concentric rings.
my $i = 10;
for my $j ( 0 ..  $offset / $i ) {
    $g->circle(
        cx => $offset,
        cy => $offset,
        r  => $i * $j,
        id => 'circle_' . $i . '_' . $j,
    );
}

# Add data-points.
for my $j (0 .. @$x - 1) {
    $g->circle(
        cx => $x->[$j] * $factor + $offset,
        cy => $y->[$j] * $factor + $offset,
        r  => '0.5',
        id => 'circle_' . $i . 'x' . $j,
        style => {
            stroke         => 'black',
            fill           => 'none',
            'stroke-width' => '0.5',
        },
    );
}

print $svg->xmlify;
