graphs in web pages, part 2 (GNUPLOT, PERL)
we want a graph that spans the last seven days that indicates the number of work order requests opened on each of the days as well as the number of requests that are closed on each day.
remembering some failed attempts at using gnuplot in grad school, i thought i would finally rectify my ignorance on the subject and do my job at the same time. i wrote a php program that grabbed the stats, wrote them to a file, and created a PNG image file of the graph with this data. this worked from the command but not from a browser (b/c of ownership, permissions, i don't know). i put this aside when someone told me perl has a nice module for creating graphs quickly.
the perl GD::Graph module did what i needed and in only about 60 lines of code (this includes reading a username and password from a hidden file, connecting to a database, executing a couple of queries there, passing the options to the graph object, and graphing it).
while this displays in a browser, it must be in the cgi-bin directory (it has a .cgi extension) which limits where it can be put. i'm sure i can change my server configuration to allow it to run from any directory but maybe i dont want to do this. is it because it uses C code that it must be in /cgi-bin???? how come php programs can execute from any directory and perl programs can't???
another drawback is that i want to incorporate this graph into an existing web site written in PHP. since it should be accessible by administrators, it needs to includes a check on session info which i need to do from PHP. also, it should be in the same directory and not in cgi-bin.
the question now is can i convert this to php? the "literature" (info online) and a few brief experiments seem to indicate that it is not as easy to do in basic php. the next step is to see if there is a PEAR package that handles what i need...
more later.
remembering some failed attempts at using gnuplot in grad school, i thought i would finally rectify my ignorance on the subject and do my job at the same time. i wrote a php program that grabbed the stats, wrote them to a file, and created a PNG image file of the graph with this data. this worked from the command but not from a browser (b/c of ownership, permissions, i don't know). i put this aside when someone told me perl has a nice module for creating graphs quickly.
the perl GD::Graph module did what i needed and in only about 60 lines of code (this includes reading a username and password from a hidden file, connecting to a database, executing a couple of queries there, passing the options to the graph object, and graphing it).
while this displays in a browser, it must be in the cgi-bin directory (it has a .cgi extension) which limits where it can be put. i'm sure i can change my server configuration to allow it to run from any directory but maybe i dont want to do this. is it because it uses C code that it must be in /cgi-bin???? how come php programs can execute from any directory and perl programs can't???
another drawback is that i want to incorporate this graph into an existing web site written in PHP. since it should be accessible by administrators, it needs to includes a check on session info which i need to do from PHP. also, it should be in the same directory and not in cgi-bin.
the question now is can i convert this to php? the "literature" (info online) and a few brief experiments seem to indicate that it is not as easy to do in basic php. the next step is to see if there is a PEAR package that handles what i need...
more later.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home