Add rectangle fails

TeeChart for PHP
Post Reply
rustydiver
Newbie
Newbie
Posts: 22
Joined: Tue Apr 30, 2013 12:00 am

Add rectangle fails

Post by rustydiver » Fri May 03, 2013 7:16 pm

The code below from this thread -- http://www.teechart.net/support/viewtop ... 11&t=12762 does not work.

Code: Select all

    $chart1 = new TChart(800,600);
    
    //$chart1->getChart()->getAspect()->setView3D(false);  //it seems to break the custom drawing brush


    //****  RENDER RENDER RENDER  ****//
    $chart1->render("chart1.png");

    $g=$chart1->getGraphics3D();
    $g->getBrush()->setVisible(true);
    $g->getPen()->setColor(Color::BLACK());
    
    $g->getBrush()->SetColor(Color::BLUE());
    $g->Rectangle(new Rectangle(10,10,100,100));

    $g->getBrush()->SetColor(Color::WHITE());
    $g->Rectangle(new Rectangle(170,170,270,270));
    
    $g->getBrush()->SetColor(Color::RED());
    $g->ellipse(400,400,500,550);
    
    imagepng($g->img, "chart1.png");

    $rand=rand();
    print '<img src="chart1.png?rand='.$rand.'">';
It produces a blank chart preceded by.. (similar to the save image to file errors)

Warning: imagecolorallocatealpha(): 247 is not a valid Image resource in C:\xampp\htdocs\------------------\sources\GraphicsGD.php on line 2158

Warning: imagefilledrectangle(): 247 is not a valid Image resource in C:\xampp\htdocs\----------------\sources\GraphicsGD.php on line 2179

Warning: imagecolorallocatealpha(): 247 is not a valid Image resource in C:\xampp\htdocs\----------------\sources\GraphicsGD.php on line 2891

Warning: imagesetstyle(): 247 is not a valid Image resource in C:\xampp\htdocs\-----------------\sources\GraphicsGD.php on line 2205

Warning: imagesetthickness(): 247 is not a valid Image resource in C:\xampp\htdocs\-----------------\sources\GraphicsGD.php on line 2208

Warning: imagerectangle(): 247 is not a valid Image resource in C:\xampp\htdocs\-------------------\sources\GraphicsGD.php on line 2210

Warning: imagecolorallocatealpha(): 247 is not a valid Image resource in C:\xampp\----------------\sources\GraphicsGD.php on line 2158

Warning: imagefilledrectangle(): 247 is not a valid Image resource in C:\xampp\htdocs\------------------\sources\GraphicsGD.php on line 2179

Warning: imagecolorallocatealpha(): 247 is not a valid Image resource in C:\xampp\htdocs\------------------\sources\GraphicsGD.php on line 2891

Warning: imagesetstyle(): 247 is not a valid Image resource in C:\xampp\htdocs\-----------------\sources\GraphicsGD.php on line 2205

Warning: imagesetthickness(): 247 is not a valid Image resource in C:\xampp\htdocs\------------------\sources\GraphicsGD.php on line 2208

Warning: imagerectangle(): 247 is not a valid Image resource in C:\xampp\htdocs\-----------------\sources\GraphicsGD.php on line 2210

Warning: imagecolorallocate(): 247 is not a valid Image resource in C:\xampp\htdocs\------------------\sources\GraphicsGD.php on line 1210

Warning: imagefilledellipse(): 247 is not a valid Image resource in C:\xampp\htdocs\---------------\sources\GraphicsGD.php on line 1219

Warning: imagecolorallocatealpha(): 247 is not a valid Image resource in C:\xampp\htdocs\----------------\sources\GraphicsGD.php on line 2891

Warning: imagesetstyle(): 247 is not a valid Image resource in C:\xampp\htdocs\-----------------\sources\GraphicsGD.php on line 1225

Warning: imagesetthickness(): 247 is not a valid Image resource in C:\xampp\htdocs\-------------\sources\GraphicsGD.php on line 1228

Warning: imageellipse(): 247 is not a valid Image resource in C:\xampp\htdocs\----------------\sources\GraphicsGD.php on line 1231

Warning: imageellipse(): 247 is not a valid Image resource in C:\xampp\htdocs\-------------\sources\GraphicsGD.php on line 1231

Warning: imagepng(): 247 is not a valid Image resource in C:\xampp\htdocs\----------------\test_chart.php on line 26

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Add rectangle fails

Post by Yeray » Wed May 08, 2013 1:50 pm

Hi,

Excuse us for the delayed reply here.
I could reproduce the problem so I've added it to the wish list to be further investigated (TF90016569).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

rustydiver
Newbie
Newbie
Posts: 22
Joined: Tue Apr 30, 2013 12:00 am

Re: Add rectangle fails

Post by rustydiver » Wed May 08, 2013 2:02 pm

OK... you notice that the errors are too similar to the save image to file error to be coincidence, right? "247 is not a valid..."

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: Add rectangle fails

Post by Pep » Wed May 15, 2013 7:21 pm

Hello,

yes, this is the same problem as in the other post. For the moment the best way I can think of if to remove the "imagedestroy($g->img); " from the render() method of TChart.php file. Then you should be able to make it work (also a good example could be the EventsDemo.php of the Features example project (at Miscellaneous folder).

In the case you want to create several charts you can always call the following line after all has been displayed :

Code: Select all

imagedestroy($chart->getChart()->getGraphics3d()->img);    

Post Reply