Custom Charts w/ Perl and GD
An anonymous reader writes "This article describes techniques you can use to create new levels of usefulness in your dynamically generated charts with Perl and GD. Cook up some automatically generated graphs for your organizational meetings or live enterprise directory data. Annotate the charts with readable text that delivers more information than the standard pie chart. Using the power of GD and Perl, you can link various data and images together to create sophisticated charts that will help bring visual interest to your applications."
When will open source advocates learn to delegate the graphic design aspect of their work to professionals? Plenty of designers would be more than happy to contribute, if only the programming types in charge of these projects would admit they're better at making code than graphics.
With a general purpose language tied to a drawing library I can make custom graphics? Holy crap, who would have thought. For those of us who just want to generate some simple graphs for papers and such, what do people use? I've messed with Excel, gnuplot, R, and now I'm using ploticus. Anyone have better solutions?
Ah, the summary was so close to getting the words 'perl' and 'readable' in the same sentence (possibly for the first time), but just couldn't quite pull it off.
ccalam - acoustic versions of new songs.
... there's matplotlib and there's reportlab for PDFs. Both are excellent open source packages, and I can tell you from experience that reportlab has outstanding support. I recently posted a question to their mailing list and received three intelligent replies within an hour.
I don't know man, they have a donut chart on there with some pretty serious graphics laid into it. That beats most other articles with their plain Jane donut charts, these ones have upper management written all over them.
Maybe they should email a link to Edward Tufte...amybe he'll be insterested. Data graphic geniuses these folks.
"Sacrifice for the good of The State" - The State
I was looking for graphing and charting stuff last year. The only thing I found at the time was ChartDirector. There have been a couple of other open source ones posted above that I may investigate in future, but finding this was what I needed at the time.
Professor Karmadillo Songs of Science
...that pie charts are evil. However there are exceptions, like this one: http://themot.org/gallery/d/58721-1/pacmanchart.pn g. Most informative.
Agreed. I had the same problem not too long ago about making dynamic charts that look professional.
My solution was to use Perl and Win32::OLE to interface with Excel 2003 using VBA scripting within Perl. Sure, it's a Windows-only solution, and it's not open source, but it was an intranet problem that needed to be solved.
Remember how programmers always talk about using the right tool for the right job?
If you want to do something like graphing, then why not learn a language like R, where you can easily and interactively create amazing visuals in very little time? I write code in Java, python, bash, and interact with Oracle and MySQL database. R fits in as a nice way to visualize data, and it's very easy to script up solutions that you can plug into your programming pipeline.
Check out http://addictedtor.free.fr/graphiques/index.php for examples (with source code)
With a general purpose language tied to a drawing library I can make custom graphics? Holy crap, who would have thought.
LibGD was made for this but does more now. There are lots of applications to do the same but "use libGD" is a good tip for people who want to make dynamic images and graphs for web pages from data.
For those of us who just want to generate some simple graphs for papers and such, what do people use? I've messed with Excel, gnuplot, R, and now I'm using ploticus.
gnuplot is very powerful. It has fitting with regression analysis, reports reduced chi squared and other math muscle stuff for papers all from text files.
Gnumeric is a good replacement for excel. It's resource light and the math is correct. It does simple graphs for papers and such.
DMCA, Hollings, Palladium. What might have sounded like paranoia is now common sense.
Or use Ruby with Gruff.
Vote Libertarian
Have you seen this? http://www.advsofteng.com/
No Sig for you.!
I make my PHP scripts output SVG. I feed it to ImageMagick's "convert", and then outputs it to the user.
Yeah, it does seem a bit overkill.
If you're organization is so dynamic that your org. chart NEEDs to be generated at runtime by a script on your web server, then maybe writing perl scripts to auto-generate org charts shouldn't be your highest priority.
Freedom is the freedom to say 2+2=4, everything else follows...
Those charts look pretty hot to me. Did you look at the chart in the page? http://www-128.ibm.com/developerworks/opensource/l ibrary/os-perlgdchart/pie_step1_step2.gif :]
c tive_Pie_Chart.gif. odc_vststockallocation2003_fig03(en-us,office.11). gif
e fox
). Anti-aliased lines and text
Let's compare this to what I'd get if I asked most professionals for a chart. (These were the first ones from google). The lack of anti-aliasing hurts one's eye, these all look like they're from 1995.
http://support.alphasoftware.com/images/XD_Intera
http://msdn2.microsoft.com/en-us/library/aa192481
(the second one is 3d)
And in response to your comment
> When will open source advocates learn to delegate the graphic design aspect of their work to professionals? if only the programming types in charge of these projects would admit they're better at making code than graphics.
You seem to have missed the point. The article is about free software that can be used by professional and non-professional alike to create some hot graphics. Perhaps you're referring to the ugliness of the original tux logo? It's not 1995, and developers aren't resigned to producing their own graphics. If you look all free software houses pushing their brand use professional designers. Think of the firefox logo (2004)
http://www.hicksdesign.co.uk/journal/branding-fir
or of ubuntu and gnome's curves, and check out the tango project http://tango.freedesktop.org/
Desktop linux has never looked so sexy.
Why so sour, AC?
I think it's dual licensed, with a very modest fee for commercial use.
You don't. You use a library like GD and a scripting language to generate the charts as images(alternatively, if your chart is representing static data, you can just whip up a static image in excel/gnuplot/whatever). There are also libraries built on top of GD (I use jpGraph with PHP) which simplify the process.
You can probably emulate a bar graph using tables, if you're particularly anal about doing it in HTML. Hell, you could probably do a line graph with a whole tonne of 1-pixel cells in a table, but I wouldn't recommend it.
Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
I do most of my work in Perl, and the lack of a good chart package has been annoying for a very long time. GD::Graph will give you very basic (and not terribly ugly) line and bar charts relatively quickly, but that's about it; it's missing even rudimentary features that make it less than useful (eg error bars).
There just isn't a general purpose charting package for Perl that would even come close to JFreeChart. Grace can produce some nice results, but the Perl interface to it is just a wrapper around their terrible command line interface (maybe it's improved in the last few years, but when I tried it it was almost entirely undocumented and nigh-unusable).
So, if you want publication quality charts you basically still have to learn gnuplot, which is great, but sometimes just a little too involved.
At least this thread gives a nice summary of what the other languages have to offer: the PHP and Ruby packages aren't faring any better, but Python's matplotlib looks freaking beautiful.
sic transit gloria mundi
Judging by the examples, this brings the readability of Perl into graphs.
i echart/warning.en.html
I think I can hear Edward Tufte weeping...
And the only chart they implement is the pie chart:
http://www.usf.uni-osnabrueck.de/~breiter/tools/p
Xix.
"Everything is adjustable, provided you have the right tools"