1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_line.php'); |
---|
4 | |
---|
5 | |
---|
6 | // Setup some dummy targets for the CSIM |
---|
7 | $n = 5; |
---|
8 | for($i=0; $i < $n; ++$i ) { |
---|
9 | $targ1[$i] = "#$i"; |
---|
10 | $targ2[$i] = "#$i"; |
---|
11 | $targ3[$i] = "#$i"; |
---|
12 | $alts1[$i] = "val=%d"; |
---|
13 | $alts2[$i] = "val=%d"; |
---|
14 | $alts3[$i] = "val=%d"; |
---|
15 | } |
---|
16 | |
---|
17 | // Some data for the points |
---|
18 | $datay1 = array(3,10,4,1,6); |
---|
19 | $datay2 = array(25,22,18,24,20); |
---|
20 | $datay3 = array(89,70,92,77,96); |
---|
21 | |
---|
22 | // Create a basic graph with some suitable margins |
---|
23 | $graph = new Graph(500,250); |
---|
24 | $graph->SetMargin(60,180,50,40); |
---|
25 | $graph->SetMarginColor('white'); |
---|
26 | $graph->title->Set("Multi Y-axes with Image Map"); |
---|
27 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
28 | |
---|
29 | // Setup the scales for all axes |
---|
30 | $graph->SetScale("intlin"); |
---|
31 | $graph->SetYScale(0,'int'); |
---|
32 | $graph->SetYScale(1,'int'); |
---|
33 | |
---|
34 | // Standard Y-axis plot |
---|
35 | $lp1 = new LinePlot($datay1); |
---|
36 | $lp1->SetLegend('2001'); |
---|
37 | $lp1->mark->SetType(MARK_DIAMOND); |
---|
38 | $lp1->mark->SetWidth(15); |
---|
39 | $lp1->mark->SetFillColor('orange'); |
---|
40 | $lp1->SetCSIMTargets($targ1,$alts1); |
---|
41 | $graph->yaxis->title->Set('Basic Rate'); |
---|
42 | $graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,10); |
---|
43 | $graph->yaxis->title->SetColor('black'); |
---|
44 | $graph->Add($lp1); |
---|
45 | |
---|
46 | // First multi Y-axis plot |
---|
47 | $lp2 = new LinePlot($datay2); |
---|
48 | $lp2->SetLegend('2002'); |
---|
49 | $lp2->mark->SetType(MARK_DIAMOND); |
---|
50 | $lp2->mark->SetWidth(15); |
---|
51 | $lp2->mark->SetFillColor('darkred'); |
---|
52 | $lp2->SetCSIMTargets($targ2,$alts2); |
---|
53 | $graph->ynaxis[0]->SetColor('darkred'); |
---|
54 | $graph->ynaxis[0]->title->Set('Rate A'); |
---|
55 | $graph->ynaxis[0]->title->SetFont(FF_ARIAL,FS_BOLD,10); |
---|
56 | $graph->ynaxis[0]->title->SetColor('darkred'); |
---|
57 | $graph->AddY(0,$lp2); |
---|
58 | |
---|
59 | // Second multi Y-axis plot |
---|
60 | $lp3 = new LinePlot($datay3); |
---|
61 | $lp3->SetLegend('2003'); |
---|
62 | $lp3->mark->SetType(MARK_DIAMOND); |
---|
63 | $lp3->mark->SetWidth(15); |
---|
64 | $lp3->mark->SetFillColor('darkgreen'); |
---|
65 | $lp3->SetCSIMTargets($targ3,$alts3); |
---|
66 | $graph->ynaxis[1]->SetColor('darkgreen'); |
---|
67 | $graph->ynaxis[1]->title->Set('Rate B'); |
---|
68 | $graph->ynaxis[1]->title->SetFont(FF_ARIAL,FS_BOLD,10); |
---|
69 | $graph->ynaxis[1]->title->SetColor('darkgreen'); |
---|
70 | $graph->AddY(1,$lp3); |
---|
71 | |
---|
72 | // Send back the HTML page which will call this script again |
---|
73 | // to retrieve the image. |
---|
74 | $graph->StrokeCSIM(); |
---|
75 | ?> |
---|