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
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.