PageRenderTime 199ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/pchart/vendor/pChart2.1.1/examples/example.drawFilledSplineChart.php

https://github.com/data-quest/histat-web
PHP | 74 lines | 41 code | 16 blank | 17 comment | 1 complexity | e5f1ec7a97596d5188ef3b2bc37189af MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0, LGPL-2.1
  1. <?php
  2. /* CAT:Spline chart */
  3. /* pChart library inclusions */
  4. include("../class/pData.class.php");
  5. include("../class/pDraw.class.php");
  6. include("../class/pImage.class.php");
  7. /* Create and populate the pData object */
  8. $MyData = new pData();
  9. $MyData->setAxisName(0,"Strength");
  10. for($i=0;$i<=720;$i=$i+20)
  11. {
  12. $MyData->addPoints(cos(deg2rad($i))*100,"Probe 1");
  13. $MyData->addPoints(cos(deg2rad($i+90))*60,"Probe 2");
  14. }
  15. /* Create the pChart object */
  16. $myPicture = new pImage(847,304,$MyData);
  17. $myPicture->drawGradientArea(0,0,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47,"EndR"=>17,"EndG"=>17,"EndB"=>17,"Alpha"=>100));
  18. $myPicture->drawGradientArea(0,250,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47,"EndR"=>27,"EndG"=>27,"EndB"=>27,"Alpha"=>100));
  19. $myPicture->drawLine(0,249,847,249,array("R"=>0,"G"=>0,"B"=>0));
  20. $myPicture->drawLine(0,250,847,250,array("R"=>70,"G"=>70,"B"=>70));
  21. /* Add a border to the picture */
  22. $myPicture->drawRectangle(0,0,846,303,array("R"=>204,"G"=>204,"B"=>204));
  23. /* Write the picture title */
  24. $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
  25. $myPicture->drawText(423,14,"Cyclic magnetic field strength",array("R"=>255,"G"=>255,"B"=>255,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
  26. /* Define the chart area */
  27. $myPicture->setGraphArea(58,27,816,228);
  28. /* Draw a rectangle */
  29. $myPicture->drawFilledRectangle(58,27,816,228,array("R"=>0,"G"=>0,"B"=>0,"Dash"=>TRUE,"DashR"=>0,"DashG"=>51,"DashB"=>51,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
  30. /* Turn on shadow computing */
  31. $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
  32. /* Draw the scale */
  33. $myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255));
  34. $ScaleSettings = array("XMargin"=>4,"DrawSubTicks"=>TRUE,"GridR"=>255,"GridG"=>255,"GridB"=>255,"AxisR"=>255,"AxisG"=>255,"AxisB"=>255,"GridAlpha"=>30,"CycleBackground"=>TRUE);
  35. $myPicture->drawScale($ScaleSettings);
  36. /* Draw the spline chart */
  37. $myPicture->drawFilledSplineChart();
  38. /* Write the chart boundaries */
  39. $BoundsSettings = array("MaxDisplayR"=>237,"MaxDisplayG"=>23,"MaxDisplayB"=>48,"MinDisplayR"=>23,"MinDisplayG"=>144,"MinDisplayB"=>237);
  40. $myPicture->writeBounds(BOUND_BOTH,$BoundsSettings);
  41. /* Write the 0 line */
  42. $myPicture->drawThreshold(0,array("WriteCaption"=>TRUE));
  43. /* Write the chart legend */
  44. $myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255));
  45. $myPicture->drawLegend(560,266,array("Style"=>LEGEND_NOBORDER));
  46. /* Write the 1st data series statistics */
  47. $Settings = array("R"=>188,"G"=>224,"B"=>46,"Align"=>TEXT_ALIGN_BOTTOMLEFT);
  48. $myPicture->drawText(620,270,"Max : ".ceil($MyData->getMax("Probe 1")),$Settings);
  49. $myPicture->drawText(680,270,"Min : ".ceil($MyData->getMin("Probe 1")),$Settings);
  50. $myPicture->drawText(740,270,"Avg : ".ceil($MyData->getSerieAverage("Probe 1")),$Settings);
  51. /* Write the 2nd data series statistics */
  52. $Settings = array("R"=>224,"G"=>100,"B"=>46,"Align"=>TEXT_ALIGN_BOTTOMLEFT);
  53. $myPicture->drawText(620,283,"Max : ".ceil($MyData->getMax("Probe 2")),$Settings);
  54. $myPicture->drawText(680,283,"Min : ".ceil($MyData->getMin("Probe 2")),$Settings);
  55. $myPicture->drawText(740,283,"Avg : ".ceil($MyData->getSerieAverage("Probe 2")),$Settings);
  56. /* Render the picture (choose the best way) */
  57. $myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
  58. ?>