} $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();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay = array(20, 10, 35, 5, 17, 35, 22); // Setup the graph $graph = new Graph\Graph(400, 250); $graph->SetScale("intlin", 0, $aYMax = 50); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->SetBox(false); $graph->title->Set('Step Line'); $graph->ygrid->Show(true); $graph->xgrid->Show(false); $graph->yaxis->HideZeroLabel(); $graph->ygrid->SetFill(true, '#FFFFFF@0.5', '#FFFFFF@0.5'); $graph->SetBackgroundGradient('blue', '#55eeff', GRAD_HOR, BGRAD_PLOT); $graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D', 'E', 'F', 'G')); // Create the line $p1 = new Plot\LinePlot($datay); $graph->Add($p1); $p1->SetFillGradient('yellow', 'red'); $p1->SetStepStyle(); $p1->SetColor('#808000'); // Output line $graph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay = array(20, 10, 35, 5, 17, 35, 22); // Setup the graph $graph = new Graph\Graph(400, 200); $graph->SetMargin(40, 40, 20, 30); $graph->SetScale("intlin"); $graph->SetBox(); $graph->SetMarginColor('darkgreen@0.8'); // Setup a background gradient image $graph->SetBackgroundGradient('darkred', 'yellow', GRAD_HOR, BGRAD_PLOT); $graph->title->Set('Gradient filled line plot ex3'); $graph->yscale->SetAutoMin(0); // Create the line $p1 = new Plot\LinePlot($datay); $p1->SetFillGradient('white', 'darkgreen', 4); $graph->Add($p1); // Output line $graph->Stroke();
// content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay1 = array(4, 26, 12, 18, 8, 22); $datay2 = array(12, 9, 42, 8, 20, 19); // Setup the graph $graph = new Graph\Graph(300, 200); $graph->SetMarginColor('white'); $graph->SetScale("textlin", 0, 50); $graph->SetMargin(30, 50, 30, 30); // We must have the frame enabled to get the gradient // However, we don't want the frame line so we set it to // white color which makes it invisible. $graph->SetFrame(true, 'white'); // Setup a background gradient image $graph->SetBackgroundGradient('blue', 'navy:0.5', GRAD_HOR, BGRAD_PLOT); // Setup the tab title $graph->tabtitle->Set(' 3rd Division '); $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 13); // Setup x,Y grid $graph->xgrid->Show(); $graph->xgrid->SetColor('gray@0.5'); $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); $graph->ygrid->SetColor('gray@0.5'); // Setup color for axis and labels on axis $graph->xaxis->SetColor('orange', 'black'); $graph->yaxis->SetColor('orange', 'black'); // Ticks on the outsid $graph->xaxis->SetTickSide(SIDE_DOWN); $graph->yaxis->SetTickSide(SIDE_LEFT); // Setup the legend box colors and font
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay = array(0, 25, 12, 47, 27, 27, 0); // Setup the graph $graph = new Graph\Graph(350, 250); $graph->SetScale("intlin", 0, $aYMax = 50); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->SetMargin(40, 40, 50, 40); $graph->title->Set('Inverted Y-axis'); $graph->SetBox(false); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // For background to be gradient, setfill is needed first. $graph->ygrid->SetFill(true, '#FFFFFF@0.5', '#FFFFFF@0.5'); $graph->SetBackgroundGradient('#FFFFFF', '#00FF7F', GRAD_HOR, BGRAD_PLOT); $graph->xaxis->SetTickLabels(array('G', 'F', 'E', 'D', 'C', 'B', 'A')); $graph->xaxis->SetLabelMargin(20); $graph->yaxis->SetLabelMargin(20); $graph->SetAxisStyle(AXSTYLE_BOXOUT); $graph->img->SetAngle(180); // Create the line $p1 = new Plot\LinePlot($datay); $graph->Add($p1); $p1->SetFillGradient('#FFFFFF', '#F0F8FF'); $p1->SetColor('#aadddd'); // Output line $graph->Stroke();