Welcome Guest, Not a member yet? Register   Sign In
pChart and Codeigniter
#1

[eluser]cbaldinu[/eluser]
Hi all,

i was wondering if someone is able to tell me how to integrate pChart in codeigniter.
I have read so many posts about this, but with no results.

Here is what i was doing by my self just for testing if all was going right:

I have created 3 libraries called pimage, pdraw and pdata, and i have pasted the code as it is, modifying only the declaration of the class as this :

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/* Axis configuration */
define("AXIS_FORMAT_DEFAULT"  , 680001);
define("AXIS_FORMAT_TIME"  , 680002);
define("AXIS_FORMAT_DATE"  , 680003);
define("AXIS_FORMAT_METRIC"  , 680004);
define("AXIS_FORMAT_CURRENCY"  , 680005);
define("AXIS_FORMAT_TRAFFIC"  , 680006);
define("AXIS_FORMAT_CUSTOM"  , 680007);

/* Axis position */
define("AXIS_POSITION_LEFT"  , 681001);
define("AXIS_POSITION_RIGHT"  , 681002);
define("AXIS_POSITION_TOP"  , 681001);
define("AXIS_POSITION_BOTTOM"  , 681002);

/* Families of data points */
define("SERIE_SHAPE_FILLEDCIRCLE" , 681011);
define("SERIE_SHAPE_FILLEDTRIANGLE" , 681012);
define("SERIE_SHAPE_FILLEDSQUARE" , 681013);
define("SERIE_SHAPE_FILLEDDIAMOND" , 681017);
define("SERIE_SHAPE_CIRCLE"  , 681014);
define("SERIE_SHAPE_TRIANGLE"  , 681015);
define("SERIE_SHAPE_SQUARE"  , 681016);
define("SERIE_SHAPE_DIAMOND"  , 681018);

/* Axis position */
define("AXIS_X"   , 682001);
define("AXIS_Y"   , 682002);

/* Define value limits */
define("ABSOLUTE_MIN"           , -10000000000000);
define("ABSOLUTE_MAX"           , 10000000000000);

/* Replacement to the PHP NULL keyword */
define("VOID"                   , 0.123456789);

/* Euro symbol for GD fonts */
define("EURO_SYMBOL"   , utf8_encode("€"));

class CI_Pdata {

/*
     pDraw - class to manipulate data arrays

     Version     : 2.1.4
     Made by     : Jean-Damien POGOLOTTI
     Last Update : 09/09/11

     This file can be distributed under the license you can find at :

                       http://www.pchart.net/license

     You can find the whole class documentation on the pChart web site.
*/




   var $Data;

   var $Palette = array("0"=>array("R"=>188,"G"=>224,"B"=>46,"Alpha"=>100),
                        "1"=>array("R"=>224,"G"=>100,"B"=>46,"Alpha"=>100),
                        "2"=>array("R"=>224,"G"=>214,"B"=>46,"Alpha"=>100),
                        "3"=>array("R"=>46,"G"=>151,"B"=>224,"Alpha"=>100),
                        "4"=>array("R"=>176,"G"=>46,"B"=>224,"Alpha"=>100),
                        "5"=>array("R"=>224,"G"=>46,"B"=>117,"Alpha"=>100),
                        "6"=>array("R"=>92,"G"=>224,"B"=>46,"Alpha"=>100),
                        "7"=>array("R"=>224,"G"=>176,"B"=>46,"Alpha"=>100));
  

   /* Class creator */
   function pData()
    {
     $this->Data = "";
     $this->Data["XAxisDisplay"] = AXIS_FORMAT_DEFAULT;
     $this->Data["XAxisFormat"]  = NULL;
     $this->Data["XAxisName"]  = NULL;
     $this->Data["XAxisUnit"]  = NULL;
     $this->Data["Abscissa"]  = NULL;
     $this->Data["AbsicssaPosition"] = AXIS_POSITION_BOTTOM;

     $this->Data["Axis"][0]["Display"]  = AXIS_FORMAT_DEFAULT;
     $this->Data["Axis"][0]["Position"] = AXIS_POSITION_LEFT;
     $this->Data["Axis"][0]["Identity"] = AXIS_Y;
    }

..................................

the rest of the code is equal to the rest of the normal pdata class findable in pData class of pChart.

now, back to codeigniter, into y controller i wrote :

Code:
$this->load->library('pdata');
  
  $this->load->library('pdraw');
  
  $this->load->library('pimage');
  
  $myData =& $this->pdata;
  
  
  $myData->addPoints(array(VOID,3,4,3,5));
        
        
      
        
       $myPicture =& $this->pimage;


  $myPicture -> pImage(700,230,$myData);
  
  
  $myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>11));
  
  
  $myPicture->setGraphArea(60,40,670,190);
  
  
  $myPicture->drawScale();
  
  
  $myPicture->drawSplineChart();
  
  
  $myPicture->Stroke();

But it still gives me errors, sooooo many errors.

Now, the question is : Can anyone help me about the integration of this pChart into codeIgniter with a mini HOW TO?

Thanks,

Cristian
#2

[eluser]cbaldinu[/eluser]
little up Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB