[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Generating on-the-fly diagrams



>What is the easiest way to generate on-the-fly diagrams in a web client
>with MacPerl?
I think you meant in the web server and displayed by the web client.

there a several possibilities. 
1)
if you want to visualise a few numbers, it may be the easiest to
use a text-only vertical bar-chart
Perl has a multiply-char operator to make this even more easy:
if $i is the number, use

  $barline = '|' x $i;

Thanks to the proportional fonts of the webbrowsers
the spacing between the lines is small and
it looks better than you might expect.
you can also set the html-fontcolors to get different colors for the 
charts.
This is also the fastest method.

2)
also for bargraphs: use a static gif and set heigh and width attributs:

sub barChart{
	my($value, $maxValue) = @_;
	my($cent) = $value * 100 / $maxValue;
	my($barLen) = $cent * 2;     # 100% is 200 points
	print HTML                   # HTML is Output Filehanle, delete for 
stdout
		qq(<img src="$bargif" width="$barLen" height="12" alt="$cent">); 
                              # qq(...) is like "...", but you can 
include ""
                              # very useful to generate html
}

This is also recommended if you want that blind people using a screen 
reader
have access to the numbers, because the real number is in the Alt-Text.

3)
use the gd-package to create gif's on the fly.
it is included in the macperl distrbution
Thomas Boutell, one of the creators of the gd libary,
has written a book:
"CGI Programming in C & Perl" (Addison Wesley)
where you can find examples for this and other cgi-problems.

4)
For really impressive results, use the pdf-pl library
to generate Acrobat-pdf Files on the Fly.
 available from http://www.ep.cs.nott.ac.uk/pdf-pl/
It works on the mac out of the box,
you have a vector based file format, so the user can magnify
the charts, and the thing is better printable than a browserpage.

5)
...(there must be much more possibilities)




---------------------------------------------------------------------
Karsten Meier
EMail krstnmr@ibm.net
WWW: http://www.dezines.com/meier
Unsolicited and/or commercial email is not permitted at this address.



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch