Ejemplo n.º 1
0
    if ($i % 10 == 0) {
        $databarx[] = $i;
        $databary[] = $datay[$i] / 2;
    }
}
// new Graph\Graph with a background image and drop shadow
$graph = new Graph\Graph(450, 300);
$graph->img->SetMargin(40, 180, 40, 40);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME);
//$graph->img->SetAntiAliasing();
$graph->SetScale("intlin");
$graph->SetShadow();
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("(\"center\" aligned bars)");
// 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, $datax);
$p1->SetWeight(1);
$p1->SetColor("red");
$p1->SetLegend("Triumph Tiger -98");
$graph->Add($p1);
$b1 = new Plot\BarPlot($databary, $databarx);
$b1->SetAbsWidth(10);
$b1->SetAlign("center");
$b1->SetShadow();
$graph->Add($b1);
$graph->Stroke();
Ejemplo n.º 2
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.º 3
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.º 4
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.º 5
0
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);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
Ejemplo n.º 6
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.º 7
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_date.php';
// Create a data set in range (50,70) and X-positions
DEFINE('NDATAPOINTS', 360);
DEFINE('SAMPLERATE', 240);
$start = time();
$end = $start + NDATAPOINTS * SAMPLERATE;
$data = array();
$xdata = array();
for ($i = 0; $i < NDATAPOINTS; ++$i) {
    $data[$i] = rand(50, 70);
    $xdata[$i] = $start + $i * SAMPLERATE;
}
// Create the new Graph\Graph
$graph = new Graph\Graph(540, 300);
// Slightly larger than normal margins at the bottom to have room for
// the x-axis labels
$graph->SetMargin(40, 40, 30, 130);
// Fix the Y-scale to go between [0,100] and use date for the x-axis
$graph->SetScale('datlin', 0, 100);
$graph->title->Set("Example on Date scale");
// Set the angle for the labels to 90 degrees
$graph->xaxis->SetLabelAngle(90);
$line = new Plot\LinePlot($data, $xdata);
$line->SetLegend('Year 2005');
$line->SetFillColor('lightblue@0.5');
$graph->Add($line);
$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
$graph->SetScale("textlin");
// Set title and subtitle
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("100 data points, X-Scale: 'text'");
// 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, 140, 40, 80);
// 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");
// Display every 10:th datalabel
$graph->xaxis->SetTextTickInterval(6);
$graph->xaxis->SetTextLabelInterval(2);
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new Plot\LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new Plot\BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetAbsWidth(6);
$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
Ejemplo n.º 10
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.º 11
0
$m = $gDateLocale->GetShortMonth();
$k = 0;
for ($i = 0; $i < 480; ++$i) {
    $datay[$i] = rand(1, 40);
    if ($i % DATAPERMONTH === 0) {
        $months[$i] = $m[(int) ($i / DATAPERMONTH)];
    } else {
        $months[$i] = 'xx';
    }
}
// new Graph\Graph with a drop shadow
$graph = new Graph\Graph(400, 200);
//$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale('textlin');
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetTextTickInterval(DATAPERMONTH, 0);
$graph->xaxis->SetTextLabelInterval(2);
// Set title and subtitle
$graph->title->Set('Textscale with tickinterval=2');
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->SetBox(true, 'red');
// Create the bar plot
$lp1 = new Plot\LinePlot($datay);
$lp1->SetLegend('Temperature');
// The order the plots are added determines who's ontop
$graph->Add($lp1);
// Finally output the  image
$graph->Stroke();
Ejemplo n.º 12
0
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
// Some data
$ydata = array(5, 10, 15, 20, 15, 10, 8, 7, 4, 10, 5);
// Create the graph
$graph = new Graph\Graph(400, 300);
$graph->SetScale("textlin");
$graph->SetShadow(true);
$graph->SetMarginColor("lightblue");
// Setup format for legend
$graph->legend->SetFillColor("antiquewhite");
$graph->legend->SetShadow(true);
// Setup title
$graph->title->Set("Filled Area Example");
$graph->title->SetFont(FF_FONT2, FS_BOLD);
// Setup semi-filled line plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetLegend("Semi-filled\nLineplot");
// Set line color
$lineplot->SetColor("black");
// Setup the two areas to be filled
$lineplot->AddArea(2, 5, LP_AREA_FILLED, "red");
$lineplot->AddArea(6, 8, LP_AREA_FILLED, "green");
// Display the marks on the lines
$lineplot->mark->SetType(MARK_DIAMOND);
$lineplot->mark->SetSize(8);
$lineplot->mark->Show();
// add plot to the graph
$graph->Add($lineplot);
// display graph
$graph->Stroke();
Ejemplo n.º 13
0
// Set legend box specification
$graph->legend->SetFillColor("white");
$graph->legend->SetLineWeight(2);
// Set X-axis at the minimum value of Y-axis (default will be at 0)
$graph->xaxis->SetPos("min");
// "min" will position the x-axis at the minimum value of the Y-axis
// Extend the margin for the labels on the Y-axis and reverse the direction
// of the ticks on the Y-axis
$graph->yaxis->SetLabelMargin(12);
$graph->xaxis->SetLabelMargin(6);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->xaxis->SetTickSide(SIDE_DOWN);
// Add mark graph with static lines
$line = new PlotLine(HORIZONTAL, 0, "black", 2);
$graph->AddLine($line);
// Create a new impuls type scatter plot
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_SQUARE);
$sp1->mark->SetFillColor("red");
$sp1->mark->SetWidth(3);
$sp1->SetImpuls();
$sp1->SetColor("blue");
$sp1->SetWeight(1);
$sp1->SetLegend("Non-causal signal");
$graph->Add($sp1);
// Create the envelope plot
$ep1 = new Plot\LinePlot($datayenv, $datax);
$ep1->SetStyle("dotted");
$ep1->SetLegend("Positive envelope");
$graph->Add($ep1);
$graph->Stroke();
Ejemplo n.º 14
0
$graph->yaxis->title->Set('Basic Rate');
$graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->yaxis->title->SetColor('black');
$graph->Add($lp1);
// First multi Y-axis plot
$lp2 = new Plot\LinePlot($datay2);
$lp2->SetLegend('2002');
$lp2->mark->SetType(MARK_DIAMOND);
$lp2->mark->SetWidth(15);
$lp2->mark->SetFillColor('darkred');
$lp2->SetCSIMTargets($targ2, $alts2);
$graph->ynaxis[0]->SetColor('darkred');
$graph->ynaxis[0]->title->Set('Rate A');
$graph->ynaxis[0]->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->ynaxis[0]->title->SetColor('darkred');
$graph->AddY(0, $lp2);
// Second multi Y-axis plot
$lp3 = new Plot\LinePlot($datay3);
$lp3->SetLegend('2003');
$lp3->mark->SetType(MARK_DIAMOND);
$lp3->mark->SetWidth(15);
$lp3->mark->SetFillColor('darkgreen');
$lp3->SetCSIMTargets($targ3, $alts3);
$graph->ynaxis[1]->SetColor('darkgreen');
$graph->ynaxis[1]->title->Set('Rate B');
$graph->ynaxis[1]->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->ynaxis[1]->title->SetColor('darkgreen');
$graph->AddY(1, $lp3);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
Ejemplo n.º 15
0
//Setup title
$graph->title->Set("Line plot with null values");
// Use built in font
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
// Slightly adjust the legend from it's default position
$graph->legend->Pos(0.03, 0.5, "right", "center");
$graph->legend->SetFont(FF_FONT1, FS_BOLD);
// Setup X-scale
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->xaxis->SetLabelAngle(45);
// 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("Undefined\nvariant 1");
$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("Undefined\nvariant 2");
$graph->Add($p2);
// Output line
$graph->Stroke();