| Server IP : 104.21.80.248 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/myschool/triamudom/check/webadmin/S_Graph/jpgraph/Examples/ |
Upload File : |
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_bar.php');
function readsunspotdata($aFile, &$aYears, &$aSunspots) {
$lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if( $lines === false ) {
throw new JpGraphException('Can not read sunspot data file.');
}
foreach( $lines as $line => $datarow ) {
$split = preg_split('/[\s]+/',$datarow);
$aYears[] = substr(trim($split[0]),0,4);
$aSunspots[] = trim($split[1]);
}
}
$year = array();
$ydata = array();
readsunspotdata('yearssn.txt',$year,$ydata);
// Width and height of the graph
$width = 600; $height = 200;
// Create a graph instance
$graph = new Graph($width,$height);
// Specify what scale we want to use,
// int = integer scale for the X-axis
// int = integer scale for the Y-axis
$graph->SetScale('intint');
// Setup a title for the graph
$graph->title->Set('Sunspot example');
// Setup titles and X-axis labels
$graph->xaxis->title->Set('(year from 1701)');
// Setup Y-axis title
$graph->yaxis->title->Set('(# sunspots)');
// Create the linear plot
$lineplot=new LinePlot($ydata);
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
?>