[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_line.php');
|
---|
| 4 |
|
---|
| 5 | $ydata = array(11,3,8,12,5,1,9,13,5,7);
|
---|
| 6 | $y2data = array(354,200,265,99,111,91,198,225,293,251);
|
---|
| 7 |
|
---|
| 8 | // Create the graph. These two calls are always required
|
---|
| 9 | $graph = new Graph(300,200);
|
---|
| 10 | $graph->img->SetMargin(40,40,20,40);
|
---|
| 11 | $graph->SetScale("textlin");
|
---|
| 12 | $graph->SetY2Scale("lin");
|
---|
| 13 | $graph->SetShadow();
|
---|
| 14 |
|
---|
| 15 | // Create the linear plot
|
---|
| 16 | $lineplot=new LinePlot($ydata);
|
---|
| 17 | $lineplot2=new LinePlot($y2data);
|
---|
| 18 |
|
---|
| 19 | // Add the plot to the graph
|
---|
| 20 | $graph->Add($lineplot);
|
---|
| 21 | $graph->AddY2($lineplot2);
|
---|
| 22 | $lineplot2->SetColor("orange");
|
---|
| 23 | $lineplot2->SetWeight(2);
|
---|
| 24 | $graph->y2axis->SetColor("orange");
|
---|
| 25 |
|
---|
| 26 | $graph->title->Set("Example 5");
|
---|
| 27 | $graph->xaxis->title->Set("X-title");
|
---|
| 28 | $graph->yaxis->title->Set("Y-title");
|
---|
| 29 |
|
---|
| 30 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 31 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 32 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 33 |
|
---|
| 34 | $lineplot->SetColor("blue");
|
---|
| 35 | $lineplot->SetWeight(2);
|
---|
| 36 |
|
---|
| 37 | $lineplot2->SetColor("orange");
|
---|
| 38 | $lineplot2->SetWeight(2);
|
---|
| 39 |
|
---|
| 40 | $graph->yaxis->SetColor("blue");
|
---|
| 41 |
|
---|
| 42 | $lineplot->SetLegend("Plot 1");
|
---|
| 43 | $lineplot2->SetLegend("Plot 2");
|
---|
| 44 |
|
---|
| 45 | // Display the graph
|
---|
| 46 | $graph->Stroke();
|
---|
| 47 | ?>
|
---|