[rt-users] RE: Getting graphs for statistics to print.

AJ me at musefoundry.com
Fri Nov 14 02:18:05 EST 2003


Well my managers really wanted those graphs.  I saw that the module once
used Apache::GD::Graph so I installed that and made some minor code changes
that have worked.

 

The apache module points /chart  (I am so creative aren't I?? :-)   ) 

 

I changed the chart invocation from Elements/Chart?.... to /chart?... for
example:

 

>From line 59 in Statistics/CallsQueueDay/index.html :

### Original Code

<%perl>

my $url= 'Elements/Chart?x_labels=';

for (0..$max) {

    $url .= $data[0][$_] . ",";

}

chop $url;

$url .= "&";

shift @data;

for (0..$#data) {

    $url .= "data".(1+$_)."=".(join ",", @{$data[$_]})."&";

}

chop $url;

</%perl>

 

Modified Code after installation of the gd apache module:

 

<%perl>

my $url= '/chart?x_labels=[';  # bracket after equal sign

for (0..$max) {

    $url .= $data[0][$_] . ",";

}

chop $url;

$url .= "]&"; #bracket before ampersand

shift @data;

for (0..$#data) {

    $url .= "data".(1+$_)."=[".(join ",", @{$data[$_]})."]&"; #bracket after
equal sign and before ampersand

}

chop $url;

</%perl>

 

The trick is to replace Elements/Chart with /chart (or whatever the path you
specified in your apache conf file) and make sure the datapoints are
surrounded by brackets.  In the above case, I looked for the = sign and put
a bracket right behind it and then looked for the & and put a close bracket
right before it.  

 

The legends were a bit of an annoyance but this seems to work:

Original Code in Statistics/CallsMultiQueue/index.html:

$url .= 'set_legend='.(join ",", @legend)."&";

 

Modified Code

my $legendstring=join ",", @legend;

$legendstring=~s/\s+/\%20/g;

$url .= 'legend=('.$legendstring.")&";

 

Key here is to make sure that the spaces in the queue names are subbed with
%20 and that the queuenames are enclosed in perens.

 

The other way to do it is to convert the Chart element to a cgi and call it
in the image tag.  

 

I am sure there is a more correct way to do it, and when its actually
posted, I will be ecstatic, but I needed it now and this is what I came up
with.

 

 

Hope it helps..

 

A.J.

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20031114/d421bb27/attachment.htm>


More information about the rt-users mailing list