P
Pascal
I am trying to create dynamic bar charts using data from a database
and am having issues formatting it. The labels can be long so i use
vertical labels but the font is small and hard to read. I try setting
font but it doesn't make a difference. Am i doing something wrong? I
am using the following code:
use strict;
use CGI::Carp qw(fatalsToBrowser);
use GD::Graph:ata;
use GD::Graph::bars;
use GD;
my $dataset = GD::Graph:ata->new() || die 'cant create dataset';
foreach (@Data)
{
my ($label,$value) = split(/,/, $_);
$dataset->add_point($label, $value) || die 'cant add data point';
}
my $my_graph = new GD::Graph::bars(600,600) || die 'cant define';
$my_graph->set_x_label_font=>(gdLargeFont);
$my_graph->set_y_label_font=>(gdLargeFont);
$my_graph->set(
y_label => 'Number of Incidents',
title => 'GRAPH TITLE',
cycle_clrs=>1,
bar_spacing=>2,
x_labels_vertical=>1,
show_values=>1
) or die $my_graph->error;
my $gd = $my_graph->plot($dataset) || die $my_graph->error;
print "Content-type: image/jpeg\n\n";
print $gd->jpeg;
and am having issues formatting it. The labels can be long so i use
vertical labels but the font is small and hard to read. I try setting
font but it doesn't make a difference. Am i doing something wrong? I
am using the following code:
use strict;
use CGI::Carp qw(fatalsToBrowser);
use GD::Graph:ata;
use GD::Graph::bars;
use GD;
my $dataset = GD::Graph:ata->new() || die 'cant create dataset';
foreach (@Data)
{
my ($label,$value) = split(/,/, $_);
$dataset->add_point($label, $value) || die 'cant add data point';
}
my $my_graph = new GD::Graph::bars(600,600) || die 'cant define';
$my_graph->set_x_label_font=>(gdLargeFont);
$my_graph->set_y_label_font=>(gdLargeFont);
$my_graph->set(
y_label => 'Number of Incidents',
title => 'GRAPH TITLE',
cycle_clrs=>1,
bar_spacing=>2,
x_labels_vertical=>1,
show_values=>1
) or die $my_graph->error;
my $gd = $my_graph->plot($dataset) || die $my_graph->error;
print "Content-type: image/jpeg\n\n";
print $gd->jpeg;