Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: GD::Graph legend only shows 1 entry

by randyk (Parson)
on Oct 29, 2005 at 15:06 UTC ( [id://503871]=note: print w/replies, xml ) Need Help??


in reply to GD::Graph legend only shows 1 entry

The problem may have something to do with the structure of your data. Does the following example work for you in displaying all 3 values for the legend?
use GD::Graph::hbars; use strict; use warnings; my @data = ( ['Jan', 'Feb', 'Mar', 'Apr'], [5, 7, 9, 6], [2, 2, 3, 1], [4, 4, 6, 3], ); my @legend = qw(maximum minimum average); my $graph = GD::Graph::hbars->new(600, 500); $graph->set ( x_label => 'Month', y_label => 'Value', title => 'GD::Graph::hbars example', bar_spacing => 6, show_values => 1, legend_placement => 'BL', legend_spacing => 5, show_values => 1, legend_marker_height => 12, dclrs => [ qw(orange cyan lred) ], ) or warn $graph->error; $graph->set_legend(@legend); my $gd = $graph->plot(\@data) or warn $graph->error; open(IMG, ">graph.png") or die $!; binmode IMG; print IMG $gd->png; close IMG;

Replies are listed 'Best First'.
Re^2: GD::Graph legend only shows 1 entry
by bageler (Hermit) on Oct 29, 2005 at 15:44 UTC
    It does not work. I tried many ways of setting the legend:
    @legend = (1,2,3); $graph->set_legend(@legend); $graph->set_legend(qw(foo bar baz)); $graph->set_legend('foo','bar','baz');
    none of the above worked.
      What version of GD::Graph are you using? The example I gave worked for me with GD::Graph version 1.43, and GD version 2.30 (on Win32 ActiveState perl-5.8.7).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-19 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found