[619] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Example16 : Importing CSV data |
---|
| 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->ImportFromCSV("Sample/CO2.csv",",",array(1,2,3,4),TRUE,0); |
---|
| 13 | $DataSet->AddAllSeries(); |
---|
| 14 | $DataSet->SetAbsciseLabelSerie(); |
---|
| 15 | $DataSet->SetYAxisName("CO2 concentrations"); |
---|
| 16 | |
---|
| 17 | // Initialise the graph |
---|
| 18 | $Test = new pChart(700,230); |
---|
| 19 | $Test->reportWarnings("GD"); |
---|
| 20 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
| 21 | $Test->setGraphArea(60,30,680,180); |
---|
| 22 | $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); |
---|
| 23 | $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230); |
---|
| 24 | $Test->drawGraphArea(255,255,255,TRUE); |
---|
| 25 | $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,90,2); |
---|
| 26 | $Test->drawGrid(4,TRUE,230,230,230,50); |
---|
| 27 | |
---|
| 28 | // Draw the 0 line |
---|
| 29 | $Test->setFontProperties("Fonts/tahoma.ttf",6); |
---|
| 30 | $Test->drawTreshold(0,143,55,72,TRUE,TRUE); |
---|
| 31 | |
---|
| 32 | // Draw the line graph |
---|
| 33 | $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); |
---|
| 34 | $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); |
---|
| 35 | |
---|
| 36 | // Finish the graph |
---|
| 37 | $Test->setFontProperties("Fonts/tahoma.ttf",8); |
---|
| 38 | $Test->drawLegend(70,40,$DataSet->GetDataDescription(),255,255,255); |
---|
| 39 | $Test->setFontProperties("Fonts/tahoma.ttf",10); |
---|
| 40 | $Test->drawTitle(60,22,"CO2 concentrations at Mauna Loa",50,50,50,585); |
---|
| 41 | $Test->Render("example16.png"); |
---|
| 42 | ?> |
---|