version 1.128, 2007/08/09 06:25:43
|
version 1.132, 2007/12/05 23:22:18
|
Line 36 use Apache::response;
|
Line 36 use Apache::response;
|
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::edit; |
use Apache::edit; |
use Apache::lonnet; |
use Apache::lonnet; |
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
use LONCAPA; |
|
|
|
|
use vars qw/$weboutputformat $versionstring/; |
use vars qw/$weboutputformat $version/; |
|
|
|
|
|
|
Line 49 BEGIN {
|
Line 48 BEGIN {
|
# |
# |
# Determine the version of GNUPLOT |
# Determine the version of GNUPLOT |
$weboutputformat = 'gif'; |
$weboutputformat = 'gif'; |
$versionstring = `gnuplot --version 2>/dev/null`; |
my $versionstring = `gnuplot --version 2>/dev/null`; |
if ($versionstring =~ /^gnuplot 4/) { |
($version) = ($versionstring =~ /^gnuplot ([\d.]+)/); |
|
if ($version >= 4) { |
$weboutputformat = 'png'; |
$weboutputformat = 'png'; |
} |
} |
|
|
Line 435 my %tic_defaults =
|
Line 435 my %tic_defaults =
|
}, |
}, |
); |
); |
|
|
my @axis_edit_order = ('color','xmin','xmax','ymin','ymax'); |
my @axis_edit_order = ('color','xmin','xmax','ymin','ymax','xformat', 'yformat'); |
my %axis_defaults = |
my %axis_defaults = |
( |
( |
color => { |
color => { |
Line 472 my %axis_defaults =
|
Line 472 my %axis_defaults =
|
description => 'Maximum y-value shown in plot', |
description => 'Maximum y-value shown in plot', |
edit_type => 'entry', |
edit_type => 'entry', |
size => '10' |
size => '10' |
} |
}, |
|
xformat => { |
|
default => 'on', |
|
test => sub {$_[0]=~/^(on|off|\d+(f|F|e|E))$/}, |
|
description => 'X-axis number formatting', |
|
edit_type => 'choice', |
|
choices => ['on', 'off', '2e', '2f'], |
|
}, |
|
yformat => { |
|
default => 'on', |
|
test => sub {$_[0]=~/^(on|off|\d+(f|F|e|E))$/}, |
|
description => 'X-axis number formatting', |
|
edit_type => 'choice', |
|
choices => ['on', 'off', '2e', '2f'], |
|
}, |
|
|
); |
); |
|
|
my @curve_edit_order = ('color','name','linestyle','linewidth','pointtype','pointsize','limit'); |
my @curve_edit_order = ('color','name','linestyle','linewidth','pointtype','pointsize','limit'); |
Line 501 my %curve_defaults =
|
Line 516 my %curve_defaults =
|
choices => [keys(%linestyles)] |
choices => [keys(%linestyles)] |
}, |
}, |
linewidth => { |
linewidth => { |
default => 2, |
default => 1, |
test => $int_test, |
test => $int_test, |
description => 'Line width (may not apply to all line styles)', |
description => 'Line width (may not apply to all line styles)', |
edit_type => 'choice', |
edit_type => 'choice', |
Line 1259 sub write_gnuplot_file {
|
Line 1274 sub write_gnuplot_file {
|
if (lc($Apache::lonplot::plot{'bmargin'}) ne 'default') { |
if (lc($Apache::lonplot::plot{'bmargin'}) ne 'default') { |
$gnuplot_input .= 'set bmargin '.$Apache::lonplot::plot{'bmargin'}.$/; |
$gnuplot_input .= 'set bmargin '.$Apache::lonplot::plot{'bmargin'}.$/; |
} |
} |
|
|
# tic scales |
# tic scales |
$gnuplot_input .= 'set ticscale '. |
if ($version > 4) { |
$Apache::lonplot::plot{'major_ticscale'}.' '.$Apache::lonplot::plot{'minor_ticscale'}.$/; |
$gnuplot_input .= 'set tics scale '. |
|
$Apache::lonplot::plot{'major_ticscale'}.', '.$Apache::lonplot::plot{'minor_ticscale'}.$/; |
|
} else { |
|
$gnuplot_input .= 'set ticscale '. |
|
$Apache::lonplot::plot{'major_ticscale'}.' '.$Apache::lonplot::plot{'minor_ticscale'}.$/; |
|
} |
#boxwidth |
#boxwidth |
if (lc($Apache::lonplot::plot{'boxwidth'}) ne '') { |
if (lc($Apache::lonplot::plot{'boxwidth'}) ne '') { |
$gnuplot_input .= 'set boxwidth '.$Apache::lonplot::plot{'boxwidth'}.$/; |
$gnuplot_input .= 'set boxwidth '.$Apache::lonplot::plot{'boxwidth'}.$/; |
Line 1315 sub write_gnuplot_file {
|
Line 1336 sub write_gnuplot_file {
|
} |
} |
# axis |
# axis |
if (%axis) { |
if (%axis) { |
|
if ($axis{'xformat'} ne 'on') { |
|
$gnuplot_input .= "set format x "; |
|
if ($axis{'xformat'} eq 'off') { |
|
$gnuplot_input .= "\"\"\n"; |
|
} else { |
|
$gnuplot_input .= "\"\%.".$axis{'xformat'}."\"\n"; |
|
} |
|
} |
|
if ($axis{'yformat'} ne 'on') { |
|
$gnuplot_input .= "set format y "; |
|
if ($axis{'yformat'} eq 'off') { |
|
$gnuplot_input .= "\"\"\n"; |
|
} else { |
|
$gnuplot_input .= "\"\%.".$axis{'yformat'}."\"\n"; |
|
} |
|
} |
$gnuplot_input .= "set xrange \[$axis{'xmin'}:$axis{'xmax'}\]\n"; |
$gnuplot_input .= "set xrange \[$axis{'xmin'}:$axis{'xmax'}\]\n"; |
$gnuplot_input .= "set yrange \[$axis{'ymin'}:$axis{'ymax'}\]\n"; |
$gnuplot_input .= "set yrange \[$axis{'ymin'}:$axis{'ymax'}\]\n"; |
} |
} |
Line 1355 sub write_gnuplot_file {
|
Line 1392 sub write_gnuplot_file {
|
$curve->{'function'}.' title "'. |
$curve->{'function'}.' title "'. |
$curve->{'name'}.'" with '. |
$curve->{'name'}.'" with '. |
$curve->{'linestyle'}; |
$curve->{'linestyle'}; |
$gnuplot_input.= ' linewidth '.$curve->{'linewidth'}; |
|
|
|
if (($curve->{'linestyle'} eq 'points') || |
if (($curve->{'linestyle'} eq 'points') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'linespoints') || |
Line 1368 sub write_gnuplot_file {
|
Line 1404 sub write_gnuplot_file {
|
} elsif ($curve->{'linestyle'} eq 'filledcurves') { |
} elsif ($curve->{'linestyle'} eq 'filledcurves') { |
$gnuplot_input.= ' '.$curve->{'limit'}; |
$gnuplot_input.= ' '.$curve->{'limit'}; |
} |
} |
|
$gnuplot_input.= ' linewidth '.$curve->{'linewidth'}; |
|
|
} elsif (exists($curve->{'data'})) { |
} elsif (exists($curve->{'data'})) { |
# Store data values in $datatext |
# Store data values in $datatext |
my $datatext = ''; |
my $datatext = ''; |
Line 1391 sub write_gnuplot_file {
|
Line 1429 sub write_gnuplot_file {
|
$gnuplot_input.= '"'.$datafilename.'" title "'. |
$gnuplot_input.= '"'.$datafilename.'" title "'. |
$curve->{'name'}.'" with '. |
$curve->{'name'}.'" with '. |
$curve->{'linestyle'}; |
$curve->{'linestyle'}; |
$gnuplot_input.= ' linewidth '.$curve->{'linewidth'}; |
|
if (($curve->{'linestyle'} eq 'points') || |
if (($curve->{'linestyle'} eq 'points') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'errorbars') || |
($curve->{'linestyle'} eq 'errorbars') || |
Line 1403 sub write_gnuplot_file {
|
Line 1440 sub write_gnuplot_file {
|
} elsif ($curve->{'linestyle'} eq 'filledcurves') { |
} elsif ($curve->{'linestyle'} eq 'filledcurves') { |
$gnuplot_input.= ' '.$curve->{'limit'}; |
$gnuplot_input.= ' '.$curve->{'limit'}; |
} |
} |
|
$gnuplot_input.= ' linewidth '.$curve->{'linewidth'}; |
} |
} |
} |
} |
# Write the output to a file. |
# Write the output to a file. |