mason-data_graphs_output_on_the_web

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



From: Brian Avis <brian.avis@searhc.org>
To: mason-users@lists.sourceforge.net
Subject: [Mason] Graphing
Date: Fri, 22 Nov 2002 10:31:54 -0900

Hi all,

I have just been asked to provide various graphs on the web pages for 
various data.  Does anyone have any advice on the best and quickest way 
to implement this?  Should the graphs be created as images with a mason 
component and the have the web page point to that image?  Is there a way 
in mason to send the image directly to the browser?  Any advice would be 
welcome.   Thanks.

===

From: <siberian@siberian.org>
Subject: Re: [Mason] Graphing
To: Brian Avis <brian.avis@searhc.org>, mason-users@lists.sourceforge.net
Date: Fri, 22 Nov 2002 12:13:13 -0800

I use rrd graphs. It works really well and interfacing 
with it is extremely simple. The images we use are 
dynamically generated by Mason interacting with the 
standard RRD tool suites and some perl libs wrapped around 
them.

google 'rrd graph' and you'll get a ton of good info and 
sample implementations.

===

From: Philip Molter <philip@texas.net>
To: siberian@siberian.org
Cc: Brian Avis <brian.avis@searhc.org>, mason-users@lists.sourceforge.net
Subject: Re: [Mason] Graphing
Date: Fri, 22 Nov 2002 14:27:26 -0600

On Fri, Nov 22, 2002 at 12:13:13PM -0800, siberian@siberian.org wrote:
: I use rrd graphs. It works really well and interfacing 
: with it is extremely simple. The images we use are 
: dynamically generated by Mason interacting with the 
: standard RRD tool suites and some perl libs wrapped around 
: them.

Note that RRD's a great tool, but it's limited to a specific feature
set, mainly handling data sets over time.  If you don't want your
X-axis to be time, RRD's probably not going to be right for you,
and if moment-in-time accuracy is your goal, RRD's definitely not
your friend.

Check out GD and GD::Graph for more generic graphing mechanisms.

: >I have just been asked to provide various graphs on the 
: >web pages for various data.  Does anyone have any advice 
: >on the best and quickest way to implement this?  Should 
: >the graphs be created as images with a mason component 
: >and the have the web page point to that image?  Is there 
: >a way in mason to send the image directly to the browser? 
: > Any advice would be welcome.   Thanks.
: >

As for how to do it under Mason, I use separate CGI scripts for
graphs when I don't *need* the Mason environment, and I just write
a simple component to output the data when I do need it (for things
like session or globals).

BTW, the way to have Mason send the image directly to the browser
is to reference the component in the <img src="" /> tag.

===


From: Brian Avis <brian.avis@searhc.org>
Subject: Re: [Mason] Graphing
To: Philip Molter <philip@texas.net>
Cc: siberian@siberian.org, mason-users@lists.sourceforge.net
Date: Fri, 22 Nov 2002 11:34:57 -0900

So I can setup a simple CGI script that can accept a bunch of data from 
the POST or GET stuff.  And then just use that script within an img tag 
to output it to the browser?

What I am envisioning is a data set of monthly, quarterly, or yearly 
data with an unknown number of years.  


For example

Years
2000
2001
2002
     
Months    1    2    3    4    5    6    7    8    9    10    11    12

The user would select what type of graph they want, then the graph type, 
colors, data and so forth would be fed to a component that would send a 
graph to the browser.


===

From: Philip Molter <philip@texas.net>
To: Brian Avis <brian.avis@searhc.org>
Cc: siberian@siberian.org, mason-users@lists.sourceforge.net
Subject: Re: [Mason] Graphing
Date: Fri, 22 Nov 2002 14:49:38 -0600

On Fri, Nov 22, 2002 at 11:34:57AM -0900, Brian Avis wrote:
: So I can setup a simple CGI script that can accept a bunch of data from 
: the POST or GET stuff.  And then just use that script within an img tag 
: to output it to the browser?

Yes.  You can do that.

===

From: Brian Avis <brian.avis@searhc.org>
To: mason-users@lists.sourceforge.net
Subject: [Mason] Graphs are harder than I thought.  :)
Date: Fri, 22 Nov 2002 13:48:50 -0900

I am testing the idea of using CGI to stuff a quick graph into my page. 
 So I set this simple stuff up.  Which of course is not working. 
 Otherwise why would I be here with a question.

On the page where the graph should display.

<img src="http://uranus/graphs/create.cgi">


And then the CGI bit.

#!/usr/bin/perl -wT

use strict;
use CGI;
use GD::Graphs::linespoints;

my $q = new CGI;

@data = (
   ["1st", "2nd", "3rd", "4th", "5th"],
   [ 1, 2, 3, 4, 5]);


my $graph = GD::Graph::linespoints(400, 300);
 
  $graph->set(
       title => 'TEST',
       x_label => 'X',
       y_label => 'Y',
       y_max_value => 40,
       y_min_value => 0,
       y_tick_number => 8,
       y_label_skip => 2,
       types => ["linespoints"]);

   $graph->set_legend("X", "Y");

   my $image = $graph->plot(\@data);

   print $q->header( -type => "image/png", -expires => "now");

   binmode STDOUT;

   print $gd_image->png;



I can create a graph just fine in a regular perl program.  But I can't 
stuff one automagically into a web page.  When the web page loads the 
little square pops up to show that there should be an image there (it 
dissappears quickly) but no image.  And I have no idea why?   Am I 
missing something obvious (as usual) or do I have to do something with 
mason to let the cgi stuff run through it?


===

From: Steven Saner <ssaner@pantheranet.com>
To: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Graphs are harder than I thought.  :)
Date: Fri, 22 Nov 2002 17:54:31 -0600

1st, you should be able to get the CGI to work, by itself, from a
browser. Can you point your browser to the URL and get a graphic to
come back at you? If not, then that is where you should look.

2nd, look at your web server logs to see if the cgi is being called an
if there are any errors.


===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu