Esempio 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_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);
Esempio n. 2
0
include "../jpgraph.php";
include "../jpgraph_bar.php";
include "../jpgraph_table.php";
$datay = array(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'), array(12, 18, 19, 7, 17, 6), array(3, 5, 2, 7, 5, 25), array(6, 1.5, 2.4, 2.1, 6.9, 12.3));
// Some basic defines to specify the shape of the bar+table
$nbrbar = 6;
$cellwidth = 50;
$tableypos = 200;
$tablexpos = 60;
$tablewidth = $nbrbar * $cellwidth;
$rightmargin = 30;
// Overall graph size
$height = 320;
$width = $tablexpos + $tablewidth + $rightmargin;
// Create the basic graph.
$graph = new Graph\Graph($width, $height);
$graph->img->SetMargin($tablexpos, $rightmargin, 30, $height - $tableypos);
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
// Setup titles and fonts
$graph->title->Set('Bar and table');
$graph->title->SetFont(FF_VERDANA, FS_NORMAL, 14);
$graph->yaxis->title->Set("Flow");
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
$graph->yaxis->title->SetMargin(10);
// Create the bars and the accbar plot
$bplot = new Plot\BarPlot($datay[3]);
$bplot->SetFillColor("orange");
$bplot2 = new Plot\BarPlot($datay[2]);
$bplot2->SetFillColor("red");
$bplot3 = new Plot\BarPlot($datay[1]);
Esempio n. 3
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay1 = array(20, 7, 16, 46);
$datay2 = array(6, 20, 10, 22);
// Setup the graph
$graph = new Graph\Graph(350, 230);
$graph->SetScale("textlin");
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->title->Set('Background Image');
$graph->SetBox(false);
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->ygrid->SetFill(false);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME);
$p1 = new Plot\LinePlot($datay1);
$graph->Add($p1);
$p2 = new Plot\LinePlot($datay2);
$graph->Add($p2);
$p1->SetColor("#55bbdd");
$p1->SetLegend('Line 1');
$p1->mark->SetType(MARK_FILLEDCIRCLE, '', 1.0);
$p1->mark->SetColor('#55bbdd');
$p1->mark->SetFillColor('#55bbdd');
$p1->SetCenter();
$p2->SetColor("#aaaaaa");
Esempio n. 4
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();
Esempio n. 5
0
<?php

// content="text/plain; charset=utf-8"
// Example of a stock chart
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_stock.php';
// Data must be in the format : open,close,min,max
$datay = array(34, 42, 27, 45, 55, 25, 14, 59, 15, 40, 12, 47, 62, 38, 25, 65, 38, 49, 32, 64);
// Setup a simple graph
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetMarginColor('lightblue');
$graph->title->Set('Stockchart example');
// Create a new stock plot
$p1 = new StockPlot($datay);
// Width of the bars (in pixels)
$p1->SetWidth(9);
// Uncomment the following line to hide the horizontal end lines
//$p1->HideEndLines();
// Add the plot to the graph and send it back to the browser
$graph->Add($p1);
$graph->Stroke();
Esempio n. 6
0
    // Return array width
    // width,color,fill color, marker filename, imgscale
    // any value can be false, in that case the default value will
    // be used.
    // We only make one pushpin another color
    if ($x == 54) {
        return array(false, false, false, 'red', 0.8);
    } else {
        return array(false, false, false, 'green', 0.8);
    }
}
// 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');
Esempio n. 7
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);
$y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251);
$graph = new Graph\Graph(350, 300);
$graph->SetAngle(40);
$graph->img->SetMargin(80, 80, 80, 80);
$graph->SetScale("textlin");
$graph->SetY2Scale("lin");
$graph->SetShadow();
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot2 = new Plot\LinePlot($y2data);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->y2axis->SetColor("orange");
$graph->title->Set("Example 1 rotated graph (40 degree)");
$graph->legend->Pos(0.05, 0.1, "right", "top");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
Esempio n. 8
0
<?php

// content="text/plain; charset=utf-8"
// Illustration of the different patterns for bands
// $Id: smallstaticbandsex7.php,v 1.1 2002/09/01 21:51:08 aditus Exp $
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(10, 29, 3, 6);
// Create the graph.
$graph = new Graph\Graph(200, 150);
$graph->SetScale("textlin");
$graph->SetMargin(25, 10, 20, 20);
// Add 10% grace ("space") at top and botton of Y-scale.
$graph->yscale->SetGrace(10);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetFillColor("lightblue");
// Position the X-axis at the bottom of the plotare
$graph->xaxis->SetPos("min");
$graph->ygrid->Show(false);
// .. and add the plot to the graph
$graph->Add($bplot);
// Add band
$band = new Plot\PlotBand(HORIZONTAL, BAND_HLINE, 15, 35, 'khaki4');
$band->ShowFrame(false);
$graph->Add($band);
// Set title
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->title->SetColor('darkred');
$graph->title->Set('BAND_HLINE');
$graph->Stroke();
Esempio n. 9
0
<?php

