<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay = array(0.298, 0.3039, 0.302, 0.3027, 0.3015); $graph = new Graph\Graph(300, 200); $graph->img->SetMargin(40, 40, 40, 40); $graph->img->SetAntiAliasing(); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set("Example of 10% top/bottom grace"); $graph->title->SetFont(FF_FONT1, FS_BOLD); // Add 10% grace to top and bottom of plot $graph->yscale->SetGrace(10, 10); $p1 = new Plot\LinePlot($datay); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("red"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p1->SetCenter(); $graph->Add($p1); $graph->Stroke();
$graph->img->SetMargin(40, 180, 40, 40); $graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLPLOT); $graph->img->SetAntiAliasing("white"); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set("Background image"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Slightly adjust the legend from it's default position in the // top right corner. $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create the first line $p1 = new Plot\LinePlot($datay); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("red"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Triumph Tiger -98"); $graph->Add($p1); // ... and the second $p2 = new Plot\LinePlot($data2y); $p2->mark->SetType(MARK_STAR); $p2->mark->SetFillColor("red"); $p2->mark->SetWidth(4); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend("New tiger -99"); $graph->Add($p2); // Output line $graph->Stroke();