Re: Perl module for chart drawing?
by zentara (Archbishop) on Dec 19, 2008 at 16:41 UTC
|
Sounds like GD's bar graph would work. Search groups.google and google for examples.
Here is a little starter script, mailling it to yourself is a different problem.
#!/usr/bin/perl
use GD::Graph::bars;
@A = qw(-5 -4 -3 -2 -1 0 1 2 3 4 5 );
@B = qw(-6 -4 -2 0 2 4 6);
@C = qw(1 2 3 4 5);
@D = qw(4 5 6 7);
@E = qw(-2 -4 -6 0 2 4 6 8);
@datacolors = qw(blue green cyan pink yellow);
my @data = ([@A],[@B],[@C],[@D],[@E]);
my $graph = GD::Graph::bars->new(600,400);
$graph->set(
transparent => '0',
x_label => 'A',
y_label => 'B',
title => 'A for B',
dclrs => [ @datacolors ]
);
open(IMG, ">$0.png");
binmode IMG;
my $gd = $graph->plot(\@data);
print IMG $gd->png;
close IMG;
| [reply] [d/l] |
|
Thank you! I'll try to use that snippet as a grounding for my own code. Thing is that I'm not really sure of what kind of data should the graphical representation contain, because when I start to play around with the idea so many different possibilities come to mind. But then again, that's for me to decide and tinker with :)
| [reply] |
|
Yeah, sleep on it for a few days, it saves rewrites later when you realize there is a better way. But then again, you often don't see the need for a better way, until you jump into the code and start hacking.
| [reply] |
Re: Perl module for chart drawing?
by samtregar (Abbot) on Dec 19, 2008 at 16:49 UTC
|
Definitely consider using Google Charts. It's so much easier than coding up custom charts in Perl (and yes, I've tried all the relevant CPAN modules) and the results are prettier too.
-sam
| [reply] |
|
| [reply] |
|
I looked at Google Charts a while ago and while the results are some of the more attractive out there and the API is really nice to use. I'm just not comfortable handing off all the internal data I would like to graph to Google.
Maybe one day they will release the renderer that we could run locally, until then its really something that pretty, but not useful.
| [reply] |
Re: Perl module for chart drawing?
by linuxer (Curate) on Dec 19, 2008 at 18:00 UTC
|
Maybe rrdtool is something you could use. (This was my first idea, as I read your message.)
There are also some Modules available at CPAN for using rrd.
| [reply] |
|
If you decide to use rrdtool, make certain to check out Alex van den Bogaerdt's tutorials.
RRDtool does not quite work the way people expect and these explanations do a good job of preparing you to expect the data you will get out of it. I've just recently been through this.
| [reply] |
Re: Perl module for chart drawing?
by planetscape (Chancellor) on Dec 20, 2008 at 08:30 UTC
|
| [reply] |
Re: Perl module for chart drawing?
by hill (Sexton) on Dec 19, 2008 at 17:42 UTC
|
Take a look at Chart Director. It's reasonably inexpensive, sold as a Perl module, and easy to use. Data is passed to it as array references with minimum, straight forward setup. Good looking output. Good customer service, too. | [reply] |
Re: Perl module for chart drawing?
by Anonymous Monk on Dec 19, 2008 at 16:40 UTC
|
| [reply] |
|
| [reply] |
Re: Perl module for chart drawing?
by lostjimmy (Chaplain) on Dec 19, 2008 at 18:33 UTC
|
I've always found gnuplot to be very easy to use. You can pipe commands to it from Perl, but there is also Chart::Gnuplot, which I have never used. | [reply] |
|
with above script, was testing module and facing error saying "sh: convert: command not found". Please help me .
| [reply] |
|
use Chart::Gnuplot::Pie;
# Create the pie chart object
my $chart = Chart::Gnuplot::Pie->new(
output => "pie.png",
title => "Sample Pie");
# Data set
my $dataSet = Chart::Gnuplot::Pie::DataSet->new(
data => [
['Item 1', 7500],
['Item 2', 3500],
['Item 3', 2000],
['Item 4', 4500],
],
);
# Plot a 2D pie chart
$chart->plot2d($dataSet);
| [reply] [d/l] |
Re: Perl module for chart drawing?
by kevbot (Priest) on Dec 01, 2015 at 08:08 UTC
|
| [reply] |