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

Ask a Question related to PERL Modules, Design and Development.

  1. #1

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

    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…")

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

    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
    deepak p Guest

  2. Similar Questions and Discussions

    1. Graph.0.69 Module---how to get a DAG from graph with cycles
      Here I use an example to illustrate the problem I met when using Graph Theory Module: I have a directed graph looks like the following (see the...
    2. Do we need Graph::Clique module?
      Hi, I am planning to implement an extension to Greg Bacon's implementation on clique reduction in a graph: ...
    3. Perl GD::Graph module: bug?
      While producing HTML Image MAP for the graph, I have found that th first line in linespoints graph type has suspicious coordinates o first line in...
    4. Recommend/survey graph, chart module space?
      While looking for a chart module, I see a very large number to choose from. Is there a pointer to a guide, or do folks have recommendations, on...
    5. Proposed new module Graph::Timeline
      I am currently looking to create a Graph::Timeline module (similar in some respects to Image::Timeline) that would allow rendering timelines as...
  3. #2

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

    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…")

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

    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
    deepak p Guest

  4. #3

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

    On 9 Jul 2003 20:20:58 -0700,
    deepak p <deepak10000@hotmail.com> wrote:
    > 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
    --
    |
    Martien Verbruggen | prepBut nI vrbLike adjHungarian! qWhat's
    | artThe adjBig nProblem? -- Alec Flett
    |
    Martien Verbruggen Guest

  5. #4

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

    On 9 Jul 2003 20:20:58 -0700,
    deepak p <deepak10000@hotmail.com> wrote:
    > 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
    --
    |
    Martien Verbruggen | prepBut nI vrbLike adjHungarian! qWhat's
    | artThe adjBig nProblem? -- Alec Flett
    |
    Martien Verbruggen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139