#!/usr/bin/perl use strict; use warnings; use GD::Graph::linespoints; my $title = "Open Bugs for Buggy"; my $graph = GD::Graph::linespoints->new( 600, 400 ); my @legend_keys = qw(new_bugs open_bugs reopen_bugs fixed_bugs verified_bugs closed_bugs); $graph->set( x_label => 'Log_Date', y_label => '$y_label', x_label_skip => 30, x_labels_vertical => 'true', title => $title, legend_placement => 'BL', legend_marker_height => 12, ); $graph->set( dclrs => [qw(green blue red yellow brown orange)] ); $graph->set_legend(@legend_keys); $graph->set_title_font(GD::gdGiantFont); $graph->set_x_label_font(GD::gdLargeFont); $graph->set_y_label_font(GD::gdLargeFont); my @data = ( [qw( Jan Feb Mar Apr May Jun Jul Sep )], [ reverse( 4, 3, 5, 6, 3, 1.5, -1, -3, -4 ) ], ); print $graph->plot( \@data ); save_chart( $graph, 'Buggy' ); sub save_chart { my $chart = shift or die "Need a chart!"; my $name = shift or die "Need a name!"; local (*OUT); my $ext = $chart->export_format; open( OUT, ">Buggy.png" ) or die "Cannot open Buggy.png for write: $!"; binmode OUT; print OUT $chart->gd->$ext(); close OUT; }