1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_line.php');
|
---|
4 |
|
---|
5 | // Callback to negate the argument
|
---|
6 | function _cb_negate($aVal) {
|
---|
7 | return round(-$aVal);
|
---|
8 | }
|
---|
9 |
|
---|
10 | // A fake depth curve
|
---|
11 | $ydata = array(0,1,4,5,8,9,10,14,16,16,16,18,20,20,20,22,22.5,22,19,19,15,15,15,15,10,10,10,6,5,5,5,4,4,2,1,0);
|
---|
12 |
|
---|
13 | // Negate all data
|
---|
14 | $n = count($ydata);
|
---|
15 | for($i=0; $i<$n; ++$i) {
|
---|
16 | $ydata[$i] = round(-$ydata[$i]);
|
---|
17 | }
|
---|
18 |
|
---|
19 | // Basic graph setup
|
---|
20 | $graph = new Graph(400,300);
|
---|
21 | $graph->SetScale("linlin");
|
---|
22 | $graph->img->SetMargin(50,50,60,40);
|
---|
23 | $graph->SetMarginColor('darkblue');
|
---|
24 | $graph->SetColor('darkblue');
|
---|
25 | $graph->SetAxisStyle(AXSTYLE_BOXOUT);
|
---|
26 | $graph->SetBackgroundImage("blueblack400x300grad.png",1);
|
---|
27 | //$graph->SetBackgroundImage("lightbluedarkblue400x300grad.png",1);
|
---|
28 |
|
---|
29 | $graph->title->Set("Depth curve. Dive #2");
|
---|
30 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
31 | $graph->title->SetColor("white");
|
---|
32 |
|
---|
33 | $graph->subtitle->Set("(Negated Y-axis)");
|
---|
34 | $graph->subtitle->SetFont(FF_FONT1,FS_NORMAL);
|
---|
35 | $graph->subtitle->SetColor("white");
|
---|
36 |
|
---|
37 | // Setup axis
|
---|
38 | $graph->yaxis->SetLabelFormatCallback("_cb_negate");
|
---|
39 | $graph->xaxis->SetColor("lightblue","white");
|
---|
40 | $graph->yaxis->SetColor("lightblue","white");
|
---|
41 | $graph->ygrid->SetColor("blue");
|
---|
42 |
|
---|
43 |
|
---|
44 | $lp1 = new LinePlot($ydata);
|
---|
45 | $lp1->SetColor("yellow");
|
---|
46 | $lp1->SetWeight(2);
|
---|
47 |
|
---|
48 |
|
---|
49 | $graph->Add($lp1);
|
---|
50 | $graph->Stroke();
|
---|
51 | ?>
|
---|
52 |
|
---|
53 |
|
---|