Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use simpler api for line example.

  • Loading branch information...
commit 8030070f1ac1436a3ca98378abef8d24597ebfb0 1 parent 74aae23
@gphat authored
Showing with 9 additions and 28 deletions.
  1. +9 −28 example/line.pl
View
37 example/line.pl
@@ -2,19 +2,10 @@
use strict;
use Chart::Clicker;
-use Chart::Clicker::Context;
-use Chart::Clicker::Data::DataSet;
-use Chart::Clicker::Data::Marker;
-use Chart::Clicker::Data::Series;
use Chart::Clicker::Renderer::Line;
-use Geometry::Primitive::Rectangle;
-use Graphics::Color::RGB;
my $cc = Chart::Clicker->new(width => 500, height => 250);
-my @hours = qw(
- 1 2 3 4 5 6 7 8 9 10 11 12
-);
my @bw1 = qw(
5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8
);
@@ -25,30 +16,20 @@
.3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1
);
-my $series1 = Chart::Clicker::Data::Series->new(
- keys => \@hours,
- values => \@bw1,
-);
-my $series2 = Chart::Clicker::Data::Series->new(
- keys => \@hours,
- values => \@bw2,
-);
-
-my $series3 = Chart::Clicker::Data::Series->new(
- keys => \@hours,
- values => \@bw3,
-);
-
-
-my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]);
-
-$cc->add_to_datasets($ds);
+foreach my $d (@bw1) {
+ $cc->add_data('Series 0', $d);
+}
+foreach my $d (@bw2) {
+ $cc->add_data('Series 1', $d);
+}
+foreach my $d (@bw3) {
+ $cc->add_data('Series 2', $d);
+}
my $def = $cc->get_context('default');
my $ren = Chart::Clicker::Renderer::Line->new;
$ren->brush->width(3);
-$def->renderer($area);
$def->range_axis->tick_values([qw(1 5 9)]);
$def->range_axis->format('%d');
$def->domain_axis->tick_values([qw(2 4 6 8 10)]);
Please sign in to comment.
Something went wrong with that request. Please try again.