[42] | 1 | <?php // content="text/plain; charset=utf-8" |
---|
| 2 | // A simple Polar graph, |
---|
| 3 | |
---|
| 4 | require_once ('jpgraph/jpgraph.php'); |
---|
| 5 | require_once ('jpgraph/jpgraph_polar.php'); |
---|
| 6 | |
---|
| 7 | $data = array(5,1,20,5,30,25,40,60, |
---|
| 8 | 50,110,60,160,70,210,75,230,80,260,85,370, |
---|
| 9 | 90,480, |
---|
| 10 | 95,370,100,260,105,230, |
---|
| 11 | 110,210,120,160,130,110,140,60, |
---|
| 12 | 150,25,160,5,175,1); |
---|
| 13 | $n = count($data); |
---|
| 14 | /* |
---|
| 15 | for($i=0; $i < $n; $i+=2 ) { |
---|
| 16 | $data[$n+$i] = 360-$data[$i]; |
---|
| 17 | $data[$n+$i+1] = $data[$i+1]; |
---|
| 18 | } |
---|
| 19 | */ |
---|
| 20 | $graph = new PolarGraph(350,480); |
---|
| 21 | $graph->SetScale('log',100); |
---|
| 22 | $graph->SetType(POLAR_360); |
---|
| 23 | |
---|
| 24 | // Hide frame around graph (by setting width=0) |
---|
| 25 | $graph->SetFrame(true,'white',1); |
---|
| 26 | |
---|
| 27 | // Show both major and minor grid lines |
---|
| 28 | $graph->axis->ShowGrid(true,true); |
---|
| 29 | |
---|
| 30 | // Set color for gradient lines |
---|
| 31 | $graph->axis->SetGridColor('lightblue:0.9','lightblue:0.9','lightblue:0.9'); |
---|
| 32 | |
---|
| 33 | // Set label and axis colors |
---|
| 34 | $graph->axis->SetColor('black','navy','darkred'); |
---|
| 35 | |
---|
| 36 | // Draw the ticks on the bottom side of the radius axis |
---|
| 37 | $graph->axis->SetTickSide(SIDE_DOWN); |
---|
| 38 | |
---|
| 39 | // Increase the margin for the labels since we changed the |
---|
| 40 | // side of the ticks. |
---|
| 41 | $graph->axis->SetLabelMargin(6); |
---|
| 42 | |
---|
| 43 | // Change fonts |
---|
| 44 | $graph->axis->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
| 45 | $graph->axis->SetAngleFont(FF_ARIAL,FS_NORMAL,8); |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | // Setup graph title |
---|
| 49 | $graph->title->Set('Polar plot #10'); |
---|
| 50 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,16); |
---|
| 51 | $graph->title->SetColor('navy'); |
---|
| 52 | |
---|
| 53 | // Setup tab title |
---|
| 54 | $graph->tabtitle->Set('Microphone #1'); |
---|
| 55 | $graph->tabtitle->SetColor('brown:0.5','lightyellow'); |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | $p = new PolarPlot($data); |
---|
| 59 | $p->SetFillColor('lightblue@0.5'); |
---|
| 60 | $p->mark->SetType(MARK_SQUARE); |
---|
| 61 | |
---|
| 62 | $graph->Add($p); |
---|
| 63 | |
---|
| 64 | $graph->Stroke(); |
---|
| 65 | |
---|
| 66 | ?> |
---|