| [42] | 1 | <?php // content="text/plain; charset=utf-8"
|
|---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
|---|
| 3 | require_once ('jpgraph/jpgraph_line.php');
|
|---|
| 4 |
|
|---|
| 5 | $n = 8;
|
|---|
| 6 | for($i=0; $i < $n; ++$i ) {
|
|---|
| 7 | $datay[$i] = rand(1,10);
|
|---|
| 8 | $datay2[$i] = rand(10,55);
|
|---|
| 9 | $datay3[$i] = rand(200,600);
|
|---|
| 10 | $datay4[$i] = rand(500,800);
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | // Setup the graph
|
|---|
| 14 | $graph = new Graph(450,250);
|
|---|
| 15 | $graph->SetMargin(40,150,40,30);
|
|---|
| 16 | $graph->SetMarginColor('white');
|
|---|
| 17 |
|
|---|
| 18 | $graph->SetScale('intlin');
|
|---|
| 19 | $graph->title->Set('Using multiple Y-axis');
|
|---|
| 20 | $graph->title->SetFont(FF_ARIAL,FS_NORMAL,14);
|
|---|
| 21 |
|
|---|
| 22 | $graph->SetYScale(0,'lin');
|
|---|
| 23 | $graph->SetYScale(1,'lin');
|
|---|
| 24 | $graph->SetYScale(2,'lin');
|
|---|
| 25 |
|
|---|
| 26 | $p1 = new LinePlot($datay);
|
|---|
| 27 | $graph->Add($p1);
|
|---|
| 28 |
|
|---|
| 29 | $p2 = new LinePlot($datay2);
|
|---|
| 30 | $p2->SetColor('teal');
|
|---|
| 31 | $graph->AddY(0,$p2);
|
|---|
| 32 | $graph->ynaxis[0]->SetColor('teal');
|
|---|
| 33 |
|
|---|
| 34 | $p3 = new LinePlot($datay3);
|
|---|
| 35 | $p3->SetColor('red');
|
|---|
| 36 | $graph->AddY(1,$p3);
|
|---|
| 37 | $graph->ynaxis[1]->SetColor('red');
|
|---|
| 38 |
|
|---|
| 39 | $p4 = new LinePlot($datay4);
|
|---|
| 40 | $p4->SetColor('blue');
|
|---|
| 41 | $graph->AddY(2,$p4);
|
|---|
| 42 | $graph->ynaxis[2]->SetColor('blue');
|
|---|
| 43 |
|
|---|
| 44 | // Output line
|
|---|
| 45 | $graph->Stroke();
|
|---|
| 46 | ?>
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|