[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_log.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_line.php');
|
---|
| 5 |
|
---|
| 6 | $ydata = array(11,3,8,12,5,1,9,13,5,7);
|
---|
| 7 | $y2data = array(354,200,265,99,111,91,198,225,293,251);
|
---|
| 8 | $datax=array("Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep");
|
---|
| 9 |
|
---|
| 10 | // Create the graph. These two calls are always required
|
---|
| 11 | $graph = new Graph(350,200);
|
---|
| 12 | $graph->img->SetMargin(40,110,20,40);
|
---|
| 13 | $graph->SetScale("textlog");
|
---|
| 14 | $graph->SetY2Scale("log");
|
---|
| 15 | $graph->SetShadow();
|
---|
| 16 |
|
---|
| 17 | $graph->ygrid->Show(true,true);
|
---|
| 18 | $graph->xgrid->Show(true,false);
|
---|
| 19 |
|
---|
| 20 | // Create the linear plot
|
---|
| 21 | $lineplot=new LinePlot($ydata);
|
---|
| 22 | $lineplot2=new LinePlot($y2data);
|
---|
| 23 |
|
---|
| 24 | $graph->yaxis->scale->ticks->SupressFirst();
|
---|
| 25 | $graph->y2axis->scale->ticks->SupressFirst();
|
---|
| 26 | // Add the plot to the graph
|
---|
| 27 | $graph->Add($lineplot);
|
---|
| 28 | $graph->AddY2($lineplot2);
|
---|
| 29 | $lineplot2->SetColor("orange");
|
---|
| 30 | $lineplot2->SetWeight(2);
|
---|
| 31 | $graph->y2axis->SetColor("orange");
|
---|
| 32 |
|
---|
| 33 | $graph->title->Set("Example 10");
|
---|
| 34 | $graph->xaxis->title->Set("X-title");
|
---|
| 35 | $graph->yaxis->title->Set("Y-title");
|
---|
| 36 |
|
---|
| 37 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 38 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 39 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 40 |
|
---|
| 41 | $lineplot->SetColor("blue");
|
---|
| 42 | $lineplot->SetWeight(2);
|
---|
| 43 |
|
---|
| 44 | $lineplot2->SetColor("orange");
|
---|
| 45 | $lineplot2->SetWeight(2);
|
---|
| 46 |
|
---|
| 47 | $graph->yaxis->SetColor("blue");
|
---|
| 48 |
|
---|
| 49 | $lineplot->SetLegend("Plot 1");
|
---|
| 50 | $lineplot2->SetLegend("Plot 2");
|
---|
| 51 |
|
---|
| 52 | $graph->legend->Pos(0.05,0.5,"right","center");
|
---|
| 53 |
|
---|
| 54 | $graph->xaxis->SetTickLabels($datax);
|
---|
| 55 | $graph->xaxis->SetTextTickInterval(2);
|
---|
| 56 |
|
---|
| 57 | // Display the graph
|
---|
| 58 | $graph->Stroke();
|
---|
| 59 | ?>
|
---|