source: trunk/xgraph/jpgraph/Examples/example6.2.php

Last change on this file was 42, checked in by marrucho, 10 years ago
File size: 1.2 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_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 and specify the scale for both Y-axis
9$graph = new Graph(300,240);   
10$graph->SetScale("textlin");
11$graph->SetShadow();
12
13// Adjust the margin
14$graph->img->SetMargin(40,40,20,70);
15
16// Create the two linear plot
17$lineplot=new LinePlot($ydata);
18$lineplot->SetStepStyle();
19
20// Adjust the axis color
21$graph->yaxis->SetColor("blue");
22
23$graph->title->Set("Example 6.2");
24$graph->xaxis->title->Set("X-title");
25$graph->yaxis->title->Set("Y-title");
26
27$graph->title->SetFont(FF_FONT1,FS_BOLD);
28$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
29$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
30
31// Set the colors for the plots
32$lineplot->SetColor("blue");
33$lineplot->SetWeight(2);
34
35// Set the legends for the plots
36$lineplot->SetLegend("Plot 1");
37
38// Add the plot to the graph
39$graph->Add($lineplot);
40
41// Adjust the legend position
42$graph->legend->SetLayout(LEGEND_HOR);
43$graph->legend->Pos(0.4,0.95,"center","bottom");
44
45// Display the graph
46$graph->Stroke();
47?>
Note: See TracBrowser for help on using the repository browser.