Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Data labels for Chart::Points

by poj (Priest)
on Sep 11, 2013 at 16:28 UTC ( #1053522=note: print w/ replies, xml ) Need Help??


in reply to Data labels for Chart::Points

You could use imagemap_dump together with GD, for example ;

#!perl use strict; use Data::Dump 'pp'; use Chart::Points; use GD; my $obj = Chart::Points->new ( 400,300 ); $obj->{'imagemap'}=1; my @labels = ('A','B','C'); $obj->set ('legend_labels' => \@labels); $obj->add_pt ('foo', 1,3,2); $obj->add_pt ('bar', 4,5,6); # create GD image my $img = GD::Image->new($obj->scalar_png); my $imagemap_data = $obj->imagemap_dump(); #pp $imagemap_data; # add labels my $black = $img->colorAllocate(0,0,0); for my $i (1..3){ for my $j (0..1){ my $text = $labels[$i-1]; my ($x,$y) = @{$imagemap_data->[$i][$j]}; $img->string(gdSmallFont,$x-10,$y-10,$text,$black); } } open (PNG,'>','chart.png') or die "$!"; binmode PNG; print PNG $img->png; close PNG;
poj


Comment on Re: Data labels for Chart::Points
Select or Download Code
Re^2: Data labels for Chart::Points
by AndreaN (Novice) on Sep 14, 2013 at 17:02 UTC

    It works perfectly! Thanks a lot.

Re^2: Data labels for Chart::Points
by attiamx (Initiate) on Jun 22, 2014 at 12:11 UTC
    How can I do the same "print data labels" when I use 3d charts? Thanks
      Which chart module are you using ?
      poj
        use GD::3DBarGrapher qw(creategraph); Thank you
        Thank you very much. I cpan insalled HTML::Treebuilder however, when I run the script, I get Can't locate HTML/Treebuilder.pm in @INC (@INC contains. you do not need to debug this for me, I am just frustrated. I never have this difficulty installing a module before. I even hardcoded the path to the module and also moved the module tree around to known librarys. perl still does not want to pick it up. I will keep trying and let you know once I get back on track. Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2015-07-04 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls