Page 1 of 1

Add rectangle fails

Posted: Fri May 03, 2013 7:16 pm
by 15965760
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

Re: Add rectangle fails

Posted: Wed May 08, 2013 1:50 pm
by yeray
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).

Re: Add rectangle fails

Posted: Wed May 08, 2013 2:02 pm
by 15965760
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..."

Re: Add rectangle fails

Posted: Wed May 15, 2013 7:21 pm
by Pep
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);