To:$coordinates .= sprintf $AREA_FORMAT, $xcoord, $ycoord, "$action_file? +x=$xvalue&y=$yvalue", "Value: [$xvalue, $yvalue]", "Value: [$xvalue, +$yvalue]";
I have also changed $AREA_FORMAT accordingly:$coordinates .= sprintf $AREA_FORMAT, $xcoord, $ycoord, $self->get_act +ion->($i);
The user has to ensure his/her subroutine takes one integer as an argument ($i - the current index) and returns a string. That way (s)he can iterate over a number of arrays, hard coded into his subroutine and associate the values correctly. As an example, the following code:my $AREA_FORMAT = qq(<area shape=circle coords="%.3f, %.3f, 2" %s>\n) +;
Gives the following output:#!/usr/bin/perl -w use strict; use GnuplotImageMap; # generate some values to plot my @xvalues = map { sprintf "%.3f", rand } 1 .. 10; my @yvalues = map { sprintf "%.3f", rand } 1 .. 10; # this is to test the "action" my $alphabets = [ 'a' .. 'z' ]; # generate the image map my $object = GnuplotImageMap->new( xvalues => [@xvalues], yvalues => [@yvalues], # this is where you specify what you want to do ... the default is + as before! action => sub { my ($i) = @_; return $alphabets->[$i] || "out + of bounds here"; }, ); # print out the image map print "\n\nThe image map:\n\n", $object->image_map(), "\n"; exit 0;
Note the alphabets: increasing from 'a' to 'j' in the image map string :) UPDATE: Tried to clarify the changes made and their effect on the output.The image map: <img src="C:\DOCUME~1\ionyia\LOCALS~1\Temp\LSPVfXDptt.png" usemap="#PL +OT"> <map name="PLOT"> <area shape=circle coords="605.000, 172.167, 2" a > <area shape=circle coords="308.779, 207.111, 2" b > <area shape=circle coords="588.668, 264.256, 2" c > <area shape=circle coords="70.000, 310.300, 2" d > <area shape=circle coords="397.195, 82.133, 2" e > <area shape=circle coords="249.647, 370.322, 2" f > <area shape=circle coords="273.863, 425.000, 2" g > <area shape=circle coords="544.179, 162.300, 2" h > <area shape=circle coords="598.805, 55.000, 2" i > <area shape=circle coords="332.432, 269.189, 2" j > </map>
In reply to Re: User defined action(s)
by j1n3l0
in thread User defined action(s)
by j1n3l0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |