Ejemplo n.º 1
1
 /**
  * Based on Example24.php
  */
 public function testXYChart()
 {
     // Dataset definition
     $DataSet = new pData();
     // Compute the points
     for ($i = 0; $i <= 360; $i = $i + 10) {
         $DataSet->addPoint(cos($i * 3.14 / 180) * 80 + $i, "Serie1");
         $DataSet->addPoint(sin($i * 3.14 / 180) * 80 + $i, "Serie2");
     }
     $DataSet->setSeriesName("Trigonometric function", "Serie1");
     $DataSet->addSeries("Serie1");
     $DataSet->addSeries("Serie2");
     $DataSet->SetXAxisName("X Axis");
     $DataSet->SetYAxisName("Y Axis");
     // Initialise the graph
     $canvas = new TestCanvas();
     $Test = new pChart(300, 300, $canvas);
     $Test->drawBackgroundGradient(new Color(0), -100);
     // Prepare the graph area
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->setGraphArea(55, 30, 270, 230);
     $scaleStyle = new ScaleStyle(SCALE_NORMAL, new Color(213, 217, 221));
     $Test->drawXYScale($DataSet, $scaleStyle, "Serie1", "Serie2", 45);
     $backgroundStyle = new BackgroundStyle(new Color(213, 217, 221), FALSE, new Color(30), -50);
     $Test->drawGraphBackground($backgroundStyle);
     $Test->drawGrid(new GridStyle(4, TRUE, new Color(230), 20));
     // Draw the chart
     $Test->setShadowProperties(2, 2, new Color(0), 60, 4);
     $Test->drawXYGraph($DataSet->GetData(), "Serie1", "Serie2", 0);
     $Test->clearShadow();
     // Draw the title
     $Title = "Drawing X versus Y charts trigonometric functions  ";
     $Test->drawTextBox(new Point(0, 280), new Point(300, 300), $Title, 0, new Color(255), ALIGN_RIGHT, ShadowProperties::FromSettings(1, 1, new Color(0), 100, 0), new Color(0), 30);
     // Draw the legend
     $Test->setFontProperties("Fonts/pf_arma_five.ttf", 6);
     $DataSet->removeSeries("Serie2");
     $Test->drawLegend(160, 5, $DataSet->GetDataDescription(), new Color(0), new Color(0), new Color(255), FALSE);
     file_put_contents(dirname(__FILE__) . '/action_logs/testXYChart', $canvas->getActionLog());
     $this->assertEquals('3c45517b3d9549198ffffaac276ad353', md5($canvas->getActionLog()));
 }