4
/* pChart library inclusions */
5
include("../class/pData.class.php");
6
include("../class/pDraw.class.php");
7
include("../class/pImage.class.php");
8
include("../class/pStock.class.php");
10
/* Create and populate the pData object */
11
$MyData = new pData();
12
$MyData->addPoints(array(34,55,15,62,38,42),"Open");
13
$MyData->addPoints(array(42,25,40,38,49,36),"Close");
14
$MyData->addPoints(array(27,14,12,25,32,32),"Min");
15
$MyData->addPoints(array(45,59,47,65,64,48),"Max");
16
$MyData->setAxisDisplay(0,AXIS_FORMAT_CURRENCY,"$");
18
$MyData->addPoints(array("8h","10h","12h","14h","16h","18h"),"Time");
19
$MyData->setAbscissa("Time");
21
/* Create the pChart object */
22
$myPicture = new pImage(700,230,$MyData);
24
/* Draw the background */
25
$Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
26
$myPicture->drawFilledRectangle(0,0,700,230,$Settings);
28
/* Overlay with a gradient */
29
$Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
30
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
33
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
36
$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
37
$myPicture->drawText(60,45,"Stock price",array("FontSize"=>28,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
39
/* Draw the 1st scale */
40
$myPicture->setGraphArea(60,60,450,190);
41
$myPicture->drawFilledRectangle(60,60,450,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
42
$myPicture->drawScale(array("DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE));
44
/* Draw the 1st stock chart */
45
$mystockChart = new pStock($myPicture,$MyData);
46
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
47
$mystockChart->drawStockChart();
49
/* Reset the display mode because of the graph small size */
50
$MyData->setAxisDisplay(0,AXIS_FORMAT_DEFAULT);
52
/* Draw the 2nd scale */
53
$myPicture->setShadow(FALSE);
54
$myPicture->setGraphArea(500,60,670,190);
55
$myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
56
$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE));
58
/* Draw the 2nd stock chart */
59
$mystockChart = new pStock($myPicture,$MyData);
60
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
61
$mystockChart->drawStockChart();
63
/* Render the picture (choose the best way) */
64
$myPicture->autoOutput("pictures/example.drawStockChart.png");
b'\\ No newline at end of file'