Welcome Guest, Not a member yet? Register   Sign In
pChart 2.0 with Codeigniter

In my project I was need PChart 2.0 and I start searching fast way how to integrate this libraries, and no complite solution was founded, so I start to integrate it by myself, and I like to share my practices with community. I want to notice thats I am using 2.2.1 CI, do not know if its work for CI 3.0.0

First at all download pChart and unpack it to  "application/third_party/chart" folder (you can delete example folder btw)
Then create new folder "libraries" in "application/third_party/chart". Inside this new folder create file pchart.php with next content

PHP Code:

class Pchart
   public function __construct() // or any other method
       require_once APPPATH.'third_party/chart/class/pData.class.php';
       require_once APPPATH.'third_party/chart/class/pDraw.class.php';
       require_once APPPATH.'third_party/chart/class/pImage.class.php';
   function pData(){
       return new pData();    
   function pImage($n,$i,$data=NULL,$trans=FALSE){
       return new pImage($n,$i,$data,$trans);

Now, I can create my controller function with example from pChart page:

PHP Code:
  function chart(){

/* Add data in your dataset */ 
       $PDA $this->pchart->pData();
/* Create a pChart object and associate your dataset */ 
       $PDI $this->pchart->pImage(700,230,$PDA); 
       /* Choose a nice font */

       /* Define the boundaries of the graph area */

       /* Draw the scale, keep everything automatic */ 

       /* Draw the scale, keep everything automatic */ 

       /* Build the PNG file and send it to the web browser */ 


And in the end I got my render. Hope its help to you as well.

Nice, thanks for sharing.


Theme © iAndrew 2016 - Forum software by © MyBB