Hallo, ich habe ein kleines Problem bei der Darstellung einer Grafik. Ein Programm macht eine Datenbankabfrage und gibt dann die Ergebnisse an ein weiteres Perl-Programm weiter welches einen Chart erstellt und dann auf einer HP darstellen soll.
Hier der Teil von Programm1 der die Daten weitergibt:
@X_Value = (11, 2, 13, 4, 5);
@Y_Value = (15, 4, 3, 12, 1);
$x_label = "Dates";
$y_label = "Errors";
$title = "Chart for Error";require chart;
&chart::graph(\@X_Value, \@Y_Value, $x_label, $y_label, $title);
und hier das Programm2:
#!/usr/local/bin/perl -wuse CGI ':standard';
use GD::Graph::bars;
use strict;
package chart;
#*****Data passed by another Program*****
sub graph
{
my $X_Value_Ref = $_[0];
my $Y_Value_Ref = $_[1];
my $x_label = $_[2];
my $y_label = $_[3];
my $title = $_[4];
#****************************************
my @data = ([@{$X_Value_Ref}], [@{$Y_Value_Ref}]);
my $mygraph = GD::Graph::bars->new(500, 300);
$mygraph->set(
x_label => "$x_label",
y_label => "$y_label",
title => "$title",
# Draw bars with width 3 pixels
bar_width => 3,
# Sepearte the bars with 4 pixels
bar_spacing => 4,
# Show the grid
long_ticks => 1,
# Show values on top of each bar
show_values => 1,
) or warn $mygraph->error;
my $myimage = $mygraph->plot(\@data) or die $mygraph->error;
print "Content-type: image/png\n\n";
print $myimage->png;
}
1;
Und das Ergebnis auf der Homepage ist anstatt des Bildes folgender Text:
Content-type: image/png
‰PNG#+`%%IHDR ...und noch alle möglichen anderen Zeichen.
Kann mir jemand weiterhelfen und sieht wo der Fehler bei der Ausgabe liegt?
Vielen Dank schonmal für eure Hilfe
Gruss Tobi
Datum: 22.02.2005-22:27
