GD Graph Pie Formatting

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::Data;
use GD::Graph::bars;
use GD;

my $dataset = GD::Graph::Data->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;
 
S

Sherm Pendley

Pascal said:
print $gd->jpeg;

Not really on-topic for a Perl group, but you might want to try an image
type that's better suited for this type of imagery, like GIF or PNG.
JPEG is optimized for photographic content, and it isn't very well
suited to blocks of solid colors with sharp boundaries.

sherm--
 
P

Pascal

Sherm Pendley said:
Not really on-topic for a Perl group, but you might want to try an image
type that's better suited for this type of imagery, like GIF or PNG.
JPEG is optimized for photographic content, and it isn't very well
suited to blocks of solid colors with sharp boundaries.

sherm--

I've tried PNG and it looks identical. If the wrong forum please
inform on the correct one. I dont think it is the image format... i
think it is the font that is at issue. i cant get it to change size.
 
S

Sherm Pendley

Pascal said:
I've tried PNG and it looks identical. If the wrong forum please
inform on the correct one.

Sorry, I didn't mean to say it was the wrong place for your question, I
meant than my answer was going astray, as it had nothing to do with
Perl. I thought the JPEG compression might be blurring the text, making
it harder to read.
think it is the font that is at issue. i cant get it to change size.

GD uses FreeType for font rendering, which supports scalable fonts. If
there are none installed, it might be defaulting to a bitmapped font. If
you're using Linux, or another *nix that doesn't come with many display
fonts, you might want to have a look around the FreeType site
<http://freetype.sourceforge.net> for links.

sherm--
 
M

Martien Verbruggen

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:
$my_graph->set_x_label_font=>(gdLargeFont);
$my_graph->set_y_label_font=>(gdLargeFont);

set_*_label_font sets the font for the axis labels, not the value
labels. Use set_*_axis_font instead.

One day I'll clean up that terminology in the documentation and
finction names.

Martien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top