Author: spadkins
Date: Wed May 10 10:48:21 2006
New Revision: 6277
Modified:
p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
Log:
added step graph from Cybage
Modified: p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
==============================================================================
--- p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
(original)
+++ p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm Wed May
10 10:48:21 2006
@@ -12,6 +12,7 @@
use Date::Format;
use Date::Parse;
+#use Data::Dumper;
use strict;
@@ -50,7 +51,6 @@
&App::sub_entry if ($App::trace);
my $self = shift;
my $name = $self->{name};
-
my $spec = $self->create_graph_spec();
my ($html);
@@ -189,6 +189,7 @@
line => 1,
pie => 1,
meter => 1,
+ step => 1,
);
my $html = "";
if ($known_graphtype{$graphtype}) {
@@ -228,7 +229,7 @@
my ($self, $spec) = @_;
require "perlchartdir.pm";
- my $x = $self->get_x($spec);
+ my $x = $self->get_x($spec); #
print STDERR Dumper $x;
my $width = $spec->{width} || 250;
my $height = $spec->{height} || 250;
my $left_margin = $spec->{left_margin};
@@ -287,7 +288,7 @@
$c->setBackground(0xbbbbff);
#$c->setBackground(perlchartdir::metalColor(0xaaaaff));
- &App::sub_exit($c) if ($App::trace);
+ &App::sub_exit($c) if ($App::trace); # print STDERR Dumper $c;
return($c);
}
@@ -683,15 +684,14 @@
&App::sub_entry if ($App::trace);
my ($self, $spec) = @_;
require "perlchartdir.pm";
-
#Create a XYChart object of size 500 x 270 pixels, with a pale blue
(0xe0e0ff)
#background, a light blue (0xccccff) border, and 1 pixel 3D border effect.
- my $c = new XYChart(800, 350, 0xe0e0ff, 0xccccff, 1);
-
+ my $c = new XYChart(600, 350, 0xe0e0ff, 0xccccff, 1); #800
#Set the plotarea at (50, 50) and of size 420 x 180 pixels, using white
#(0xffffff) as the plot area background color. Turn on both horizontal and
#vertical grid lines with light grey color (0xc0c0c0)
- $c->setPlotArea(50, 50, 720, 260, 0xffffff)->setGridColor(0xc0c0c0,
0xc0c0c0);
+
+ $c->setPlotArea(50, 50, 320, 260, 0xffffff)->setGridColor(0xc0c0c0,
0xc0c0c0); #720
#Add a legend box at (55, 25) (top of the chart) with horizontal layout.
Use 10
#pts Arial Bold Italic font. Set the background and border color to
Transparent.
@@ -753,5 +753,47 @@
&App::sub_exit() if ($App::trace);
}
+sub write_step_graph_image {
+ &App::sub_entry if ($App::trace);
+ my ($self, $spec) = @_;
+ my $c = $self->new_xy_chart($spec);
+ my $x = $self->get_x($spec);
+ my $yn = $self->get_y($spec);
+ my ($layer, $dataset);
+ my @symbols = (
+ { symbol => $perlchartdir::SquareSymbol, size => 7, },
+ { symbol => $perlchartdir::DiamondSymbol, size => 9, },
+ { symbol => $perlchartdir::CircleShape, size => 7, },
+ { symbol => $perlchartdir::TriangleShape, size => 8, },
+ );
+ $layer = $c->addStepLineLayer();
+ $layer->setLineWidth(2);
+
+ if ($#$yn > 0) {
+ my ($stacked_y, $y, $dataset);
+ my $y_labels = $spec->{y_labels} || [];
+ for (my $i = 0; $i <= $#$yn; $i++) {
+ $y = $yn->[$i];
+
+ $dataset = $layer->addDataSet($y, -1, $y_labels->[$i]);
+ $dataset->setDataSymbol($self->sym($i, [EMAIL PROTECTED])) if
($spec->{points});
+ }
+ }
+ elsif ($#$yn > -1) {
+ $layer = $c->addStepLineLayer($yn->[0]);
+ $layer->setLineWidth(5);
+ }
+ if ($spec->{point_labels}) {
+ my $label_format = $spec->{point_labels};
+ $label_format = "{value|0}" if ($label_format eq "1");
+ $layer->setDataLabelFormat($label_format);
+ }
+
+ $self->set_x_axis($spec, $c, $layer, $x);
+
+ $c->makeChart($spec->{image_path});
+ &App::sub_exit() if ($App::trace);
+}
+
1;