Need help with Chart::OFC

Need help with Chart::OFC

am 05.01.2008 04:04:38 von ron

This is Debian, with the usual suspects:
Apache/2.2.6 (Unix) mod_fastcgi/2.4.6 mod_perl/2.0.3 Perl/v5.8.8.

I've installed Flash and successfully tested the demo my.cgi which
comes with Open Flash Chart.

However, when I replace the data generating code in my.cgi
(renamed ofc.1.cgi) with calls to Chart::OFC::* (from the latter's
t/Grid.t and t/Pie.t) I get a HTTP error:
[Sat Jan 05 13:52:40 2008] [error] [client 127.0.0.1] malformed header
from script. Bad header=&pie=80,#000000,#000000&: ofc.1.cgi.

Code:
=====><8=====
#!/usr/bin/perl

use strict;
use warnings;

use CGI qw/:standard/;
use Chart::OFC::Dataset;
use Chart::OFC::Dataset::Bar;
use Chart::OFC::Grid;
use Chart::OFC::Pie;
use Chart::OFC::XAxis;
use Chart::OFC::YAxis;

# ---------------------------

sub swf_object {
my $width = shift;
my $height = shift;
my $url = shift;

print ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cab s/flash/
swflash.cab#version=8,0,0,0" width="400" height="300" id="graph-2"
align="middle">';
print '';
print " $width&height=$height&data=$url /> \" />";
print ' bgcolor="#FFFFFF" width="'. $width .'" height="'. $height .'"
name="open-flash-chart" align="middle" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://
www.macromedia.com/go/getflashplayer" />';
print '
';

}

# ---------------------------

if( !param() ) {

print header, start_html( -title => "Open Flash Demo" );
swf_object( 600, 250, 'http://127.0.0.1/cgi-bin/ofc.1.cgi?data' );
print "\n";

} else {

=pod

my @datasets = Chart::OFC::Dataset::Bar->new( values => [ 1 .. 5] );
my $x_axis = Chart::OFC::XAxis->new( axis_label => 'X Axis' );
my $y_axis = Chart::OFC::YAxis->new( axis_label => 'Y Axis', max =>
100, label_steps => 20 );

my $chart = Chart::OFC::Grid->new( title => 'Grid Test',
inner_bg_color => '#FFFF00',
inner_bg_color2 => '#FFFFFF',
inner_bg_fade_angle => 152,
datasets => \@datasets,
x_axis => $x_axis,
y_axis => $y_axis,
);

print $chart->as_ofc_data();

=cut

my $set = Chart::OFC::Dataset->new( values => [ 1..10 ] );
my $pie = Chart::OFC::Pie->new( title => 'Pie Test', dataset => $set,
labels => [ 'a'..'j' ] );

print $pie->as_ofc_data();

}
=====><8=====

Lastly, if I comment out all Chart::OFC code in this program, and plug
back in the original code from my.cgi, the code works.

Any ideas?
TIA.

--
Ron Savage
http://savage.net.au/index.html

Re: Need help with Chart::OFC

am 06.01.2008 02:09:19 von ron

On Jan 5, 2:04 pm, r...@savage.net.au wrote:

Hi Ron

> Any ideas?

Yep.

Chart::OFC ships with OFC V 1.9.5, but I installed V 1.9.6.

Unfortunately the author of OFC changed the method of concatenating
data strings, for whatever reason.

I had to edit Chart::OFC.pm line 52 to be:

return $CRLF . join '', map { "$_ \n" } @lines;

Now, Chart::OFC works!

Many thanx to both authors.

OFC's home is: http://teethgrinder.co.uk/open-flash-chart/

--
Ron Savage

http://savage.net.au/index.html