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

AJ me at musefoundry.com
Fri Nov 14 02:45:28 EST 2003


For those interested, email me and Ill send you a link to a tarball with the
code changes.

 

Remember:

1.	You need the apache gd module
2.	there are some other changes.  For instance, my boss complained that
when he selected a queue and the graph came up the select bar reset itself
to the first queue.  So I copied the SelectQueue from the core elements and
copied into the statistics/elements directory, changed it so it reflected
the last chosen queue, and changed the rest of the code to use that one
instead.

 

A.J.

 

By the way, these are hacks.  I have no mandate from best practical or the
original authors of any contributed code I modified.  My aim is, and always
will be, getting things to work but I eagerly await the updates as I would
gladly replace what I have done with the real coders work.  When all is said
and done, I must say, RT is a great product.

 

 

-----Original Message-----
From: rt-users-bounces at lists.fsck.com
[mailto:rt-users-bounces at lists.fsck.com] On Behalf Of AJ
Sent: Friday, November 14, 2003 2:18 AM
To: rt-users at lists.fsck.com
Subject: [rt-users] RE: Getting graphs for statistics to print.

 

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/a39b94cf/attachment.htm>


More information about the rt-users mailing list