Home > Archive > PERL Miscellaneous > December 2004 > GD Graph Pie Formatting
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
GD Graph Pie Formatting
|
|
| Pascal 2004-12-01, 3:56 am |
| 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;
| |
| Sherm Pendley 2004-12-01, 3:56 am |
| Pascal wrote:
> 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--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
| |
| Pascal 2004-12-01, 3:58 pm |
| Sherm Pendley <spamtrap@dot-app.org> wrote in message news:<Q-Kdnf9ijqtg8DDcRVn-gw@adelphia.com>...
> Pascal wrote:
>
>
> 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.
| |
| Sherm Pendley 2004-12-01, 8:56 pm |
| Pascal wrote:
> 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--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
| |
| Martien Verbruggen 2004-12-07, 4:11 am |
| On 30 Nov 2004 22:56:32 -0800,
Pascal <pascal@straec.com> wrote:
> 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
--
|
Martien Verbruggen | prepBut nI vrbLike adjHungarian! qWhat's
| artThe adjBig nProblem? -- Alec Flett
|
|
|
|
|
|