Graphing widget

THIS CONTRIB HASN’T BEEN TESTED WITH P4A 2.0!!

P4A_Graph: a wrapper widget for the PHPLOT open source library.

System requirements

You’ll need the GD library or phpplot will not work.

Screenshots

Sample code

// note: Put p4a_graph.php in the objects folder and all the masks in a subfolder of objects. 
// building the object
$this->build("P4A_Graph", "graph");
 
// setting the type of the graph, it can be:
// bars, lines, linepoints, area, points and pie
$this->graph->setPlotType("bars");
 
// set the P4A_DB_Source (previously created)
$this->graph->setSource($db_source);
 
// adding a label column, it's a field from the db_source
$grp->setLabelCol("label_column");
 
// adding a data column, you can add as many as you want
$grp->addDataCol("data_column", "name_in_legend");

Now you can anchor your P4A_Graph to one of your frames/sheets/canvas with the classical anchor method.

Code reference

More documentation

Take a look at the phpplot function reference at http://www.phplot.com/doc/user_functions.html

Note about debugging

The P4A_Graph widget is rendered as a jpeg file, if an error occurs you won’t be able to see it in your browser but you’ll get a blank image.

If you want to debug, look at the HTML code, copy the src link of the phplot wrapper (something like phplot_wrapper.php?id=wdg43746d9797238&p4a_application_name=myApplication&p4a_root_dir=/var/www/p4a) and paste it derectly to your browser’s address bar. With this trick you’ll be able to see what errors are occurring.

Download

Authors

 
gaphing-widget.txt · Last modified: 2007/04/07 05:41 by p4a
 
Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki