PhosphoricX has asked for the wisdom of the Perl Monks concerning the following question:
Oh wise monks,
I'm creating a report that will list of the memory use on our board from the C make file. I'm trying to figure out what the best library to use would be. I'm considering this report to be either a PDF, Excel or SVG file. I've considered using GD to create the graphics, but I am having problems with it on my Windows NT machine. The various PDF Modules are also giving me trouble as well as the SVG Modules. Have anyone every generated something similar to this on a Windows NT machine? I'm trying to avoid having to use Excel because, I think that that it would looks much nicer if it were a PDF or SVG. Your comments and/or suggestion would be most appreciated.
Re: Document with Graphics
by EvdB (Deacon) on Mar 25, 2004 at 13:48 UTC
|
Not the question you asked, but... I find that ascii art can work wonders at times:
my %data = ( first => 12,
second => 45,
third => 27 );
foreach my $bit ( keys %data ) {
print "$bit:\t", '-' x $data{$bit}, " $data{$bit}\n";
}
Produces:
first: ------------ 12
second: --------------------------------------------- 45
third: --------------------------- 27
It may not be perty but it is fast, flexible and portable.
--tidiness is the memory loss of environmental mnemonics
| [reply] [d/l] [select] |
|
...
printf "%8s:\t%s %2d\n", $bit, "-" x $data{$bit}, $data{$bit};
...
Update:
And of course you can get even fancier by making your graph lines a fixed width (say 50 characters) and mapping that into marks and spaces so that the actual values are lined up nicely as well.
...
my $marks = "-" x int( ( $data{ $bit } / MAXDATA ) * 50.0 );
my $blanks = " " x ( 50 - $data );
printf "%8s:\t%s%s %2d\n", $bit, $marks, $blanks, $data{ $bit };
| [reply] [d/l] [select] |
|
But if we are getting fussy then we can't assume that the keys in the hash are less than eight letters long (or that tabs are 8 chars). With this assumption we'll lose alignment for large keys:
small: ----- 5
really big key: -------- 8
I see that you reduce the keys to 8 chars, but this may not work for keys such as "TotalSales2003", "TotalSales2004" etc. This is why I hate 'pertyness', there is always something to break it...
--tidiness is the memory loss of environmental mnemonics
| [reply] [d/l] [select] |
Re: Document with Graphics
by halley (Prior) on Mar 25, 2004 at 14:51 UTC
|
Presenting data is an extremely fussy business, where you'll be tweaking and altering it often. Once a middle-manager sees a chart, it is just about mandatory that they have to add their own, uh, mark of excellence. These changes are often completely irrelevant, but it's self-defeating to deny them this luxury in many cases. "Yeah, and get rid of that font. I like Tahoma."
So the priority is on making it bone-simple and quick to incorporate presentation and style changes.
I would also recommend HTML, using the minimum of machine-generated graphics. PDF is *usually* too cumbersome to author and revise. SVG is worse, but only because it's so nascent that the available tools are weak. I wouldn't rule them out, except that they also raise the complexity of ensuring your audience is configured to view them properly. Everyone can view paper, and everyone who is anyone can view HTML.
In those cases where the machine-generated graphics are important, use the method which takes tabular data and creates the basic plots as distinct graphics files. In a quickly configurable way, if you have too many middle-managers.
-- [ e d @ h a l l e y . c c ]
| [reply] |
Re: Document with Graphics
by soon_j (Scribe) on Mar 25, 2004 at 15:19 UTC
|
On my opinion, if you publish a report, just use plain HTML if you are just concerned with showing bars or histograms. If you need to show pie charts or complex charts, you can use GD or Chart to format them and show them through your pages.
From those pages, include a link that allows them to download such report in pure text (then include the previous suggestion of using ASCII art) or in PDF.
| [reply] |
Re: Document with Graphics
by eserte (Deacon) on Mar 25, 2004 at 14:17 UTC
|
My suggestion: use HTML and generated images. Either use the print function of your browser or a tool like html2ps or htmldoc to create Postscript or PDF. GD surely should work under Windows. What is exactly your problem? | [reply] |
Re: Document with Graphics
by toma (Vicar) on Mar 26, 2004 at 08:41 UTC
|
For really nice looking graphics, there are a few
great packages that will work. One is
R. R makes graphs
and also includes a data modeling language and
advanced statistical analysis tools.
You can create Postscript with R.
It is easy to translate this Postscript to PDF.
To use R within a perl program, you could try
Statistics::R. I have not tried this module
yet.
PGPLOT
is probably the best package available for drawing
graphs, but may be too difficult for you on NT.
PGPLOT supports many output formats, both
vector and bitmap.
To use PGPLOT within a perl program, use
PGPLOT. This module has worked for me.
It should work perfectly the first time! - toma
| [reply] |
|
|