07975 997026 enquiries@ harpanet.com
A CI Library has been created (in
The CI jpGraph Library has been created as a single interface to jpGraph and to establish some level of consistency in jpGraph use within Trostre Intranet systems. It does not need to be used - you can work directly with the jpGraph application if preferred (see http://jpgraph.net).
This library is useful in the current (Feb 2013) Trostre Apache/PHP server environment because the jpGraph library is 'located somewhere on the server' (see below) rather than sitting within the CI
/application/libraries/jpgraph folder. If jpGraph was located in the latter location, it could simply be loaded using standard CI methods. eg.
jpGraph library files are located in
All graphs are created as image files within the jpGraph cache folder.
The jpGraph cache path used to store cached graph images must be set within the
/application/config/tata.php configuration file.
This location must be publicly accessible as your View files need to display the images in the client browser.
/* * set location to store jpgraph images */ $config['jpgraph_imgpath'] = './assets/img/jpgraph_cache/';
Each graph generated in the cache will have a 'hashed' filename based on the URI from which it is generated PLUS a unique ID for the image.
To initialise the CI jpGraph Library within your controller method, use …
$this->load->library('jpgraph'); $jpgraph = & $this->jpgraph;
Note: In the above example, the jpGraph library has been aliased 'by reference' to
$jpgraph to simplify use within the controller. Using this approach, you can use
$jpgraph→setting instead of
Once the CI jpGraph Library has been loaded, you need to:
$jpgraph->graph_size = array(800,600);
$ydata = array(10,50,23,79,85,60,12,42,37); $graph = $jpgraph->barchart($ydata, 'TESTING');
make_png()to generate the cache file and retrieve the filename
$png = $jpgraph->make_png( $graph, '2013012' );
tplSet('bodyContentBottom', "<img src='$png'>");
Note: This example uses the hArpanet Template System
tplSet() method as implemented by Trostre Intranet systems.