Example2.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. Example2 : A cubic curve graph
  4. */
  5. // Standard inclusions
  6. include("src/pData.php");
  7. include("src/pChart.php");
  8. // Dataset definition
  9. $DataSet = new pData;
  10. $DataSet->AddPoint(array(1,4,3,4,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7),"Serie1");
  11. $DataSet->AddPoint(array(1,4,2,6,2,3,0,1,5,1,2,4,5,2,1,0,6,4,2),"Serie2");
  12. $DataSet->AddAllSeries();
  13. $DataSet->SetAbsciseLabelSerie();
  14. $DataSet->SetSerieName("January","Serie1");
  15. $DataSet->SetSerieName("February","Serie2");
  16. // Initialise the graph
  17. $Test = new pChart(700,230);
  18. $Test->setFixedScale(-2,8);
  19. $Test->setFontProperties("Fonts/tahoma.ttf",8);
  20. $Test->setGraphArea(50,30,585,200);
  21. $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
  22. $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
  23. $Test->drawGraphArea(255,255,255,TRUE);
  24. $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);
  25. $Test->drawGrid(4,TRUE,230,230,230,50);
  26. // Draw the 0 line
  27. $Test->setFontProperties("Fonts/tahoma.ttf",6);
  28. $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
  29. // Draw the cubic curve graph
  30. $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());
  31. // Finish the graph
  32. $Test->setFontProperties("Fonts/tahoma.ttf",8);
  33. $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);
  34. $Test->setFontProperties("Fonts/tahoma.ttf",10);
  35. $Test->drawTitle(50,22,"Example 2",50,50,50,585);
  36. $Test->Render("example2.png");