Problem with the parameters passed to PHPlot by the Codeigniter Controller

1

I have a question that at the same time is a problem, because I do not know what I might be doing wrong.

This is the following, I am using Codeigniter and to generate a graph I will use the library PHPlot , the basic I was able to generate the graph The problem started when I needed to change the size of the generated image, which in that library is passed by __construct of the class.

For this I moved the library to folder thirdy_party , then in the libraries folder I created a class called CIPHPlot extending the library, hence the controller and this my class CIPHPLot looks like this:

class Welcome extends CI_Controller {

    public function Index(){
        // Carregamos a library PHPlot
        $this->load->library('CIPHPlot', array(1200, 800));

and the CIPHPLot library like this:

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

require_once APPPATH."third_party/PHPlot.php";

class CIPHPlot extends PHPlot {

    public function __construct($params = array())
    {
        $width       = 600;
        $height      = 400;
        $output_file = NULL;
        $input_file  = NULL;

        if(isset($params) && is_array($params)) {
            if (isset($params[0])) {
                $width = (int) $params[0];
            }
            if (isset($params[1])) {
                $height = (int) $params[1];
            }
            if (isset($params[2])) {
                $output_file = $params[2];
            }
            if (isset($params[3])) {
                $input_file = $params[3];
            }
        }

        new PHPlot($width, $height, $output_file, $input_file);

        parent::__construct();
    }

}

So far, it seems all right, because now if I go inside the PHPlot library construct and give var_dump in the first parameter, in this case the $width it will display the value passed in the Controller, in case 1200, but when it generates the graph, it generates with the default size of 600 and not with the 1200 as printed in var_dump .

class PHPlot
{

    function __construct($width=600, $height=400, $output_file=NULL, $input_file=NULL)
    {
        var_dump($width);die();
        $this->initialize('imagecreate', $width, $height, $output_file, $input_file);
    }
    
asked by anonymous 24.06.2016 / 21:53

0 answers