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?? :slight_smile: )

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.

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.From: rt-users-bounces@lists.fsck.com
[mailto:rt-users-bounces@lists.fsck.com] On Behalf Of AJ
Sent: Friday, November 14, 2003 2:18 AM
To: rt-users@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?? :slight_smile: )

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.

The RT/RTFM combination is great, but I have alot of external documents
which I would like reference as an “external article”. (IE. I don’t
want to copy/paste text into article) The Attachment feature of RT is
excellent but (currently) doesn’t extend to RTFM.

Having an RTFM custom field type of “Attachment” would be sooo sweet.

Are there plans for this functionality in the future?

I can fudge this by creating an “Article” queue, and creating "tickets"
with attachments and restrict rights on the queue so it becomes
essentially “query only”. But this breaks the mold of what a "ticket"
is.

Thoughts?

-Bob

The RT/RTFM combination is great, but I have alot of external documents
which I would like reference as an “external article”. (IE. I don’t
want to copy/paste text into article) The Attachment feature of RT is
excellent but (currently) doesn’t extend to RTFM.

Having an RTFM custom field type of “Attachment” would be sooo sweet.

Are there plans for this functionality in the future?

In the “would be cool” sense, yes. But in the “development resources
committed” sense, not yet, no.

I can fudge this by creating an “Article” queue, and creating “tickets”
with attachments and restrict rights on the queue so it becomes
essentially “query only”. But this breaks the mold of what a “ticket”
is.

Thoughts?

-Bob


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

Request Tracker... So much more than a help desk — Best Practical Solutions – Trouble Ticketing. Free.