Nalina has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I am using GD::Graph module for graph generation. Font size of the chart title, legends and x&y axes lables are small. How do I change the font size?

I tried
$my_graph->set_title_font(gdGiantFont); $my_graph->set_y_label_font(gdMediumBoldFont); $my_graph->set_x_label_font(gdMediumBoldFont); $my_graph->set_y_axis_font(gdMediumBoldFont); $my_graph->set_x_axis_font(gdMediumBoldFont); $my_graph->set_values_font(gdMediumBoldFont); $my_graph->set_legend_font(gdMediumBoldFont);
But the result is not satisfactory. I want the chart title font size to be 20. How do I do it?

Thanks & Regards

Nalina

Replies are listed 'Best First'.
Re: Font size in GD::Graph module
by BrowserUk (Patriarch) on Jul 08, 2004 at 10:59 UTC

    From the GD pod:

    Depending on your version of GD, this accepts both GD builtin fonts or + the name of a TrueType font file. In the case of a TrueType font, you must spec +ify the font size. See the GD::Text manpage for more details and other things, + since all font handling in GD::Graph is delegated to there. Examples: $my_graph->set_title_font('/fonts/arial.ttf', 18); $my_graph->set_legend_font(gdTinyFont); $my_graph->set_legend_font( ['verdana', 'arial', gdMediumBoldFont], 12) (The above discussion is based on GD::Text 0.65. Older versions have more restrictive behaviour).

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
      Thanks for the reply,

      I need one more clarification. I am using GD::Graph::pie module to generate pie chart. The legends appear on the chart it self. Is there any way to put the legends on the top or bottom of the chart, as we do it in line graphs?

      Also I want the chart to be at the bottom of the html page (I am using GD::Graph::Map module to export chart from png to html), as I have a table at the begining of the same page. How do I move the graph to the end? Thanks & Regards

      Nalina
        • Legends

          GD::Graph::pie doesn't support legends, so I assume that you mean that the labels are placed upon the pie. As far as I can see, there is no option or mechanism for adjusting these.

          However, the does seem to be a facility in GD::Graph::Map for producing an html legend but you'll have to read the docs and play.

        • GD::Graph::Map. I've never used this module so I can't help much, but from what I read, the imagemap() method returns the html to you. It's then just a case of you outputting it at the appropriate place in your html stream.

        Sorry I couldn't be more help.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon