Subject: | Graph output going to standard error |
Date: | Thu, 27 Feb 2014 04:56:01 +0000 |
To: | "'bug-Chart-Gnuplot [...] rt.cpan.org'" <bug-Chart-Gnuplot [...] rt.cpan.org> |
From: | "Ford, Alan" <Alan.FORD [...] stanwell.com> |
Hi,
Great product, really handy.
I had to modify you Gnuplot.pm to allow streaming to STDOUT...
This program would stream the result to STDERR
#----- Start prog -----#
#!/usr/bin/perl
use Switch;
use Chart::Gnuplot;
# Input data source
my @x = (-10 .. 10);
my @y = (0 .. 20);
# Chart object
my $chart = Chart::Gnuplot->new(
gnuplot => "/usr/local/bin/gnuplot",
terminal => "png",
output => "| base64",
);
# Data set object
my $dataSet = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y,
);
# Plot the graph
$chart->plot2d($dataSet);
#----- End prog ----#
The change I made was at line 1001
Your code...
#---- Begin Snippet ----#
# Execute gnuplot
my $cmd = qq("$gnuplot" "$self->{_script}");
$cmd .= " -" if ($self->{terminal} =~ /^(ggi|pm|windows|wxt|x11)(\s|$)/);
my $err = `$cmd 2>&1`;
# my $err;
# system("$cmd");
#---- End Snippet ----#
My code...
#---- Begin Snippet ----#
# Execute gnuplot
my $cmd = qq("$gnuplot" "$self->{_script}");
$cmd .= " -" if ($self->{terminal} =~ /^(ggi|pm|windows|wxt|x11)(\s|$)/);
my $TmpFile = "/tmp/gnuplot.$$.err";
my $out = `$cmd 2>$TmpFile`;
my $err = `cat $TmpFile`;
`rm -f $TmpFile > /dev/null 2>&1`;
# my $err;
# system("$cmd");
# Print normal output
if (defined $out && $out ne '')
{
print $out;
}
#---- End Snippet ----#
Thanks
Alan Ford
Senior Database Administrator
Com Serv - Information Communications and Technology
Stanwell Corporation Limited
Tel (07) 3335 7243 | Mob 0407 610 141
GPO Box 773, Brisbane, QLD 4001
www.stanwell.com<http://www.stanwell.com>
This email is to be read subject to the email disclaimer located at http://www.stanwell.com/email-disclaimer.aspx