// Data arrays $datax = array(10, 20, 30, 40, 54, 60, 70, 80); $datay = array(12, 23, 65, 18, 84, 28, 86, 44); // Setup the graph $graph = new Graph\Graph(400, 270); // We add a small 1pixel left,right,bottom margin so the plot area // doesn't cover the frame around the graph. $graph->img->SetMargin(1, 1, 1, 1); $graph->SetScale('linlin', 0, 100, 0, 100); // We don't want any axis to be shown $graph->xaxis->Hide(); $graph->yaxis->Hide(); // Use a worldmap as the background and let it fill the plot area $graph->SetBackgroundImage(WORLDMAP, BGIMG_FILLPLOT); // Setup a nice title with a striped bevel background $graph->title->Set("Pushpin graph"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 16); $graph->title->SetColor('white'); $graph->SetTitleBackground('darkgreen', TITLEBKG_STYLE1, TITLEBKG_FRAME_BEVEL); $graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED, 'blue', 'darkgreen'); // Finally create the lineplot $lp = new Plot\LinePlot($datay, $datax); $lp->SetColor('lightgray'); // We want the markers to be an image $lp->mark->SetType(MARK_IMG_PUSHPIN, 'blue', 0.6); // Install the Y-X callback for the markers $lp->mark->SetCallbackYX('markCallback'); // ... and add it to the graph $graph->Add($lp); // .. and output to browser $graph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_plotline.php'; $datay = array(2, 3, 5, 8.5, 11.5, 6, 3); // Create the graph. $graph = new Graph\Graph(460, 400, 'auto'); $graph->SetScale("textlin"); $graph->SetMargin(40, 20, 50, 70); $graph->legend->SetPos(0.5, 0.97, 'center', 'bottom'); $graph->title->Set('Plot line legend'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->SetTitleBackground('lightblue:1.3', TITLEBKG_STYLE2, TITLEBKG_FRAME_BEVEL); $graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED, 'lightblue', 'navy'); // Create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->value->Show(); $bplot->value->SetFont(FF_VERDANA, FS_BOLD, 8); $bplot->SetValuePos('top'); $bplot->SetLegend('Bar Legend'); $graph->Add($bplot); $pline = new PlotLine(HORIZONTAL, 8, 'red', 2); $pline->SetLegend('Line Legend'); $graph->legend->SetColumns(10); $graph->Add($pline); $graph->Stroke();