in reply to gnuplot and CGI
However, because I need to change the gnuplot set commands based on user input, I want to do this differently. Something like#!/usr/bin/perl -w # test4.pl for testing real-time graph capabilities # November 9, 2004 use CGI qw( :standard ); use CGI::Carp 'fatalsToBrowser'; my $q = new CGI; my $station = $q->param('sta'); my $constituent = $q->param('const'); my $combined = "$station" . "$constituent"; my $img = `/usr/local/bin/gnuplot $station $constituent $combined`; print $q->header("image/png"), $img;
#!/usr/bin/perl -w # test5.pl for testing real-time graph capabilities # November 17, 2004 use CGI qw( :standard ); use CGI::Carp 'fatalsToBrowser'; #will print error message to user $CGI::POST_MAX = 512; # limit maximum posting size to 512 bytes $CGI::DISABLE_UPLOADS = 1; # disables uploading files entirely my $q = new CGI; my $data = "05056670.txt"; print $q->header("image/png\n\n"); my $img = plotdata(); sub plotdata { open my $graph => "| /usr/local/bin/gnuplot" or die "Failed to open +pipe: $!\n"; print $graph <<"gnu"; set terminal png color set output set xdata time set timefmt "%Y%m%d" set key left top title "Legend" box set grid xtics ytics set yrange [700:] set format x "%Y" set xlabel "Year" set ylabel "Sodium, water, filtered, milligrams per liter" set title "05056670 Western Stump Lake Major Ions" plot "$data" using 2:3 title "P00930 Sodium dissolved" gnu close $graph or die "Failed to close pipe: $!\n"; }
|
|---|