~josephjamesmills/zpanelcp/zpanelcp

« back to all changes in this revision

Viewing changes to var/www/zpanel/lib/pChart2/examples/example.drawStockChart.php

  • Committer: Joseph Mills
  • Date: 2012-05-09 02:52:32 UTC
  • Revision ID: josephjamesmills@gmail.com-20120509025232-ob5xni0ggrse28c0
setup framwork for www

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 /* CAT:Stock chart */
 
3
 
 
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");
 
9
 
 
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,"$");
 
17
 
 
18
 $MyData->addPoints(array("8h","10h","12h","14h","16h","18h"),"Time");
 
19
 $MyData->setAbscissa("Time");
 
20
 
 
21
 /* Create the pChart object */
 
22
 $myPicture = new pImage(700,230,$MyData);
 
23
 
 
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);
 
27
 
 
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);
 
31
 
 
32
 /* Draw the border */
 
33
 $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
 
34
 
 
35
 /* Write the title */
 
36
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
 
37
 $myPicture->drawText(60,45,"Stock price",array("FontSize"=>28,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
 
38
 
 
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));
 
43
 
 
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();
 
48
 
 
49
 /* Reset the display mode because of the graph small size */
 
50
 $MyData->setAxisDisplay(0,AXIS_FORMAT_DEFAULT);
 
51
 
 
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));
 
57
 
 
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();
 
62
 
 
63
 /* Render the picture (choose the best way) */
 
64
 $myPicture->autoOutput("pictures/example.drawStockChart.png");
 
65
?>
 
 
b'\\ No newline at end of file'