in reply to Re^4: Data labels for Chart::Points
in thread Data labels for Chart::Points
Perhaps you can adapt this.
poj# 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;
|
|---|