Request for help in using GD::Graph module (y label and undef related)

D

deepak p

Hello,

I'm writing perl scripts that utilize GD::Graph module to generate 3
types of graphs: bar, lines, linespoint and my question is specific to
this wonderful module. These 3 types of graphs are similar in that
they all have x-y axis and I'm running into difficulty in 2 areas.

1. In setting label for the ‘y axis' all 3 types of graphs, if I don't
include the method ‘set_y_label_font' in my graph generation data
structure, the y label appears as one would expect i.e. its
approximately centered in the y axis and oriented such that one would
read it bottom to top as illustrated in the URL below. (See y label –
"Revenue…")

http://wdvl.internet.com/Authoring/Languages/Perl/Weave/chart1-3.html

If however, I specify the font type and size for the y label as shown
below, the y label's orientation and placement gets messed up.

$graph->set_y_label_font('/usr/openwin/lib/X11/fonts/TrueType/CourierNew-Bold.ttf',
12);

What happens is 1) Y Label text gets automatically rotated 180 degrees
(hence, instead of it appearing from bottom to top along the y axis,
now its top to bottom). 2) Text is no longer centered along the y
axis, rather its gets shifted towards the bottom such that the last
letter of the y label ends at the start of y axis. I want to be able
to specify the y_label_font's type and size such that it does not
rotate and shift the text.

Incidentally when I specify the x_label_font, it does not mess its
orientation or placement. Why would x_label_font render fine while
y_label_font gets messed..its puzzling to me and don't know how to
fix.

2. In creating line graphs, if my data set is missing some data
points, I would expect to see breaks in the line. For example, if my
data set is as shown below

my @data = (['Jan', 'Feb', 'Mar', 'Apr', 'May', ‘Jun', ‘Jul'],
[50, 60, undef, 90, 50, undef, 80],

I would like to see a line segment connecting 50 to 60, then a break,
then a new segment connecting 90 to 50. The line graph however appears
to connect 50 to 60, then 60 to 90, then 90 to 50 and 50 to
80..ignoring the undef points. How can I specify GD::Graph::lines to
have breaks in the line segments when it encounters undefs?

I really appreciate and would like to thank in advance, if anyone can
help me overcome the difficulties. My env. if it matters is perl 5.61
running on Solaris 5.6 and we're using the latest GD::Graph module
(1.43).

Thank you for your time.

Best wishes,
Deepak
 
M

Martien Verbruggen

If however, I specify the font type and size for the y label as shown
below, the y label's orientation and placement gets messed up.

$graph->set_y_label_font('/usr/openwin/lib/X11/fonts/TrueType/CourierNew-Bold.ttf',
12);

What happens is 1) Y Label text gets automatically rotated 180 degrees
(hence, instead of it appearing from bottom to top along the y axis,
now its top to bottom). 2) Text is no longer centered along the y
axis, rather its gets shifted towards the bottom such that the last
letter of the y label ends at the start of y axis. I want to be able
to specify the y_label_font's type and size such that it does not
rotate and shift the text.

Looks like your text is, for some reason or other, also being rotated by
180 degrees. None of this happens for me. In fact, samples 14 and 71 in
the distribution do exactly this, without problems. Could you check
those examples in the distribution, just to see whether they do the same
thing?

If not, could you post (or email me) the full code for a program, as
small as possible, that displays the problem, together with its data
set? Could you also include the versions of GD, GD::Graph and GD::Text
you use? Run the following to find out:

#!/usr/local/bin/perl
use GD;
use GD::Text;
use GD::Graph;

print "GD: $GD::VERSION\n";
print "GD::Text: $GD::Text::VERSION\n";
print "GD::Graph: $GD::Graph::VERSION\n";
print "Perl: $]\n";

Alternatively, you can run 'make info' in the samples directory of a
recent GD::Graph distribution.
Incidentally when I specify the x_label_font, it does not mess its
orientation or placement. Why would x_label_font render fine while
y_label_font gets messed..its puzzling to me and don't know how to
fix.

It's puzzling me as well, which is why I'd like that information above,
so I can see whether there's some problem with GD::graph or something
else.
2. In creating line graphs, if my data set is missing some data
points, I would expect to see breaks in the line. For example, if my
data set is as shown below

That's on my todo list.
My env. if it matters is perl 5.61
running on Solaris 5.6 and we're using the latest GD::Graph module
(1.43).

Ok.. Could you also include the version numbers of GD and GD::Text? And
if you know which libgd and which freetype GD were linked against, that
could also help. There used to be some bugs in the freetype library
that entirely screwed up rotations. This happened several times.

I'd actually say that that is the most likely cause, without knowing
more.

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

Members online

Forum statistics

Threads
473,704
Messages
2,569,334
Members
44,617
Latest member
ConcettaTa

Latest Threads

Top