[619] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Example9 : Showing how to use labels |
---|
| 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(0,70,70,0,0,70,70,0,0,70),"Serie1"); |
---|
| 13 | $DataSet->AddPoint(array(0.5,2,4.5,8,12.5,18,24.5,32,40.5,50),"Serie2"); |
---|
| 14 | |
---|
| 15 | $DataSet->AddAllSeries(); |
---|
| 16 | $DataSet->SetAbsciseLabelSerie(); |
---|
| 17 | $DataSet->SetSerieName("January","Serie1"); |
---|
| 18 | $DataSet->SetSerieName("February","Serie2"); |
---|
| 19 | |
---|
| 20 | // Initialise the graph |
---|
| 21 | $Test = new pChart(700,230); |
---|
| 22 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
| 23 | $Test->setGraphArea(50,30,585,200); |
---|
| 24 | $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); |
---|
| 25 | $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230); |
---|
| 26 | $Test->drawGraphArea(255,255,255,TRUE); |
---|
| 27 | $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2); |
---|
| 28 | $Test->drawGrid(4,TRUE,230,230,230,50); |
---|
| 29 | |
---|
| 30 | // Draw the 0 line |
---|
| 31 | $Test->setFontProperties("Fonts/tahoma.ttf",6); |
---|
| 32 | $Test->drawTreshold(0,143,55,72,TRUE,TRUE); |
---|
| 33 | |
---|
| 34 | // Draw the line graph |
---|
| 35 | $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); |
---|
| 36 | $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); |
---|
| 37 | |
---|
| 38 | // Set labels |
---|
| 39 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
| 40 | $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","2","Daily incomes",221,230,174); |
---|
| 41 | $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie2","6","Production break",239,233,195); |
---|
| 42 | |
---|
| 43 | // Finish the graph |
---|
| 44 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
| 45 | $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255); |
---|
| 46 | $Test->setFontProperties("Fonts/tahoma.ttf",10); |
---|
| 47 | $Test->drawTitle(50,22,"Example 9",50,50,50,585); |
---|
| 48 | $Test->Render("example9.png"); |
---|
| 49 | ?> |
---|