Page 1 of 1

render problem

Posted: Wed Nov 02, 2011 9:12 pm
by 15960028
I found that if you don't actually create something on the chart before rendering the chart then the transparency functions and brush and pen settings don't work correctly or at all when you try to draw on it afterwards.

I was experimenting with painting areas of the canvas certain colors and I bumped into this problem and it also explains the transparency issues I posted about previously.

I have 2 examples that should produce the same results but they really don't and the only difference is in the first example I put an annotation on the chart before rendering.

This first example creates 2 rectangles which will not be filled as they should and an ellipse that does fill correctly... go figure. This is because the chart doesn't actually contain anything..

Code: Select all

    $chart1 = new TChart(800,600);
    $chart1->getChart()->getAspect()->setView3D(false);

    $chart1->getChart()->getAxes()->getLeft()->setVisible(true);  //adds 1 pixel border all around assuming all else is off
    $chart1->getChart()->getAxes()->getRight()->setVisible(true);
    $chart1->getChart()->getAxes()->getTop()->setVisible(true);
    $chart1->getChart()->getAxes()->getBottom()->setVisible(true);

    $chart1->getChart()->getAxes()->getLeft()->getLabels()->setVisible(false);
    $chart1->getChart()->getAxes()->getRight()->getLabels()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getLabels()->setVisible(false);
    $chart1->getChart()->getAxes()->getBottom()->getLabels()->setVisible(false);

    $chart1->getChart()->getAxes()->getLeft()->getTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getRight()->getTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getTicks()->setVisible(true); // adds 3 pixels not impacted by font size
    $chart1->getChart()->getAxes()->getBottom()->getTicks()->setVisible(false);

    $chart1->getAxes()->getTop()->getTicks()->setLength(10); //this will be the vertical margin for balance..

    $chart1->getChart()->getAxes()->getLeft()->getTicksInner()->setVisible(false); // adds nothing to whitespace
    $chart1->getChart()->getAxes()->getRight()->getTicksInner()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getTicksInner()->setVisible(false);
    $chart1->getChart()->getAxes()->getBottom()->getTicksInner()->setVisible(false);

    $chart1->getChart()->getAxes()->getLeft()->getMinorTicks()->setVisible(false); // adds nothing to whitespace
    $chart1->getChart()->getAxes()->getRight()->getMinorTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getMinorTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getBottom()->getMinorTicks()->setVisible(false);

    $chart1->getPanel()->setMarginUnits(PanelMarginUnits::$PIXELS);
    $chart1->getPanel()->setMarginLeft(0);
    $chart1->getPanel()->setMarginRight(0);
    $chart1->getPanel()->setMarginTop(0);
    $chart1->getPanel()->setMarginBottom(0);

    $chart1->getChart()->getHeader()->setVisible(true);
    $chart1->getChart()->getFooter()->setVisible(false); 
    $chart1->getChart()->getSubHeader()->setVisible(false);

  //****  RENDER RENDER RENDER ****************************************************************************************//

    $chart1->render("chart1.png");   //means create canvas to draw on..

    $g=$chart1->getGraphics3D();
    $g->getBrush()->setVisible(true); //this turned on the color in the free canvas forms
    $chart1->getGraphics3D()->getPen()->setColor(Color::BLACK());
    $chart1->getChart()->getGraphics3D()->getBrush()->SetColor(Color::BLUE());  //works to set brush color

       
    $chart1->getChart()->getGraphics3D()->Rectangle(new Rectangle(10,10,100,100));

    $r = new Rectangle(170,170,270,270);
    $chart1->getChart()->getGraphics3D()->getBrush()->SetColor(Color::WHITE());

    $chart1->getChart()->getGraphics3D()->Rectangle($r);

    $chart1->getChart()->getGraphics3D()->getBrush()->SetColor(Color::RED());

    $chart1->getChart()->getGraphics3D()->ellipse(400,400,500,550);
    imagepng($chart1->getChart()->getGraphics3d()->img, "chart1.png");  //this seems to draw the image when ready

    $rand=rand();
    print '<font face="Verdana" size="2">Vertical Bar Chart<p>';
    print '<img src="chart1.png?rand='.$rand.'"><p>';
 
//end of php file




The second example creates the same shapes which will all fill properly. The transparency functions will work correctly as well.
The only difference is an annotation is added to the chart before it is rendered.

