Пример #1
0
include "../jpgraph_utils.inc.php";
//
// Create some random data for the plot. We use the current time for the
// first X-position
//
$datay = array();
$datax = array();
$ts = time();
$n = 15;
// Number of data points
for ($i = 0; $i < $n; ++$i) {
    $datax[$i] = $ts + $i * 700000;
    $datay[$i] = rand(5, 60);
}
// Now get labels at the start of each month
list($tickPositions, $minTickPositions) = DateScaleUtils::GetTicks($datax);
// We add some grace to the end of the X-axis scale so that the first and last
// data point isn't exactly at the very end or beginning of the scale
$grace = 400000;
$xmin = $datax[0] - $grace;
$xmax = $datax[$n - 1] + $grace;
//
// The code to setup a very basic graph
//
$graph = new Graph(400, 200);
//
// We use an integer scale on the X-axis since the positions on the X axis
// are assumed to be UNI timestamps
$graph->SetScale('intlin', 0, 0, $xmin, $xmax);
$graph->title->Set('Basic example with manual ticks');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
Пример #2
0
//
// Create some random data for the plot. We use the current time for the
// first X-position
//
$datay = array();
$datax = array();
$ts = time();
$n = 15;
// Number of data points
for ($i = 0; $i < $n; ++$i) {
    $datax[$i] = $ts + $i * 700000;
    $datay[$i] = rand(5, 60);
}
// Now get labels at the start of each month
$dateUtils = new DateScaleUtils();
list($tickPositions, $minTickPositions) = $dateUtils->GetTicks($datax);
// We add some grace to the end of the X-axis scale so that the first and last
// data point isn't exactly at the very end or beginning of the scale
$grace = 400000;
$xmin = $datax[0] - $grace;
$xmax = $datax[$n - 1] + $grace;
//
// The code to setup a very basic graph
//
$graph = new Graph(400, 200);
//
// We use an integer scale on the X-axis since the positions on the X axis
// are assumed to be UNI timestamps
$graph->SetScale('intlin', 0, 0, $xmin, $xmax);
$graph->title->Set('Basic example with manual ticks');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);