Ejemplo n.º 1
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_utils.inc.php';
$f = new FuncGenerator('cos($i)', '$i*$i*$i');
list($xdata, $ydata) = $f->E(-M_PI, M_PI, 25);
$graph = new Graph\Graph(350, 430);
$graph->SetScale("linlin");
$graph->SetShadow();
$graph->img->SetMargin(50, 50, 60, 40);
$graph->SetBox(true, 'black', 2);
$graph->SetMarginColor('white');
$graph->SetColor('lightyellow');
$graph->SetAxisStyle(AXSTYLE_BOXIN);
$graph->xgrid->Show();
//$graph->xaxis->SetLabelFormat('%.0f');
$graph->img->SetMargin(50, 50, 60, 40);
$graph->title->Set("Function plot");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->subtitle->Set("(BOXIN Axis style)");
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
$lp1 = new Plot\LinePlot($ydata, $xdata);
$lp1->SetColor("blue");
$lp1->SetWeight(2);
$graph->Add($lp1);
$graph->Stroke();
Ejemplo n.º 2
0
$graph->SetBox(true, 'black', 2);
$graph->SetMarginColor('white');
$graph->SetColor('lightyellow');
// ... and titles
$graph->title->Set('Example of Function plot');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->subtitle->Set("(With some more advanced axis formatting\nHiding first and last label)");
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
$graph->xgrid->Show();
$graph->yaxis->SetPos(0);
$graph->yaxis->SetWeight(2);
$graph->yaxis->HideZeroLabel();
$graph->yaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('black', 'darkblue');
$graph->yaxis->HideTicks(true, false);
$graph->yaxis->HideFirstLastLabel();
$graph->xaxis->SetWeight(2);
$graph->xaxis->HideZeroLabel();
$graph->xaxis->HideFirstLastLabel();
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetColor('black', 'darkblue');
$lp1 = new Plot\LinePlot($ydata, $xdata);
$lp1->SetColor('blue');
$lp1->SetWeight(2);
$lp2 = new Plot\LinePlot($y2data, $x2data);
list($xm, $ym) = $lp2->Max();
$lp2->SetColor('red');
$lp2->SetWeight(2);
$graph->Add($lp1);
$graph->Add($lp2);
$graph->Stroke();
Ejemplo n.º 3
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 250);
$graph->SetScale("textlin");
$graph->SetMargin(40, 40, 50, 50);
// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);
// Steup graph titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11);
$graph->subtitle->Set('"BGIMG_FILLFRAME"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg', BGIMG_FILLFRAME);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Ejemplo n.º 4
0
// 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();
Ejemplo n.º 5
0
// 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
$graph->legend->SetColor('white', 'navy');
$graph->legend->SetFillColor('navy@0.25');
$graph->legend->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->legend->SetShadow('darkgray@0.4', 3);
$graph->legend->SetPos(0.05, 0.05, 'right', 'top');
// Create the first line
$p1 = new Plot\LinePlot($datay1);
$p1->SetColor("red");
$p1->SetWeight(2);
$p1->SetLegend('2002');
$graph->Add($p1);
// Create the second line
$p2 = new Plot\LinePlot($datay2);
$p2->SetColor("lightyellow");
$p2->SetLegend('2001');
$p2->SetWeight(2);
$graph->Add($p2);
// Output line
$graph->Stroke();
Ejemplo n.º 6
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_log.php';
// Matrix size rxr
$r = 10;
// Max Interpolation factor
$f = 5;
for ($i = 1; $i <= $f; ++$i) {
    $xdata[] = $i;
    $ydata[] = pow($r * pow(2, $i - 1) - (pow(2, $i) - 1), 2);
}
$graph = new Graph\Graph(400, 240);
$graph->SetScale('intlog');
$graph->SetMargin(50, 50, 20, 30);
$graph->SetFrame(false);
$graph->SetBox(true, 'black', 2);
$graph->SetMarginColor('white');
$graph->SetColor('lightyellow@0.7');
$graph->title->Set('Interpolation growth for size 10x10');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetTitle('Interpolation factor', 'center');
$graph->xaxis->SetTitleMargin(10);
$graph->SetAxisStyle(AXSTYLE_YBOXIN);
$graph->xgrid->Show();
$lp1 = new Plot\LinePlot($ydata, $xdata);
$lp1->SetColor('darkred');
$lp1->SetWeight(3);
$graph->Add($lp1);
$graph->Stroke();
Ejemplo n.º 7
0
$graph->SetMargin(50, 50, 60, 40);
$graph->SetMarginColor('darkblue');
$graph->SetColor('darkblue');
// Setup titles
$graph->title->Set("Inverting both Y-axis");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetColor("white");
$graph->subtitle->Set("(Negated Y & Y2 axis)");
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
$graph->subtitle->SetColor("white");
// Setup axis
$graph->yaxis->SetLabelFormatCallback("_cb_negate");
$graph->xaxis->SetColor("lightblue", "white");
$graph->yaxis->SetColor("lightblue", "white");
$graph->ygrid->SetColor("blue");
// Setup Y2 axis
$graph->y2axis->SetLabelFormatCallback("_cb_negate");
$graph->y2axis->SetColor("darkred", "white");
$graph->y2scale->SetAutoMax(0);
// To make sure it starts with 0
// Setup plot 1
$lp1 = new Plot\LinePlot($ydata);
$lp1->SetColor("yellow");
$lp1->SetWeight(2);
$graph->Add($lp1);
// Setup plot 2
$lp2 = new Plot\LinePlot($y2data);
$lp2->SetColor("darkred");
$lp2->SetWeight(2);
$graph->AddY2($lp2);
$graph->Stroke();
Ejemplo n.º 8
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$ydata = array(12, 17, 22, 19, 5, 15);
$graph = new Graph\Graph(270, 170);
$graph->SetMargin(30, 90, 30, 30);
$graph->SetScale("textlin");
$graph->img->SetAngle(90);
$graph->img->SetCenter(floor(270 / 2), floor(170 / 2));
$line = new Plot\LinePlot($ydata);
$line->SetLegend('2002');
$line->SetColor('darkred');
$line->SetWeight(2);
$graph->Add($line);
// Output graph
$graph->Stroke();
Ejemplo n.º 9
0
// Set the start time to be on the closest minute just before the "start" timestamp
$adjstart = floor($start / 60);
// Create a data set in range (20,100) and X-positions
// We also apply a simple low pass filter on the data to make it less
// random and a little smoother
$data = array();
$xdata = array();
$data[0] = rand(20, 100);
$xdata[0] = $adjstart;
for ($i = 1; $i < NDATAPOINTS; ++$i) {
    $data[$i] = rand(20, 100) * 0.2 + $data[$i - 1] * 0.8;
    $xdata[$i] = $adjstart + $i * SAMPLERATE;
}
// Assume that the data points represents data that is sampled every 10s
// when determing the end value on the scale. We also add some extra
// length to end on an even label tick.
$adjend = $adjstart + (NDATAPOINTS + 10) * 10;
$graph = new Graph\Graph(500, 250);
$graph->SetMargin(40, 20, 30, 50);
// Now specify the X-scale explicit but let the Y-scale be auto-scaled
$graph->SetScale("intlin", 0, 0, $adjstart, $adjend);
$graph->title->Set("Example on TimeStamp Callback");
// Setup the callback and adjust the angle of the labels
$graph->xaxis->SetLabelFormatCallback('TimeCallback');
$graph->xaxis->SetLabelAngle(90);
// Set the labels every 5min (i.e. 300seconds) and minor ticks every minute
$graph->xaxis->scale->ticks->Set(300, 60);
$line = new Plot\LinePlot($data, $xdata);
$line->SetColor('lightblue');
$graph->Add($line);
$graph->Stroke();
Ejemplo n.º 10
0
$graph2 = new Graph\Graph(WIND_WIDTH - 30, WIND_HEIGHT);
$graph2->SetScale('datlin');
$graph2->Set90AndMargin(5, 20, 60, 30);
$graph2->SetMarginColor(BKG_COLOR);
$graph2->SetFrame(true, 'white', 0);
$graph2->SetBox();
$graph2->title->Set('Windspeed');
$graph2->title->SetColor('red');
$graph2->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph2->title->SetMargin(5);
$graph2->xaxis->HideLabels();
$graph2->xgrid->Show();
$graph2->yaxis->SetLabelAngle(90);
$graph2->yaxis->SetColor('red');
$graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph2->yaxis->SetLabelMargin(0);
$graph2->yaxis->scale->SetAutoMin(0);
$line2 = new Plot\LinePlot($data_windspeed, $xdata);
$line2->SetStepStyle();
$line2->SetColor('red');
$graph2->Add($line2);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(2, 2, 2, 2);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetFillColor(BKG_COLOR);
$mgraph->Add($graph);
$mgraph->Add($graph2, 280, 0);
$mgraph->Stroke();
Ejemplo n.º 11
0
}
// A fake depth curve
$ydata = array(0, 1, 4, 5, 8, 9, 10, 14, 16, 16, 16, 18, 20, 20, 20, 22, 22.5, 22, 19, 19, 15, 15, 15, 15, 10, 10, 10, 6, 5, 5, 5, 4, 4, 2, 1, 0);
// Negate all data
$n = count($ydata);
for ($i = 0; $i < $n; ++$i) {
    $ydata[$i] = round(-$ydata[$i]);
}
// Basic graph setup
$graph = new Graph\Graph(400, 300);
$graph->SetScale("linlin");
$graph->img->SetMargin(50, 50, 60, 40);
$graph->SetMarginColor('darkblue');
$graph->SetColor('darkblue');
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->title->Set("Depth curve. Dive #2");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetColor("white");
$graph->subtitle->Set("(Negated Y-axis)");
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
$graph->subtitle->SetColor("white");
// Setup axis
$graph->yaxis->SetLabelFormatCallback("_cb_negate");
$graph->xaxis->SetColor("lightblue", "white");
$graph->yaxis->SetColor("lightblue", "white");
$graph->ygrid->SetColor("blue");
$lp1 = new Plot\LinePlot($ydata);
$lp1->SetColor("yellow");
$lp1->SetWeight(2);
$graph->Add($lp1);
$graph->Stroke();
Ejemplo n.º 12
0
require_once '../jpgraph.php';
require_once '../jpgraph_line.php';
$datay = array(0, 3, 5, 12, 15, 18, 22, 36, 37, 41);
// Setup the graph
$graph = new Graph\Graph(320, 200);
$graph->title->Set('Education growth');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph->SetScale('intlin');
$graph->SetMarginColor('white');
$graph->SetBox();
//$graph->img->SetAntialiasing();
$graph->SetGridDepth(DEPTH_FRONT);
$graph->ygrid->SetColor('gray@0.7');
$graph->SetBackgroundImage('classroom.jpg', BGIMG_FILLPLOT);
// Masking graph
$p1 = new Plot\LinePlot($datay);
$p1->SetFillColor('white');
$p1->SetFillFromYMax();
$p1->SetWeight(0);
$graph->Add($p1);
// Line plot
$p2 = new Plot\LinePlot($datay);
$p2->SetColor('black@0.4');
$p2->SetWeight(3);
$p2->mark->SetType(MARK_SQUARE);
$p2->mark->SetColor('orange@0.5');
$p2->mark->SetFillColor('orange@0.3');
$graph->Add($p2);
// Output line
$graph->Stroke();
Ejemplo n.º 13
0
$graph->title->Set('Example of Function plot');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetColor('lightgreen');
$graph->subtitle->Set("(With some more advanced axis formatting\nHiding first and last label)");
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
$graph->subtitle->SetColor('lightgreen');
$graph->xgrid->Show();
$graph->xgrid->SetColor('darkgreen');
$graph->ygrid->SetColor('darkgreen');
$graph->yaxis->SetPos(0);
$graph->yaxis->SetWeight(2);
$graph->yaxis->HideZeroLabel();
$graph->yaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('green', 'green');
$graph->yaxis->HideTicks(true, true);
$graph->yaxis->HideFirstLastLabel();
$graph->xaxis->SetWeight(2);
$graph->xaxis->HideZeroLabel();
$graph->xaxis->HideFirstLastLabel();
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetColor('green', 'green');
$lp1 = new Plot\LinePlot($ydata, $xdata);
$lp1->SetColor('yellow');
$lp1->SetWeight(2);
$lp2 = new Plot\LinePlot($y2data, $x2data);
list($xm, $ym) = $lp2->Max();
$lp2->SetColor('blue');
$lp2->SetWeight(2);
$graph->Add($lp1);
$graph->Add($lp2);
$graph->Stroke();
Ejemplo n.º 14
0
$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();
Ejemplo n.º 15
0
$graph->tabtitle->SetWidth(TABTITLE_WIDTHFULL);
// Enable X and Y Grid
$graph->xgrid->Show();
$graph->xgrid->SetColor('gray@0.5');
$graph->ygrid->SetColor('gray@0.5');
// Format the legend box
$graph->legend->SetColor('navy');
$graph->legend->SetFillColor('lightgreen');
$graph->legend->SetLineWeight(1);
$graph->legend->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->legend->SetShadow('gray@0.4', 3);
$graph->legend->SetAbsPos(15, 120, 'right', 'bottom');
// Create the line plots
$p1 = new Plot\LinePlot($datay1);
$p1->SetColor("red");
$p1->SetFillColor("yellow@0.5");
$p1->SetWeight(2);
$p1->mark->SetType(MARK_IMG_DIAMOND, 5, 0.6);
$p1->SetLegend('2006');
$graph->Add($p1);
$p2 = new Plot\LinePlot($datay2);
$p2->SetColor("darkgreen");
$p2->SetWeight(2);
$p2->SetLegend('2001');
$p2->mark->SetType(MARK_IMG_MBALL, 'red');
$graph->Add($p2);
// Add a vertical line at the end scale position '7'
$l1 = new PlotLine(VERTICAL, 7);
$graph->Add($l1);
// Output the graph
$graph->Stroke();
Ejemplo n.º 16
0
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_iconplot.php';
//$datay = array(20,15,23,15,17,35,22);
$datay = array(30, 25, 33, 25, 27, 45, 32);
$datay2 = array(3, 25, 10, 15, 50, 5, 18);
$datay3 = array(10, 5, 10, 15, 5, 2, 1);
// Setup the graph
$graph = new Graph\Graph(400, 250);
$graph->SetMargin(40, 40, 20, 30);
$graph->SetScale("textlin");
$graph->title->Set('Adding an icon ("tux") in the background');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
//$graph->SetBackgroundGradient('red','blue');
$graph->xaxis->SetPos('min');
$p1 = new Plot\LinePlot($datay);
$p1->SetColor("blue");
$p1->SetFillGradient('yellow@0.4', 'red@0.4');
$p2 = new Plot\LinePlot($datay2);
$p2->SetColor("black");
$p2->SetFillGradient('green@0.4', 'white');
$p3 = new Plot\LinePlot($datay3);
$p3->SetColor("blue");
$p3->SetFillGradient('navy@0.4', 'white@0.4');
$graph->Add($p1);
$graph->Add($p2);
$graph->Add($p3);
$icon = new IconPlot('penguin.png', 0.2, 0.3, 1, 30);
$icon->SetAnchor('center', 'center');
$graph->Add($icon);
// Output line
$graph->Stroke();
Ejemplo n.º 17
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_NORMAL, 12);
//
// 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, 10);
$graph->yaxis->SetFont(FF_TIMES, FS_NORMAL, 10);
// Add a X-grid
$graph->xgrid->Show();
// Create the plot line
$p1 = new Plot\LinePlot($datay, $datax);
$p1->SetColor('teal');
$graph->Add($p1);
// Output graph
$graph->Stroke();
Ejemplo n.º 18
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_bar.php';
$l1datay = array(11, 9, 2, 4, 3, 13, 17);
$l2datay = array(23, 12, 5, 19, 17, 10, 15);
$datax = $gDateLocale->GetShortMonth();
// Create the graph.
$graph = new Graph\Graph(400, 200);
$graph->SetScale("textlin");
$graph->SetMargin(40, 130, 20, 40);
$graph->SetShadow();
$graph->xaxis->SetTickLabels($datax);
// Create the linear error plot
$l1plot = new Plot\LinePlot($l1datay);
$l1plot->SetColor("red");
$l1plot->SetWeight(2);
$l1plot->SetLegend("Prediction");
//Center the line plot in the center of the bars
$l1plot->SetBarCenter();
// Create the bar plot
$bplot = new Plot\BarPlot($l2datay);
$bplot->SetFillColor("orange");
$bplot->SetLegend("Result");
// Add the plots to t'he graph
$graph->Add($bplot);
$graph->Add($l1plot);
$graph->title->Set("Adding a line plot to a bar graph v1");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
Ejemplo n.º 19
0
$graph3->SetFrame(true, 'white', 0);
$graph3->SetBox();
$graph3->title->Set('Temperature');
$graph3->title->SetColor('black');
$graph3->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph3->title->SetMargin(5);
$graph3->xaxis->HideLabels();
$graph3->xgrid->Show();
$graph3->yaxis->SetLabelAngle(90);
$graph3->yaxis->SetColor('black');
$graph3->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph3->yaxis->SetLabelMargin(0);
$graph3->yaxis->scale->SetAutoMin(-10);
$line3 = new Plot\LinePlot($data_windtemp, $xdata);
$line3->SetStepStyle();
$line3->SetColor('black');
$graph3->Add($line3);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(2, 2, 2, 2);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetFillColor(BKG_COLOR);
$mgraph->Add($graph, 0, 50);
$mgraph->Add($graph2, 250, 50);
$mgraph->Add($graph3, 460, 50);
$mgraph->title->Set('Climate diagram 12 March 2009');
$mgraph->title->SetFont(FF_ARIAL, FS_BOLD, 20);
$mgraph->title->SetMargin(8);
$mgraph->Stroke();
Ejemplo n.º 20
0
// Setup the graph
$graph = new Graph\Graph(300, 200);
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(30, 50, 30, 30);
$graph->tabtitle->Set(' Year 2003 ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 13);
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Create the first line
$p1 = new Plot\LinePlot($datay1);
$p1->SetColor("navy");
$p1->SetLegend('Line 1');
$graph->Add($p1);
// Create the second line
$p2 = new Plot\LinePlot($datay2);
$p2->SetColor("red");
$p2->SetLegend('Line 2');
$graph->Add($p2);
// Create the third line
$p3 = new Plot\LinePlot($datay3);
$p3->SetColor("orange");
$p3->SetLegend('Line 3');
$graph->Add($p3);
$graph->legend->SetShadow('gray@0.4', 5);
$graph->legend->SetPos(0.1, 0.1, 'right', 'top');
// Output line
$graph->Stroke();
Ejemplo n.º 21
0
    $datay[$i] = rand(1, 10);
    $datay2[$i] = rand(10, 55);
    $datay3[$i] = rand(200, 600);
    $datay4[$i] = rand(500, 800);
}
// Setup the graph
$graph = new Graph\Graph(450, 250);
$graph->SetMargin(40, 150, 40, 30);
$graph->SetMarginColor('white');
$graph->SetScale('intlin');
$graph->title->Set('Using multiple Y-axis');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
$graph->SetYScale(0, 'lin');
$graph->SetYScale(1, 'lin');
$graph->SetYScale(2, 'lin');
$p1 = new Plot\LinePlot($datay);
$graph->Add($p1);
$p2 = new Plot\LinePlot($datay2);
$p2->SetColor('teal');
$graph->AddY(0, $p2);
$graph->ynaxis[0]->SetColor('teal');
$p3 = new Plot\LinePlot($datay3);
$p3->SetColor('red');
$graph->AddY(1, $p3);
$graph->ynaxis[1]->SetColor('red');
$p4 = new Plot\LinePlot($datay4);
$p4->SetColor('blue');
$graph->AddY(2, $p4);
$graph->ynaxis[2]->SetColor('blue');
// Output line
$graph->Stroke();
Ejemplo n.º 22
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
// create the graph
$graph = new Graph\Graph(400, 250);
$ydata = array(5, 10, 15, 20, 15, 10);
$graph->SetScale("textlin");
$graph->SetShadow(true);
$graph->SetMarginColor("antiquewhite");
$graph->img->SetMargin(60, 40, 40, 50);
$graph->img->setTransparent("white");
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->setTextTickInterval(1);
$graph->xaxis->SetTextLabelInterval(1);
$graph->legend->SetFillColor("antiquewhite");
$graph->legend->SetShadow(true);
$graph->legend->SetLayout(LEGEND_VERT);
$graph->legend->Pos(0.02, 0.01);
$graph->title->Set("Step Styled Example");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor("black");
$lineplot->setFillColor("gray7");
$lineplot->SetStepStyle();
$lineplot->SetLegend(" 2002 ");
// add plot to the graph
$graph->Add($lineplot);
$graph->ygrid->show(false, false);
// display graph
$graph->Stroke();
Ejemplo n.º 23
0
require_once 'dataset01.inc.php';
$dateUtils = new DateScaleUtils();
// Setup a basic graph
$width = 500;
$height = 300;
$graph = new Graph\Graph($width, $height);
$graph->SetScale('datlin');
$graph->SetMargin(60, 20, 40, 60);
// Setup the titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Development since 1984');
$graph->subtitle->SetFont(FF_ARIAL, FS_ITALIC, 10);
$graph->subtitle->Set('(Example using the builtin date scale)');
// Setup the labels to be correctly format on the X-axis
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->xaxis->SetLabelAngle(30);
// The second paramter set to 'true' will make the library interpret the
// format string as a date format. We use a Month + Year format
// $graph->xaxis->SetLabelFormatString('M, Y',true);
// First add an area plot
$lp1 = new Plot\LinePlot($ydata, $xdata);
$lp1->SetWeight(0);
$lp1->SetFillColor('orange@0.85');
$graph->Add($lp1);
// And then add line. We use two plots in order to get a
// more distinct border on the graph
$lp2 = new Plot\LinePlot($ydata, $xdata);
$lp2->SetColor('orange');
$graph->Add($lp2);
// And send back to the client
$graph->Stroke();
Ejemplo n.º 24
0
// 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
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->xaxis->SetLabelMargin(8);
$graph->yaxis->SetTickSide(SIDE_LEFT);
// Setup a filled y-grid
//$graph->ygrid->SetFill(true,'darkgray:1.55@0.7','darkgray:1.6@0.7');
$graph->ygrid->SetStyle('dotted');
$graph->xgrid->SetStyle('dashed');
// Create the plot line
$p1 = new Plot\LinePlot($datay, $datax);
$p1->SetWeight(2);
$p1->SetColor('orange:0.9');
$p1->SetFillColor('white@0.7');
$p1->SetFillFromYMin();
$graph->Add($p1);
// Output graph
$graph->Stroke();
Ejemplo n.º 25
0
$graph = new Graph\Graph(300, 200);
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(30, 5, 25, 20);
// Setup the tab
$graph->tabtitle->Set(' Year 2003 ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 13);
$graph->tabtitle->SetColor('darkred', '#E1E1FF');
// Enable X-grid as well
$graph->xgrid->Show();
// Use months as X-labels
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Create the plot
$p1 = new Plot\LinePlot($datay1);
$p1->SetColor("navy");
// Use an image of favourite car as marker
$p1->mark->SetType(MARK_IMG, 'saab_95.jpg', 0.5);
// Displayes value on top of marker image
$p1->value->SetFormat('%d mil');
$p1->value->Show();
$p1->value->SetColor('darkred');
$p1->value->SetFont(FF_ARIAL, FS_BOLD, 10);
// Increase the margin so that the value is printed avove tje
// img marker
$p1->value->SetMargin(14);
// Incent the X-scale so the first and last point doesn't
// fall on the edges
$p1->SetCenter();
$graph->Add($p1);
$graph->Stroke();
Ejemplo n.º 26
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(300, 250);
$graph->SetScale('intlin', 0, 10);
$graph->SetMargin(30, 20, 70, 40);
$graph->SetMarginColor(array(177, 191, 174));
$graph->SetClipping(false);
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->ygrid->SetLineStyle('dashed');
$graph->title->Set("Manual scale");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph->title->SetColor('white');
$graph->subtitle->Set("(No clipping)");
$graph->subtitle->SetColor('white');
$graph->subtitle->SetFont(FF_ARIAL, FS_BOLD, 10);
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor("red");
$lineplot->SetWeight(2);
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Ejemplo n.º 27
0
// For the new data set we want 40 points to
// get a smooth curve.
list($newx, $newy) = $spline->Get(50);
// Create the graph
$g = new Graph\Graph(300, 200);
$g->SetMargin(30, 20, 40, 30);
$g->title->Set("Natural cubic splines");
$g->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
$g->subtitle->Set('(Control points shown in red)');
$g->subtitle->SetColor('darkred');
$g->SetMarginColor('lightblue');
//$g->img->SetAntiAliasing();
// We need a linlin scale since we provide both
// x and y coordinates for the data points.
$g->SetScale('linlin');
// We want 1 decimal for the X-label
$g->xaxis->SetLabelFormat('%1.1f');
// We use a scatterplot to illustrate the original
// contro points.
$splot = new ScatterPlot($ydata, $xdata);
//
$splot->mark->SetFillColor('red@0.3');
$splot->mark->SetColor('red@0.5');
// And a line plot to stroke the smooth curve we got
// from the original control points
$lplot = new Plot\LinePlot($newy, $newx);
$lplot->SetColor('navy');
// Add the plots to the graph and stroke
$g->Add($lplot);
$g->Add($splot);
$g->Stroke();
Ejemplo n.º 28
0
}
// new Graph\Graph with a background image and drop shadow
$graph = new Graph\Graph(450, 300);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME);
$graph->SetShadow();
// Use an integer X-scale
$graph->SetScale("intlin");
// Set title and subtitle
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("(\"left\" aligned bars)");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40, 120, 40, 40);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Create a red line plot
$p1 = new Plot\LinePlot($datay, $datax);
$p1->SetColor("red");
$p1->SetLegend("Status one");
$graph->Add($p1);
// Create the bar plot
$b1 = new Plot\BarPlot($databary, $databarx);
$b1->SetLegend("Status two");
$b1->SetAlign("left");
$b1->SetShadow();
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
Ejemplo n.º 29
0
$p1->value->SetFormat('%d mil');
$p1->value->Show();
$p1->value->SetColor('darkred');
$p1->value->SetFont(FF_ARIAL, FS_BOLD, 10);
// Increase the margin so that the value is printed avove tje
// img marker
$p1->value->SetMargin(14);
// Incent the X-scale so the first and last point doesn't
// fall on the edges
$p1->SetCenter();
$graph->Add($p1);
//------------
// 2:nd plot
//------------
$p2 = new Plot\LinePlot($datay[1]);
$p2->SetColor("navy");
// Use a flag
$p2->mark->SetType(MARK_FLAG1, 'united states');
// Displayes value on top of marker image
$p2->value->SetFormat('%d mil');
$p2->value->Show();
$p2->value->SetColor('darkred');
$p2->value->SetFont(FF_ARIAL, FS_BOLD, 10);
// Increase the margin so that the value is printed avove tje
// img marker
$p2->value->SetMargin(14);
// Incent the X-scale so the first and last point doesn't
// fall on the edges
$p2->SetCenter();
$graph->Add($p2);
$graph->Stroke();