Code: Select all

 $chart1 = new TChart(800,600);
    $chart1->getChart()->getAspect()->setView3D(false);

    $chart1->getChart()->getAxes()->getLeft()->setVisible(true);  //adds 1 pixel border all around assuming all else is off
    $chart1->getChart()->getAxes()->getRight()->setVisible(true);
    $chart1->getChart()->getAxes()->getTop()->setVisible(true);
    $chart1->getChart()->getAxes()->getBottom()->setVisible(true);

    $chart1->getChart()->getAxes()->getLeft()->getLabels()->setVisible(false);
    $chart1->getChart()->getAxes()->getRight()->getLabels()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getLabels()->setVisible(false);
    $chart1->getChart()->getAxes()->getBottom()->getLabels()->setVisible(false);
  

    $chart1->getChart()->getAxes()->getLeft()->getTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getRight()->getTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getTicks()->setVisible(true); // adds 3 pixels not impacted by font size
    $chart1->getChart()->getAxes()->getBottom()->getTicks()->setVisible(false);

    $chart1->getAxes()->getTop()->getTicks()->setLength(10); //this will be the vertical margin for balance..

    $chart1->getChart()->getAxes()->getLeft()->getTicksInner()->setVisible(false); // adds nothing to whitespace
    $chart1->getChart()->getAxes()->getRight()->getTicksInner()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getTicksInner()->setVisible(false);
    $chart1->getChart()->getAxes()->getBottom()->getTicksInner()->setVisible(false);

    $chart1->getChart()->getAxes()->getLeft()->getMinorTicks()->setVisible(false); // adds nothing to whitespace
    $chart1->getChart()->getAxes()->getRight()->getMinorTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getTop()->getMinorTicks()->setVisible(false);
    $chart1->getChart()->getAxes()->getBottom()->getMinorTicks()->setVisible(false);

    $chart1->getPanel()->setMarginUnits(PanelMarginUnits::$PIXELS);
    $chart1->getPanel()->setMarginLeft(0);
    $chart1->getPanel()->setMarginRight(0);
    $chart1->getPanel()->setMarginTop(0);
    $chart1->getPanel()->setMarginBottom(0);

    $chart1->getChart()->getHeader()->setVisible(true);
    $chart1->getChart()->getFooter()->setVisible(false); 
    $chart1->getChart()->getSubHeader()->setVisible(false);

        $tool=new Annotation($chart1->getChart());
        $tool->getShape()->setCustomPosition(true);
        $tool->setTop(rand(10, 600));
        $tool->setLeft(rand(10, 800));
        $tool->setText("topic 2");

  //****  RENDER RENDER RENDER ****************************************************************************************//

    $chart1->render("chart1.png");   //means create canvas to draw on..

    $g=$chart1->getGraphics3D();
    $g->getBrush()->setVisible(true); //this turned on the color in the free canvas forms
    $chart1->getGraphics3D()->getPen()->setColor(Color::BLACK());
    $chart1->getChart()->getGraphics3D()->getBrush()->SetColor(Color::BLUE());  //works to set brush color

       
    $chart1->getChart()->getGraphics3D()->Rectangle(new Rectangle(10,10,100,100));

    $r = new Rectangle(170,170,270,270);
    $chart1->getChart()->getGraphics3D()->getBrush()->SetColor(Color::WHITE());

    $chart1->getChart()->getGraphics3D()->Rectangle($r);

    $chart1->getChart()->getGraphics3D()->getBrush()->SetColor(Color::RED());

    $chart1->getChart()->getGraphics3D()->ellipse(400,400,500,550);
    imagepng($chart1->getChart()->getGraphics3d()->img, "chart1.png");  //this seems to draw the image when ready

    $rand=rand();
    print '<font face="Verdana" size="2">Vertical Bar Chart<p>';
    print '<img src="chart1.png?rand='.$rand.'"><p>';
 
//end of php file

For my project I need to create a custom "graph" from rectangles and ellipses and text callouts.
What can be done to make the first example look work like the second. I don't think I can toss in an annotation, especially if I can't turn off the shadowing.

Re: render problem

Posted: Thu Nov 03, 2011 2:09 pm
by yeray
Hello,

Playing a little bit with your code, I've found what actually seems to break the custom drawing brush: the "setView3D(false)" instruction.

Code: Select all

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

    /*$tool=new Annotation($chart1->getChart()); //the annotation seems to fix the custom drawing brush
    $tool->getShape()->setCustomPosition(true);
    $tool->setTop(rand(10, 600));
    $tool->setLeft(rand(10, 800));
    $tool->setText("topic 2");*/

    //****  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.'">';
Could you please confirm it?

Re: render problem

Posted: Thu Nov 03, 2011 6:34 pm
by 15960028
Yes indeed that's confirmed.

//$chart1->getChart()->getAspect()->setView3D(false); //it seems to break the custom drawing brush

commenting out the setview3D() line prevents the problem, but gives the canvas that 3d appearance on the upper left side.

Re: render problem

Posted: Fri Nov 04, 2011 10:46 am
by yeray
Hello

I've added it to the defect list to be revised for further releases (TF90015815).
Thanks for reporting and helping to identify and describe the problem.

Re: render problem

Posted: Fri Nov 04, 2011 5:17 pm
by 15960028
Is there any timeline on when the next release will be ready ?

Re: render problem

Posted: Mon Nov 07, 2011 4:50 pm
by yeray
Hello,

We expect to be able to publish a new release in the first quarter next year, adding some interactivity, including some new series and of course fixing some bugs.