Chart-Plot

 view release on metacpan or  search on metacpan

demo.cgi  view on Meta::CPAN

#!/usr/bin/perl

# CGI Demonstration of Plot.pm
#     Place Chart/Plot.pm beneath this script's directory,
#        or use lib '...'
#        or just install Chart::Plot
#     Make sure there is also a writable tmp subdirectory here.
#     Requires both GD.pm and CGI.pm.
#     Copyright 1998 Sanford Morton <smorton@pobox.com>.

use CGI::Carp qw(fatalsToBrowser carpout);
use CGI;
use Plot; #use Chart::Plot;
# use strict;
# use cgidebug;

sub web_print {
  print "Content-type: text/html\n\n<html><body>\n$_[0]\n</body></html>";
  exit;
}

my $web_form = <<"HERE";
<FORM METHOD=POST>
<CENTER><H1>CGI Demonstration of Plot.pm</H1></CENTER>
<TABLE BORDER=0><TR><TD>
Enter your data, one data point per line. Enter the independent (x) variable 
followed by the dependent (y) variable separated by whitespace, like this
<PRE>
1.5  -325
2.75 450.7
3 645
</PRE>
Do not enter any other symbols. There is a limit of 100 data points
in this demonstration. 
</TD><TD>
<TEXTAREA COLS=20 ROWS=10 NAME=data></TEXTAREA>
</TD></TR></TABLE><P>
All the following are optional (CAPS are the default):<UL>
<LI>Plot data with 
    <INPUT TYPE=RADIO NAME=linestyle VALUE=solidline checked> SOLID lines,
    <INPUT TYPE=RADIO NAME=linestyle VALUE=dashedline> dashed lines, or
    <INPUT TYPE=RADIO NAME=linestyle VALUE=noline> no lines? <BR>
    Plot with 
    <INPUT TYPE=RADIO NAME=pointstyle VALUE=points checked> POINTS or
    <INPUT TYPE=RADIO NAME=pointstyle VALUE=nopoints> no points? <BR>
    What color,
    <INPUT TYPE=RADIO NAME=colorstyle VALUE=red> red, 
    <INPUT TYPE=RADIO NAME=colorstyle VALUE=green> green, 
    <INPUT TYPE=RADIO NAME=colorstyle VALUE=blue> blue or
    <INPUT TYPE=RADIO NAME=colorstyle VALUE=black checked> BLACK?
<LI>Enter a title for the graph: <INPUT TYPE=TEXT NAME=title>.
<LI>Enter labels for the axes:
    Hor: <INPUT TYPE=TEXT NAME=horAxisLabel> 
    Vert: <INPUT TYPE=TEXT NAME=vertAxisLabel>
<LI>Image size (default 400x400, max 640x480 in this demonstration): 
    Hor: <INPUT TYPE=TEXT NAME=horImgSz SIZE=3>
    Vert: <INPUT TYPE=TEXT NAME=verImgSz SIZE=3>
<LI>Pixel distance from graph to image boundary (default 50x50):
    Hor: <INPUT TYPE=TEXT NAME=horGraphOffset SIZE=3>
    Vert: <INPUT TYPE=TEXT NAME=vertGraphOffset SIZE=3>
</UL>
<TABLE BORDER=0><TR><TD>
Enter your own horizontal tick labels here. Enter an x-axis position followed
by the label at that position on the horizontal axis, one per line. Like this:
<PRE>
1 One o\'clock
2 Two o\'clock
3 Three o\'clock
</PRE>
Leave this blank to have tick labels drawn automatically.
</TD><TD>
<TEXTAREA COLS=20 ROWS=10 NAME=xTickLabels></TEXTAREA>
</TD></TR></TABLE><P>

<INPUT TYPE=SUBMIT> <INPUT TYPE=RESET></FORM>



( run in 0.881 second using v1.01-cache-2.11-cpan-5735350b133 )