// 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);
Esempio n. 10
0
$graph->SetScale('linlin', 0, 0, $xmin, $xmax);
$graph->SetMargin($lm, $rm, 10, 30);
$graph->SetMarginColor('white');
$graph->SetFrame(false);
$graph->SetBox(true);
$graph->title->Set('Example of combined graph');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
$graph->xaxis->SetTickPositions($tickPositions, $minTickPositions);
$graph->xaxis->SetLabelFormatString('My', true);
$graph->xgrid->Show();
$p1 = new Plot\LinePlot($datay, $datax);
$graph->Add($p1);
//----------------------
// Setup the bar graph
//----------------------
$graph2 = new Graph\Graph($w, 110);
$graph2->SetScale('linlin', 0, 0, $xmin, $xmax);
$graph2->SetMargin($lm, $rm, 5, 10);
$graph2->SetMarginColor('white');
$graph2->SetFrame(false);
$graph2->SetBox(true);
$graph2->xgrid->Show();
$graph2->xaxis->SetTickPositions($tickPositions, $minTickPositions);
$graph2->xaxis->SetLabelFormatString('My', true);
$graph2->xaxis->SetPos('max');
$graph2->xaxis->HideLabels();
$graph2->xaxis->SetTickSide(SIDE_DOWN);
$b1 = new Plot\BarPlot($datay2, $datax);
$b1->SetFillColor('teal');
$b1->SetColor('teal:1.2');
$graph2->Add($b1);
Esempio n. 11
0
<?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();
Esempio n. 12
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
require_once 'jpgraph/jpgraph_line.php';
$theme = isset($_GET['theme']) ? $_GET['theme'] : null;
$data = array(0 => array(0 => 79, 1 => -25, 2 => -7, 3 => 85, 4 => -26, 5 => -32), 1 => array(0 => 76, 1 => 51, 2 => 86, 3 => 12, 4 => -7, 5 => 94), 2 => array(0 => 49, 1 => 38, 2 => 7, 3 => -40, 4 => 9, 5 => -7), 3 => array(0 => 69, 1 => 96, 2 => 49, 3 => 7, 4 => 92, 5 => -38), 4 => array(0 => 68, 1 => 16, 2 => 82, 3 => -49, 4 => 50, 5 => 7), 5 => array(0 => -37, 1 => 28, 2 => 32, 3 => 6, 4 => 13, 5 => 57), 6 => array(0 => 24, 1 => -11, 2 => 7, 3 => 10, 4 => 51, 5 => 51), 7 => array(0 => 3, 1 => -1, 2 => -12, 3 => 61, 4 => 10, 5 => 47), 8 => array(0 => -47, 1 => -21, 2 => 43, 3 => 53, 4 => 36, 5 => 34));
// Create the graph. These two calls are always required
$graph = new Graph\Graph(400, 300);
$graph->SetScale("textlin");
if ($theme) {
    $graph->SetTheme(new $theme());
}
$theme_class = new VividTheme();
$graph->SetTheme($theme_class);
$plot = array();
// Create the bar plots
for ($i = 0; $i < 4; $i++) {
    $plot[$i] = new Plot\BarPlot($data[$i]);
    $plot[$i]->SetLegend('plot' . ($i + 1));
}
//$acc1 = new Plot\AccBarPlot(array($plot[0], $plot[1]));
//$acc1->value->Show();
$gbplot = new Plot\GroupBarPlot(array($plot[2], $plot[1]));
for ($i = 4; $i < 8; $i++) {
    $plot[$i] = new Plot\LinePlot($data[$i]);
    $plot[$i]->SetLegend('plot' . $i);
    $plot[$i]->value->Show();
}
$graph->Add($gbplot);
$graph->Add($plot[4]);
Esempio n. 13
0
<?php

// 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");
Esempio n. 14
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();
Esempio n. 15
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay = array(1.23, 1.9, 1.6, 3.1, 3.4, 2.8, 2.1, 1.9);
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 40, 40, 40);
$graph->SetShadow();
$graph->SetGridDepth(DEPTH_FRONT);
$graph->title->Set("Example of filled line plot");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$p1 = new Plot\LinePlot($datay);
$p1->SetFillColor("orange");
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$graph->Add($p1);
$graph->Stroke();
Esempio n. 16
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay1 = array(20, 15, 23, 15);
$datay2 = array(12, 9, 42, 8);
$datay3 = array(5, 17, 32, 24);
// 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
Esempio n. 17
0
$tickLabels[0] = '0';
for ($i = 1; $i / 2 * M_PI < 11; ++$i) {
    $tickPositions[$i] = $i / 2 * M_PI;
    if ($i % 2) {
        $tickLabels[$i] = $i . '/2' . SymChar::Get('pi');
    } else {
        $tickLabels[$i] = $i / 2 . SymChar::Get('pi');
    }
}
$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);
<?php

