--- loncom/xml/lonplot.pm 2014/07/09 15:17:32 1.152.6.1 +++ loncom/xml/lonplot.pm 2011/07/04 09:25:13 1.153 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.152.6.1 2014/07/09 15:17:32 raeburn Exp $ +# $Id: lonplot.pm,v 1.153 2011/07/04 09:25:13 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -634,6 +634,8 @@ sub end_gnuplot { ('title','xlabel','ylabel','key','axis','label','curve')); my $result = ''; my $randnumber; + my $tmpdir =LONCAPA::tempdir(); # Where temporary files live: + # need to call rand everytime start_script would evaluate, as the # safe space rand number generator and the global rand generator # are not separate @@ -645,7 +647,6 @@ sub end_gnuplot { &check_inputs(); # Make sure we have all the data we need ## ## Determine filename - my $tmpdir = '/home/httpd/perl/tmp/'; my $filename = $env{'user.name'}.'_'.$env{'user.domain'}. '_'.time.'_'.$$.$randnumber.'_plot'; ## Write the plot description to the file @@ -666,7 +667,7 @@ ENDIMAGE #might be inside the safe space, register the URL for later &Apache::lonxml::register_ssi("/cgi-bin/plot.gif?file=$filename.data&output=eps"); $result = "%DYNAMICIMAGE:$Apache::lonplot::plot{'width'}:$Apache::lonplot::plot{'height'}:$Apache::lonplot::plot{'texwidth'}\n"; - $result .= '\graphicspath{{/home/httpd/perl/tmp/}}'."\n"; + $result .= '\graphicspath{{'.$tmpdir.'}}'."\n"; $result .= '\includegraphics[width='.$Apache::lonplot::plot{'texwidth'}.' mm]{'.&unescape($filename).'.eps}'; } } elsif ($target eq 'edit') { @@ -1609,7 +1610,7 @@ sub write_gnuplot_file { } $gnuplot_input .= ' "'.$font_properties->{'printname'}.'" '; $gnuplot_input .= $fontsize; - $gnuplot_input .= "\nset output \"/home/httpd/perl/tmp/". + $gnuplot_input .= "\nset output \"".$tmpdir. &unescape($filename).".eps\"\n"; $gnuplot_input .= "set encoding iso_8859_1\n"; # Get access to extended font. @@ -1681,12 +1682,8 @@ sub write_gnuplot_file { $gnuplot_input .= "set samples $Apache::lonplot::plot{'samples'}\n"; # title, xlabel, ylabel # titles - my $offset; - if ($version >= 4.4) { - $offset = 'offset '; - } - my $extra_space_x = ($xtics{'location'} eq 'axis') ? ' '.$offset.'0, -0.5 ' : ''; - my $extra_space_y = ($ytics{'location'} eq 'axis') ? ' '.$offset.'-0.5, 0 ' : ''; + my $extra_space_x = ($xtics{'location'} eq 'axis') ? ' 0, -0.5 ' : ''; + my $extra_space_y = ($ytics{'location'} eq 'axis') ? ' -0.5, 0 ' : ''; if ($target eq 'tex') { $gnuplot_input .= "set title \"$title\" font \"".$font_properties->{'printname'}.",".$fontsize."pt\"\n" if (defined($title)) ;