Problem with parameters passed to Phplot by Codeigniter Controller

Asked

Viewed 130 times

1

I’m having a doubt that at the same time is being a problem, because I don’t know what I might be doing wrong.

The thing is, I’m using Codeigniter and to generate a graph I’m going to use the library Phplot, the basic I managed to generate the necessary graph, the problem started when I needed to change the size of the generated image, which in this library is passed by __construct class.

For this I moved the library to folder thirdy_party, dai in the Libraries folder I created a class named CIPHPlot extend the library, give it the controller and this class of mine CIPHPLot were thus:

class Welcome extends CI_Controller {

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

and the Ciphplot library:

<?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 apparently all right, because now if I go inside the Phplot library’s Construct and give a var_dump in the first parameter, in the case of $width it will display the value passed in the Controller, in case 1200, but when it generates the graph, it generates with the standard size of 600 and not with the 1200 as it is printed in the 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);
    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.