Welcome Guest, Not a member yet? Register   Sign In
$this->load->model conflicing with PHPGraphLib
#1

[eluser]Jona[/eluser]
Hi All,
I'm trying to use PHPgraphlib as found here: http://www.ebrueggeman.com/index.php to render some graphs and it works really well with the following code:
Code:
function test(){
            #$this->load->model('user_mod','users');
            require('/var/www/html/resources/php/graph.php');
            $data['Jan'] = 65;
            $data['Feb'] = 56;
            draw_single_graph($data);
        }
However as soon as I uncomment the model line instead of an image I get the following error image:
The image xxx could not be displayed, because it contains errors.

The model code works fine elsewhere so it shouldn't be throwing a php error.

The code for graph.php is as follows:
Code:
function draw_single_graph($dataArray,$title="Graph",$width=500,$height=450){
include("phpgraphlib.php");
$graph=new PHPGraphLib($width,$height);
if(is_array($dataArray)){
   $graph->addData($dataArray);
}
$graph->createGraph('rah.png');
}
There is no errors shown in the logs.

Any help on this would be massively appreciated, it seems like it should work!!

Cheers
Jona
#2

[eluser]mandril[/eluser]
i think the problem is the require after the load model..
#3

[eluser]Jona[/eluser]
Have tried the following:
Code:
function test(){
            require('/var/www/html/resources/php/graph.php');
            $this->load->model('user_mod','users');
Which results in the same problem....

Cheers
Jona
#4

[eluser]CJL01[/eluser]
Did you ever find out how to do this? I'm also trying to use PHPGraphLib with CI and having the same problem.

Thanks
#5

[eluser]Jona[/eluser]
Hi,
I never found out how to make this work properly, instead I modified the way I was using the library to save the graph to a file and then load that graph into the page. Not ideal but it worked.....

I did also consider using google charts to generate my charts for me.
#6

[eluser]CJL01[/eluser]
Thanks. I'm currently using Google charts, but I've got a lot of data points and I'm finding that accurately labeling the x-axis is getting hard - they seem to simply evenly space labels, and I can't vertically orient the label text. They are definitely very simple to implement though!

Do you have some sample code for how you save the PHPGraphLib chart off as a file? That would be a great help for me.

Thanks
#7

[eluser]Jona[/eluser]
Hi there,
I've attached the modified version of phpgraphlib. Basically you call createGraph passing it a filename, be aware this may have all kinds of bugs and security holes in it, use at your own risk!

Cheers
Jona
#8

[eluser]CJL01[/eluser]
Thanks a lot!




Theme © iAndrew 2016 - Forum software by © MyBB