From 8b8b972fa84f6400326f700bd9434e2f257e16d9 Mon Sep 17 00:00:00 2001 From: Refik Hadzialic Date: Tue, 9 Aug 2011 18:53:51 +0200 Subject: Libraries and start code for the output results image --- .../examples/example.drawStockChart.php | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 notFinishedCode/pChart2.1.2/examples/example.drawStockChart.php (limited to 'notFinishedCode/pChart2.1.2/examples/example.drawStockChart.php') diff --git a/notFinishedCode/pChart2.1.2/examples/example.drawStockChart.php b/notFinishedCode/pChart2.1.2/examples/example.drawStockChart.php new file mode 100644 index 0000000..003b7a4 --- /dev/null +++ b/notFinishedCode/pChart2.1.2/examples/example.drawStockChart.php @@ -0,0 +1,65 @@ +addPoints(array(34,55,15,62,38,42),"Open"); + $MyData->addPoints(array(42,25,40,38,49,36),"Close"); + $MyData->addPoints(array(27,14,12,25,32,32),"Min"); + $MyData->addPoints(array(45,59,47,65,64,48),"Max"); + $MyData->setAxisDisplay(0,AXIS_FORMAT_CURRENCY,"$"); + + $MyData->addPoints(array("8h","10h","12h","14h","16h","18h"),"Time"); + $MyData->setAbscissa("Time"); + + /* Create the pChart object */ + $myPicture = new pImage(700,230,$MyData); + + /* Draw the background */ + $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107); + $myPicture->drawFilledRectangle(0,0,700,230,$Settings); + + /* Overlay with a gradient */ + $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50); + $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings); + + /* Draw the border */ + $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0)); + + /* Write the title */ + $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11)); + $myPicture->drawText(60,45,"Stock price",array("FontSize"=>28,"Align"=>TEXT_ALIGN_BOTTOMLEFT)); + + /* Draw the 1st scale */ + $myPicture->setGraphArea(60,60,450,190); + $myPicture->drawFilledRectangle(60,60,450,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); + $myPicture->drawScale(array("DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE)); + + /* Draw the 1st stock chart */ + $mystockChart = new pStock($myPicture,$MyData); + $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30)); + $mystockChart->drawStockChart(); + + /* Reset the display mode because of the graph small size */ + $MyData->setAxisDisplay(0,AXIS_FORMAT_DEFAULT); + + /* Draw the 2nd scale */ + $myPicture->setShadow(FALSE); + $myPicture->setGraphArea(500,60,670,190); + $myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); + $myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE)); + + /* Draw the 2nd stock chart */ + $mystockChart = new pStock($myPicture,$MyData); + $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30)); + $mystockChart->drawStockChart(); + + /* Render the picture (choose the best way) */ + $myPicture->autoOutput("pictures/example.drawStockChart.png"); +?> \ No newline at end of file -- cgit v1.2.3-55-g7522