GD-Graph-bars3d
Stegalex
created: 2006-04-03 11:50:57
Quick Question: Has anyone been able to successfully generate an imagemap for a 3d chart using the GD-Graph-bars3d module?

I have been able to do this for 2d bar and line graphs but it seems that axestype3d.pm does not contain a get_hotspot method.


~~~~~~~~~~~~~~~
I like chicken.
Re: GD-Graph-bars3d
created: 2006-04-03 12:53:17
This works, (don't know about get_hotspot, where do you come up with that?)
#!/usr/bin/perl
use strict;
use warnings;
use GD::Graph::bars3d;

# sample data
my @data = (30, 45, 36, 42, 40, 44, 41, 39, 35, 46, 43, 38);
my @dt = ('2002-10-10 00:00:00', '2002-10-10 01:00:00', '2002-10-10 02:00:00',
'2002-10-10 03:00:00', '2002-10-10 04:00:00', '2002-10-10 05:00:00',
'2002-10-10 06:00:00', '2002-10-10 07:00:00', '2002-10-10 08:00:00',
'2002-10-10 09:00:00', '2002-10-10 10:00:00', '2002-10-10 11:00:00');

# setup the color set
my @colors;
for my $datum (@data) {
push(@colors, get_color($datum));
}

# create the data set for the graph
my @dataset = (\@dt, \@data);

# create the new graph
my $graph = GD::Graph::bars3d->new( 400, 300 );

# setup the graph options
$graph->set(
transparent       => '0',
bgclr             => 'lgray',
boxclr            => 'white',
fgclr             => 'white',
x_label           => 'Date / Time',
y_label           => 'Number of Woozles Sold',
title             => 'World Wide Woozle Sales',
dclrs             => \@colors,
cycle_clrs        => 1, # this is mandatory for this to work
x_labels_vertical => 1,
);

# plot the graph
my $gd = $graph->plot(\@dataset);

# create a PNG file of the graph
open(IMG, ">$0.png") or die $!;
binmode IMG;
print IMG $gd->png;

# returns the color name based on the value given
# this is only an example
# you should base your numbers off of your actual data
sub get_color {
my $value = shift;
return "dpurple" if ($value < 34);
return "lpurple" if ($value < 36);
return "blue" if ($value < 38);
return "green" if ($value < 40);
return "yellow" if ($value < 42);
return "orange" if ($value < 44);
return "red";
}


I'm not really a human, but I play one on earth. flash japh
Re^2: GD-Graph-bars3d
created: 2006-04-03 13:17:47
That's an image, not an imagemap. An imagemap is a list of shapes defining the mouse-clickabable areas of an image. Refer to "HOTSPOTS" in the GD::Graph documentation.
Re^3: GD-Graph-bars3d
created: 2006-04-03 15:38:42
Well you know more than me.:-) I'm glad that you recognized that a subroutine, that does not exist in the module, is somehow relevant.

I'm not really a human, but I play one on earth. flash japh
Re^4: GD-Graph-bars3d
created: 2006-04-03 15:50:55
I didn't know more than you. I researched the subject before answering.
Re^5: GD-Graph-bars3d
created: 2006-04-04 05:11:04
Will you believe I was feeling masiochistic and just needed some downvotes? :-)

I'm not really a human, but I play one on earth. flash japh

perlmonks.org content © perlmonks.org and ikegami, Stegalex, zentara

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03