Exemple #1
0
 public function testDrawBarGraph()
 {
     // Dataset definition
     $DataSet = new pData();
     $DataSet->addPoints(array(1, 4, -3, 2, -3, 3, 2, 1, 0, 7, 4), "Serie1");
     $DataSet->addPoints(array(3, 3, -4, 1, -2, 2, 1, 0, -1, 6, 3), "Serie2");
     $DataSet->addPoints(array(4, 1, 2, -1, -4, -2, 3, 2, 1, 2, 2), "Serie3");
     $DataSet->AddAllSeries();
     $DataSet->SetAbscissaLabelSeries();
     $DataSet->setSeriesName("January", "Serie1");
     $DataSet->setSeriesName("February", "Serie2");
     $DataSet->setSeriesName("March", "Serie3");
     // Initialise the graph
     $canvas = new TestCanvas();
     $Test = new pChart(700, 230, $canvas);
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->setGraphArea(50, 30, 680, 200);
     $canvas->drawFilledRoundedRectangle(new Point(7, 7), new Point(693, 223), 5, new Color(240), 1, 0, ShadowProperties::NoShadow());
     $backgroundStyle = new BackgroundStyle(new Color(255), TRUE);
     $Test->drawGraphBackground($backgroundStyle);
     $Test->drawScale($DataSet, ScaleStyle::DefaultStyle(), 0, 2, TRUE);
     $Test->drawGrid(new GridStyle(4, TRUE, new Color(230), 50));
     // Draw the 0 line
     $Test->setFontProperties("Fonts/tahoma.ttf", 6);
     $Test->drawTreshold(0, new Color(143, 55, 72), TRUE, TRUE);
     // Draw the bar graph
     $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80);
     // Finish the graph
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->drawLegend(596, 150, $DataSet->GetDataDescription(), new Color(255));
     $Test->setFontProperties("Fonts/tahoma.ttf", 10);
     $Test->drawTitle(50, 22, "Example 12", new Color(50), 585);
     $this->assertEquals('c5cc595cf2c41c6c363521346c8262a5', md5($canvas->getActionLog()));
 }