1 | <?php |
---|
2 | /* |
---|
3 | Example21 : Playing with background |
---|
4 | */ |
---|
5 | |
---|
6 | // Standard inclusions |
---|
7 | include("pChart/pData.class"); |
---|
8 | include("pChart/pChart.class"); |
---|
9 | |
---|
10 | // Dataset definition |
---|
11 | $DataSet = new pData; |
---|
12 | $DataSet->AddPoint(array(9,9,9,10,10,11,12,14,16,17,18,18,19,19,18,15,12,10,9),"Serie1"); |
---|
13 | $DataSet->AddPoint(array(10,11,11,12,12,13,14,15,17,19,22,24,23,23,22,20,18,16,14),"Serie2"); |
---|
14 | $DataSet->AddPoint(array(4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22),"Serie3"); |
---|
15 | $DataSet->AddAllSeries(); |
---|
16 | $DataSet->RemoveSerie("Serie3"); |
---|
17 | $DataSet->SetAbsciseLabelSerie("Serie3"); |
---|
18 | $DataSet->SetSerieName("January","Serie1"); |
---|
19 | $DataSet->SetSerieName("February","Serie2"); |
---|
20 | $DataSet->SetYAxisName("Temperature"); |
---|
21 | $DataSet->SetYAxisUnit("°C"); |
---|
22 | $DataSet->SetXAxisUnit("h"); |
---|
23 | |
---|
24 | // Initialise the graph |
---|
25 | $Test = new pChart(700,230); |
---|
26 | $Test->drawGraphAreaGradient(132,153,172,50,TARGET_BACKGROUND); |
---|
27 | |
---|
28 | // Graph area setup |
---|
29 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
30 | $Test->setGraphArea(60,20,585,180); |
---|
31 | $Test->drawGraphArea(213,217,221,FALSE); |
---|
32 | $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,2); |
---|
33 | $Test->drawGraphAreaGradient(162,183,202,50); |
---|
34 | $Test->drawGrid(4,TRUE,230,230,230,20); |
---|
35 | |
---|
36 | // Draw the line chart |
---|
37 | $Test->setShadowProperties(3,3,0,0,0,30,4); |
---|
38 | $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); |
---|
39 | $Test->clearShadow(); |
---|
40 | $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),4,2,-1,-1,-1,TRUE); |
---|
41 | |
---|
42 | // Draw the legend |
---|
43 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
44 | $Test->drawLegend(605,142,$DataSet->GetDataDescription(),236,238,240,52,58,82); |
---|
45 | |
---|
46 | // Draw the title |
---|
47 | $Title = "Average Temperatures during the first months of 2008 "; |
---|
48 | $Test->drawTextBox(0,210,700,230,$Title,0,255,255,255,ALIGN_RIGHT,TRUE,0,0,0,30); |
---|
49 | |
---|
50 | // Render the picture |
---|
51 | $Test->addBorder(2); |
---|
52 | $Test->Render("example21.png"); |
---|
53 | ?> |
---|