예제 #1
0
$n = count($datax);
$xmin = $datax[0];
$xmax = $datax[$n - 1];
//
// The code to setup a very basic graph
//
$graph = new Graph\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('linlin', 0, 0, $xmin, $xmax);
$graph->title->Set('Example with manual tick labels');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->SetColor('white');
// Setup a abackground gradient
$graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN);
$graph->SetPlotGradient('black', 'darkred:0.8', 2);
// Make sure that the X-axis is always at the bottom of the scale
// (By default the X-axis is alwys positioned at Y=0 so if the scale
// doesn't happen to include 0 the axis will not be shown)
$graph->xaxis->SetPos('min');
// Now set the tic positions
$graph->xaxis->SetMajTickPositions($tickPositions, $tickLabels);
// Use Times font
$graph->xaxis->SetFont(FF_TIMES, FS_NORMAL, 11);
$graph->yaxis->SetFont(FF_TIMES, FS_NORMAL, 9);
// Set colors for axis
$graph->xaxis->SetColor('lightgray');
$graph->yaxis->SetColor('lightgray');
// Add a X-grid
$graph->xgrid->Show();
// Show ticks outwards