[532] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $values = array(); |
---|
| 4 | $legend = array(); |
---|
| 5 | |
---|
| 6 | foreach($_GET as $key=>$val) |
---|
| 7 | { |
---|
| 8 | if ($key == "title") |
---|
| 9 | |
---|
| 10 | $title = $val; |
---|
| 11 | |
---|
| 12 | elseif ($key == "size") |
---|
| 13 | |
---|
| 14 | list($size_x, $size_y) = explode("x", $val); |
---|
| 15 | |
---|
| 16 | else |
---|
| 17 | { |
---|
| 18 | list( $value, $color ) = explode( ",", $val ); |
---|
| 19 | $values[] = $value; |
---|
| 20 | $legend[] = $key; |
---|
| 21 | } |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | // Include pChart libs |
---|
| 25 | // |
---|
| 26 | include( "./lib/pchart/pData.class" ); |
---|
| 27 | include( "./lib/pchart/pChart.class" ); |
---|
| 28 | |
---|
| 29 | // Dataset definition |
---|
| 30 | // |
---|
| 31 | $DataSet = new pData; |
---|
| 32 | $DataSet->AddPoint( $values, "Pie slices" ); |
---|
| 33 | $DataSet->AddPoint( $legend, "Legend" ); |
---|
| 34 | $DataSet->AddAllSeries(); |
---|
| 35 | $DataSet->SetAbsciseLabelSerie( "Legend" ); |
---|
| 36 | |
---|
| 37 | // Initialise the graph |
---|
| 38 | $myChart = new pChart(380,200); |
---|
| 39 | $myChart->drawFilledRoundedRectangle(7,7,373,193,5,240,240,240); |
---|
| 40 | $myChart->drawRoundedRectangle(5,5,375,195,5,230,230,230); |
---|
| 41 | |
---|
| 42 | // Font for slice percentages & legend text |
---|
| 43 | // |
---|
| 44 | $myChart->setFontProperties( "./lib/pchart/tahoma.ttf", 8 ); |
---|
| 45 | |
---|
| 46 | // Draw the pie slices and percentages text |
---|
| 47 | // |
---|
| 48 | $myChart->drawPieGraph( $DataSet->GetData(), $DataSet->GetDataDescription(), 160, 100, 110, TRUE, TRUE, 50, 20, 20 ); |
---|
| 49 | |
---|
| 50 | // Draw legend text |
---|
| 51 | // |
---|
| 52 | $myChart->drawPieLegend( 280, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250 ); |
---|
| 53 | |
---|
| 54 | // Font for title: a little bigger |
---|
| 55 | // |
---|
| 56 | $myChart->setFontProperties( "./lib/pchart/tahoma.ttf", 12 ); |
---|
| 57 | |
---|
| 58 | // Draw title text |
---|
| 59 | // |
---|
| 60 | $myChart->drawTitle( 0, 5, $title, 50, 50, 50, 380, 20 ); |
---|
| 61 | |
---|
| 62 | // Draw complete graph embedded inline: output the png |
---|
| 63 | // |
---|
| 64 | $myChart->Stroke(); |
---|
| 65 | ?> |
---|