// 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);
Esempio n. 19
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();
Esempio n. 20
0
<?php

// content="text/plain; charset=utf-8"
require_once '../jpgraph.php';
require_once '../jpgraph_bar.php';
$datay = array(12, 26, 9, 17, 31);
// Create the graph.
$graph = new Graph\Graph(400, 250);
$graph->SetScale('textlin');
$graph->SetMargin(50, 80, 20, 40);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$n = count($datay);
// Number of bars
global $_wrapperfilename;
// Create targets for the image maps. One for each column
$targ = array();
$alt = array();
$wtarg = array();
for ($i = 0; $i < $n; ++$i) {
    $urlarg = 'clickedon=' . ($i + 1);
    $targ[] = $_wrapperfilename . '?' . $urlarg;
    $alt[] = 'val=%d';
    $wtarg[] = '';
}
$bplot->SetCSIMTargets($targ, $alt, $wtarg);
$graph->Add($bplot);
$graph->title->Set('Multiple Image maps');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetCSIMTarget('#45', 'Title for Bar', '_blank');
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
Esempio n. 21
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
require_once 'jpgraph/jpgraph_flags.php';
// Some data
$datay1 = array(140, 110, 50);
$datay2 = array(35, 90, 190);
$datay3 = array(20, 60, 70);
// Create the basic graph
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetMargin(40, 20, 20, 40);
$graph->SetMarginColor('white:0.9');
$graph->SetColor('white');
$graph->SetShadow();
// Apply a perspective transformation at the end
$graph->Set3DPerspective(SKEW3D_DOWN, 100, 180);
// Adjust the position of the legend box
$graph->legend->Pos(0.03, 0.1);
// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.1');
$graph->legend->Hide();
// Get localised version of the month names
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
$graph->SetBackgroundCountryFlag('mais', BGIMG_COPY, 50);
// Set axis titles and fonts
$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
Esempio n. 22
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(12, 8, 19, 3, 10, 5);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(300, 200);
$graph->SetScale('textlin');
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40, 30, 40, 40);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$graph->Add($bplot);
// Create and add a new text
$txt = new Text('This is a text');
$txt->SetPos(10, 20);
$txt->SetColor('darkred');
$txt->SetFont(FF_FONT2, FS_BOLD);
$txt->SetBox('yellow', 'navy', 'gray@0.5');
$graph->AddText($txt);
// Setup the titles
$graph->title->Set("A simple bar graph");
$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);
// Display the graph
Esempio n. 23
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
require_once 'jpgraph/jpgraph_line.php';
$ydata = array(12, 15, 22, 19, 5);
$graph = new Graph\Graph(400, 200);
$graph->img->SetMargin(40, 80, 40, 40);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set('Center the line points in bars');
$line = new Plot\LinePlot($ydata);
$line->SetBarCenter();
$line->SetWeight(2);
$bar = new Plot\BarPlot($ydata);
$bar2 = new Plot\BarPlot($ydata);
$bar2->SetFillColor("red");
$gbar = new Plot\GroupBarPlot(array($bar, $bar2));
$graph->Add($gbar);
$graph->Add($line);
// Output line
$graph->Stroke();
Esempio n. 24
0
<?php

// 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
Esempio n. 25
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_scatter.php';
// Make a circle with a scatterplot
$steps = 16;
for ($i = 0; $i < $steps; ++$i) {
    $a = 2 * M_PI / $steps * $i;
    $datax[$i] = cos($a);
    $datay[$i] = sin($a);
}
$graph = new Graph\Graph(350, 230);
$graph->SetScale('linlin');
$graph->SetShadow();
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->img->SetMargin(50, 50, 60, 40);
$graph->title->Set('Linked scatter plot');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->subtitle->Set('(BOXOUT Axis style)');
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
// 10% top and bottom grace
$graph->yscale->SetGrace(5, 5);
$graph->xscale->SetGrace(1, 1);
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor('red');
$sp1->SetColor('blue');
$sp1->mark->SetWidth(4);
$sp1->link->Show();
$sp1->link->SetStyle('dotted');
Esempio n. 26
0
<?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();
Esempio n. 27
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_bar.php';
// Some data
$steps = 100;
for ($i = 0; $i < $steps; ++$i) {
    $datay[$i] = log(pow($i, $i / 10) + 1) * sin($i / 15) + 35;
    $datax[] = $i;
    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->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");
Esempio n. 28
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();
Esempio n. 29
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(12, 8, 19, 3, 10, 5);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(20);
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40, 30, 20, 40);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
// Adjust fill color
$bplot->SetFillColor('orange');
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10);
$bplot->value->SetAngle(45);
$bplot->value->SetFormat('%0.1f');
$graph->Add($bplot);
// Setup the titles
$graph->title->Set("Bar graph with Y-scale grace");
$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);
// Display the graph
Esempio n. 30
0
<?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();