in reply to Re: Data labels for Chart::Points
in thread Data labels for Chart::Points

How can I do the same "print data labels" when I use 3d charts? Thanks

Replies are listed 'Best First'.
Re^3: Data labels for Chart::Points
by poj (Abbot) on Jun 22, 2014 at 12:40 UTC
    Which chart module are you using ?
    poj
      use GD::3DBarGrapher qw(creategraph); Thank you

        Perhaps you can adapt this.

        # perl use strict; use GD::3DBarGrapher qw(creategraph); use GD; use HTML::Treebuilder; use Data::Dump 'pp'; my @data = ( ['Apples', 28], ['Pears', 43], ['Bananas',67], ); my %options = ( 'file' => 'mygraph.jpg', ); my $imagemap = creategraph(\@data, \%options); my $tree = HTML::TreeBuilder->new; $tree->parse($imagemap); my @elements = $tree->find_by_tag_name('area'); my %plot=(); for my $e (@elements){ my ($bar,$value) = split ':',$e->attr('title'); $plot{$bar}{'value'} = $value; my @coord = split ',',$e->attr('coords'); $plot{$bar}{'coord'} = \@coord; } #pp %plot; my $img = GD::Image->newFromJpeg('mygraph.jpg',[1]); my $black = $img->colorAllocate(0,0,0); for my $bar (keys %plot){ my $x = $plot{$bar}{'coord'}[0]; my $y = $plot{$bar}{'coord'}[1] - 20; # above bar my $v = $plot{$bar}{'value'}; # gdSmallFont, gdMediumBoldFont, gdTinyFont, # gdLargeFont and gdGiantFont. $img->string(gdMediumBoldFont,$x,$y,$v,$black); } open IMG,'>mygraph.png'; binmode IMG; print IMG $img->png;
        poj
      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
        If your requirement is simple, an easy alternative might be create your own version of the module with this line added
        else { # draw main bar face my $centretopy = $ypos + ($dims{plotheight} - (($dims{plot +height}/$dims{range})*$d->[1])) + $floordepth; $image->filledRectangle($barpos,$centretopy,$barpos+$conf{ +bwidth},$ypos+$dims{plotheight}+$floordepth,$colbar); ### add this line $image->string(gdSmallFont,$barpos,$centretopy-20,$d->[1],$colba +r);
        poj
        It works find with the HTML::Treebuilder . Perrrrrrrrrrrrfect. Thank you so much.