Initial commit

This commit is contained in:
Alexander Schwarz 2022-11-21 09:47:28 +01:00
commit 76cec83d26
11652 changed files with 1980467 additions and 0 deletions

1
#jpgraph/VERSION Normal file
View File

@ -0,0 +1 @@
Version: v4.0.2

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$data1y=array(-8,8,9,3,5,6);
$data2y=array(18,2,1,7,5,4);
// Create the graph. These two calls are always required
$graph = new Graph(500,400);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b1plot->value->Show();
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
$b2plot->value->Show();
// Create the grouped bar plot
$gbplot = new AccBarPlot(array($b1plot,$b2plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$graph->title->Set("Accumulated bar plots");
$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
$graph->Stroke();
?>

View File

@ -0,0 +1,31 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay1=array(13,8,19,7,17,6);
$datay2=array(4,5,2,7,5,25);
// Create the graph.
$graph = new Graph(350,250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);
$bplot->SetColor('darkred');
// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);
$bplot2->SetColor('darkgreen');
// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot,$bplot2));
$graph->Add($accbplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,33 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay1=array(13,8,19,7,17,6);
$datay2=array(4,5,2,7,5,25);
// Create the graph.
$graph = new Graph(350,250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);
$bplot->SetColor('darkred');
// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);
$bplot2->SetColor('darkgreen');
// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot,$bplot2));
$accbplot->SetColor('red');
$accbplot->SetWeight(1);
$graph->Add($accbplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,35 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay1=array(13,8,19,7,17,6);
$datay2=array(4,5,2,7,5,25);
// Create the graph.
$graph = new Graph(350,250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);
$bplot->SetColor('darkred');
$bplot->SetWeight(0);
// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);
$bplot2->SetColor('darkgreen');
$bplot2->SetWeight(0);
// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot,$bplot2));
$accbplot->SetColor('darkgray');
$accbplot->SetWeight(1);
$graph->Add($accbplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,75 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$datay1=array(140,110,50,60);
$datay2=array(35,90,190,190);
$datay3=array(20,60,70,140);
// Create the basic graph
$graph = new Graph(450,250,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40,80,30,40);
// Adjust the position of the legend box
$graph->legend->Pos(0.02,0.15);
// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.3');
// Get localised version of the month names
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Set a nice summer (in Stockholm) image
$graph->SetBackgroundImage('stship.jpg',BGIMG_COPY);
// Set axis titles and fonts
$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('white');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('white');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using alpha blending with a background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('orange@0.4');
$bplot2->SetFillColor('brown@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,18 @@
<?php // content="text/plain; charset=utf-8"
// Antispam example using a random string
require_once "jpgraph/jpgraph_antispam.php";
// Create new anti-spam challenge creator
// Note: Neither '0' (digit) or 'O' (letter) can be used to avoid confusion
$spam = new AntiSpam();
// Create a random 5 char challenge and return the string generated
$chars = $spam->Rand(5);
// Stroke random cahllenge
if( $spam->Stroke() === false ) {
die('Illegal or no data to plot');
}
?>

View File

@ -0,0 +1,58 @@
<?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(400,300);
$graph->SetScale("textlin");
if ($theme) {
$graph->SetTheme(new $theme());
}
$theme_class = new AquaTheme;
$graph->SetTheme($theme_class);
$plot = array();
// Create the bar plots
for ($i = 0; $i < 4; $i++) {
$plot[$i] = new BarPlot($data[$i]);
$plot[$i]->SetLegend('plot'.($i+1));
}
//$acc1 = new AccBarPlot(array($plot[0], $plot[1]));
//$acc1->value->Show();
$gbplot = new GroupBarPlot(array($plot[2], $plot[1] ));
for ($i = 4; $i < 8; $i++) {
$plot[$i] = new LinePlot($data[$i]);
$plot[$i]->SetLegend('plot'.$i);
$plot[$i]->value->Show();
}
$graph->Add($gbplot);
$graph->Add($plot[4]);
$title = "AquaTheme Example";
$title = mb_convert_encoding($title,'UTF-8');
$graph->title->Set($title);
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Display the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,35 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_NONE"');
$graph->SetAxisLabelBackground(LABELBKG_NONE,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_XAXIS"');
$graph->SetAxisLabelBackground(LABELBKG_XAXIS,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_YAXIS"');
$graph->SetAxisLabelBackground(LABELBKG_YAXIS,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_YAXISFULL"');
$graph->SetAxisLabelBackground(LABELBKG_YAXISFULL,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_XAXISFULL"');
$graph->SetAxisLabelBackground(LABELBKG_XAXISFULL,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_XYFULL"');
$graph->SetAxisLabelBackground(LABELBKG_XYFULL,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$ydata = array(12,19,3,9,15,10);
// The code to setup a very basic graph
$graph = new Graph(200,150);
$graph->SetScale('intlin');
$graph->SetMargin(30,15,40,30);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'blue',3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_XY"');
$graph->SetAxisLabelBackground(LABELBKG_XY,'orange','red','lightblue','red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>

View File

@ -0,0 +1,38 @@
<?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(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_COPY"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg',BGIMG_COPY);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,38 @@
<?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(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_CENTER"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg',BGIMG_CENTER);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,38 @@
<?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(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_FREE"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg',BGIMG_FREE);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,38 @@
<?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(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_FILLPLOT"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg',BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,38 @@
<?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(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 LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,51 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
// Some data
$datay = array(28,19,18,23,12,11);
$data2y = array(14,18,33,29,39,55);
// A nice graph with anti-aliasing
$graph = new Graph(400,200);
$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 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 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();
?>

View File

@ -0,0 +1,51 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
// Some data
$datay = array(28,19,18,23,12,11);
$data2y = array(14,18,33,29,39,55);
// A nice graph with anti-aliasing
$graph = new Graph(400,200);
$graph->img->SetMargin(40,180,40,40);
$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME);
$graph->img->SetAntiAliasing();
$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 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 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();
?>

View File

@ -0,0 +1,51 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
// Some data
$datay = array(28,19,18,23,12,11);
$data2y = array(14,18,33,29,39,55);
// A nice graph with anti-aliasing
$graph = new Graph(400,200);
$graph->img->SetMargin(40,180,40,40);
$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_COPY);
$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 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 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();
?>

View File

@ -0,0 +1,56 @@
<?php // content="text/plain; charset=utf-8"
// $Id: balloonex1.php,v 1.5 2002/12/15 16:08:51 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_scatter.php');
// Some data
$datax = array(1,2,3,4,5,6,7,8);
$datay = array(12,23,95,18,65,28,86,44);
// Callback for markers
// Must return array(width,color,fill_color)
// If any of the returned values are "" then the
// default value for that parameter will be used.
function FCallback($aVal) {
// This callback will adjust the fill color and size of
// the datapoint according to the data value according to
if( $aVal < 30 ) $c = "blue";
elseif( $aVal < 70 ) $c = "green";
else $c="red";
return array(floor($aVal/3),"",$c);
}
// Setup a basic graph
$graph = new Graph(400,300,'auto');
$graph->SetScale("linlin");
$graph->img->SetMargin(40,100,40,40);
$graph->SetShadow();
$graph->title->Set("Example of ballon scatter plot");
// Use a lot of grace to get large scales
$graph->yaxis->scale->SetGrace(50,10);
// Make sure X-axis as at the bottom of the graph
$graph->xaxis->SetPos('min');
// Create the scatter plot
$sp1 = new ScatterPlot($datay,$datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
// Uncomment the following two lines to display the values
$sp1->value->Show();
$sp1->value->SetFont(FF_FONT1,FS_BOLD);
// Specify the callback
$sp1->mark->SetCallback("FCallback");
// Setup the legend for plot
$sp1->SetLegend('Year 2002');
// Add the scatter plot to the graph
$graph->Add($sp1);
// ... and send to browser
$graph->Stroke();
?>

View File

@ -0,0 +1,81 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_scatter.php');
// Each ballon is specificed by four values.
// (X,Y,Size,Color)
$data = array(
array(1,12,10,'orange'),
array(3,41,15,'red'),
array(4,5,19,'lightblue'),
array(5,70,22,'yellow')
);
// We need to create X,Y data vectors suitable for the
// library from the above raw data.
$n = count($data);
for( $i=0; $i < $n; ++$i ) {
$datax[$i] = $data[$i][0];
$datay[$i] = $data[$i][1];
// Create a faster lookup array so we don't have to search
// for the correct values in the callback function
$format[strval($datax[$i])][strval($datay[$i])] = array($data[$i][2],$data[$i][3]);
}
// Callback for markers
// Must return array(width,border_color,fill_color,filename,imgscale)
// If any of the returned values are '' then the
// default value for that parameter will be used (possible empty)
function FCallback($aYVal,$aXVal) {
global $format;
return array($format[strval($aXVal)][strval($aYVal)][0],'',
$format[strval($aXVal)][strval($aYVal)][1],'','');
}
// Setup a basic graph
$graph = new Graph(450,300,'auto');
$graph->SetScale("intlin");
$graph->SetMargin(40,40,40,40);
$graph->SetMarginColor('wheat');
$graph->title->Set("Example of ballon scatter plot with X,Y callback");
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->title->SetMargin(10);
// Use a lot of grace to get large scales since the ballon have
// size and we don't want them to collide with the X-axis
$graph->yaxis->scale->SetGrace(50,10);
$graph->xaxis->scale->SetGrace(50,10);
// Make sure X-axis as at the bottom of the graph and not at the default Y=0
$graph->xaxis->SetPos('min');
// Set X-scale to start at 0
$graph->xscale->SetAutoMin(0);
// Create the scatter plot
$sp1 = new ScatterPlot($datay,$datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
// Uncomment the following two lines to display the values
$sp1->value->Show();
$sp1->value->SetFont(FF_FONT1,FS_BOLD);
// Specify the callback
$sp1->mark->SetCallbackYX("FCallback");
// Add the scatter plot to the graph
$graph->Add($sp1);
// ... and send to browser
$graph->Stroke();
?>

View File

@ -0,0 +1,48 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay=array(20,30,50,80);
$datay2=array(430,645,223,690);
$datazero=array(0,0,0,0);
// Create the graph.
$graph = new Graph(450,200);
$graph->title->Set('Example with 2 scale bars');
// Setup Y and Y2 scales with some "grace"
$graph->SetScale("textlin");
$graph->SetY2Scale("lin");
$graph->yaxis->scale->SetGrace(30);
$graph->y2axis->scale->SetGrace(30);
//$graph->ygrid->Show(true,true);
$graph->ygrid->SetColor('gray','lightgray@0.5');
// Setup graph colors
$graph->SetMarginColor('white');
$graph->y2axis->SetColor('darkred');
// Create the "dummy" 0 bplot
$bplotzero = new BarPlot($datazero);
// Create the "Y" axis group
$ybplot1 = new BarPlot($datay);
$ybplot1->value->Show();
$ybplot = new GroupBarPlot(array($ybplot1,$bplotzero));
// Create the "Y2" axis group
$ybplot2 = new BarPlot($datay2);
$ybplot2->value->Show();
$ybplot2->value->SetColor('darkred');
$ybplot2->SetFillColor('darkred');
$y2bplot = new GroupBarPlot(array($bplotzero,$ybplot2));
// Add the grouped bar plots to the graph
$graph->Add($ybplot);
$graph->AddY2($y2bplot);
// .. and finally stroke the image back to browser
$graph->Stroke();
?>

View File

@ -0,0 +1,52 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay=array(12,26,9,17,31);
// Create the graph.
// One minute timeout for the cached image
// INLINE_NO means don't stream it back to the browser.
$graph = new Graph(310,250,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(60,30,20,40);
$graph->yaxis->SetTitleMargin(45);
$graph->yaxis->scale->SetGrace(30);
$graph->SetShadow();
// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
// Create a bar pot
$bplot = new BarPlot($datay);
// Create targets for the image maps. One for each column
$targ=array("bar_clsmex1.php#1","bar_clsmex1.php#2","bar_clsmex1.php#3","bar_clsmex1.php#4","bar_clsmex1.php#5","bar_clsmex1.php#6");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$bplot->SetCSIMTargets($targ,$alts);
$bplot->SetFillColor("orange");
// Use a shadow on the bar graphs (just use the default settings)
$bplot->SetShadow();
$bplot->value->SetFormat(" $ %2.1f",70);
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
$bplot->value->SetColor("blue");
$bplot->value->Show();
$graph->Add($bplot);
$graph->title->Set("Image maps barex1");
$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);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
?>

View File

@ -0,0 +1,51 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$data1y=array(12,8,19,3,10,5);
$data2y=array(8,2,12,7,14,4);
// Create the graph. These two calls are always required
$graph = new Graph(310,200,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40,30,20,40);
$graph->SetShadow();
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$targ=array("bar_clsmex2.php#1","bar_clsmex2.php#2","bar_clsmex2.php#3",
"bar_clsmex2.php#4","bar_clsmex2.php#5","bar_clsmex2.php#6");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$b1plot->SetCSIMTargets($targ,$alts);
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
$targ=array("bar_clsmex2.php#7","bar_clsmex2.php#8","bar_clsmex2.php#9",
"bar_clsmex2.php#10","bar_clsmex2.php#11","bar_clsmex2.php#12");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$b2plot->SetCSIMTargets($targ,$alts);
// Create the grouped bar plot
$abplot = new AccBarPlot(array($b1plot,$b2plot));
$abplot->SetShadow();
$abplot->value->Show();
// ...and add it to the graPH
$graph->Add($abplot);
$graph->title->Set("Image map barex2");
$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);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
?>

View File

@ -0,0 +1,88 @@
<?php // content="text/plain; charset=utf-8"
// $Id: bar_csimex3.php,v 1.3 2002/08/31 20:03:46 aditus Exp $
// Horiontal bar graph with image maps
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$data1y=array(5,8,19,3,10,5);
$data2y=array(12,2,12,7,14,4);
// Setup the basic parameters for the graph
$graph = new Graph(400,700);
$graph->SetAngle(90);
$graph->SetScale("textlin");
// The negative margins are necessary since we
// have rotated the image 90 degress and shifted the
// meaning of width, and height. This means that the
// left and right margins now becomes top and bottom
// calculated with the image width and not the height.
$graph->img->SetMargin(-80,-80,210,210);
$graph->SetMarginColor('white');
// Setup title for graph
$graph->title->Set('Horizontal bar graph');
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->subtitle->Set("With image map\nNote: The URL just points back to this image");
// Setup X-axis.
$graph->xaxis->SetTitle("X-title",'center');
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetAngle(90);
$graph->xaxis->SetTitleMargin(30);
$graph->xaxis->SetLabelMargin(15);
$graph->xaxis->SetLabelAlign('right','center');
// Setup Y-axis
// First we want it at the bottom, i.e. the 'max' value of the
// x-axis
$graph->yaxis->SetPos('max');
// Arrange the title
$graph->yaxis->SetTitle("Turnaround (mkr)",'center');
$graph->yaxis->SetTitleSide(SIDE_RIGHT);
$graph->yaxis->title->SetFont(FF_FONT2,FS_BOLD);
$graph->yaxis->title->SetAngle(0);
$graph->yaxis->title->Align('center','top');
$graph->yaxis->SetTitleMargin(30);
// Arrange the labels
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
$graph->yaxis->SetLabelAlign('center','top');
// Create the bar plots with image maps
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$targ=array("bar_clsmex2.php#1","bar_clsmex2.php#2","bar_clsmex2.php#3",
"bar_clsmex2.php#4","bar_clsmex2.php#5","bar_clsmex2.php#6");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$b1plot->SetCSIMTargets($targ,$alts);
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
$targ=array("bar_clsmex2.php#7","bar_clsmex2.php#8","bar_clsmex2.php#9",
"bar_clsmex2.php#10","bar_clsmex2.php#11","bar_clsmex2.php#12");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$b2plot->SetCSIMTargets($targ,$alts);
// Create the accumulated bar plot
$abplot = new AccBarPlot(array($b1plot,$b2plot));
$abplot->SetShadow();
// We want to display the value of each bar at the top
$abplot->value->Show();
$abplot->value->SetFont(FF_FONT1,FS_NORMAL);
$abplot->value->SetAlign('left','center');
$abplot->value->SetColor("black","darkred");
$abplot->value->SetFormat('%.1f mkr');
// ...and add it to the graph
$graph->Add($abplot);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
?>

View File

@ -0,0 +1,16 @@
<?php
// ==============================================
// Output Image using Code 39 using only default values
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
try {
$encoder = BarcodeFactory::Create(ENCODING_CODE39);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->Stroke('abc123');
} catch( JpGraphException $e ) {
//echo 'Error: ' . $e->getMessage()."\n";
JpGraphError::Raise($e->getMessage());
}
?>

View File

@ -0,0 +1,11 @@
<?php
// ==============================================
// Output Image using Code 39 using only default values
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODE39);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->Stroke('ABC123');
?>

View File

@ -0,0 +1,14 @@
<?php
// ==============================================
// Output Image using Code 128
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODE128);
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetModuleWidth(2);
$e->SetHeight(20);
echo nl2br($e->Stroke('3125134772'));
?>

View File

@ -0,0 +1,14 @@
<?php
// ==============================================
// Output Postscript of nterleaved 2 of 5
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODEI25);
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetModuleWidth(2);
$e->SetHeight(70);
$ps = $e->Stroke('3125134772');
echo nl2br(htmlspecialchars($ps));
?>

View File

@ -0,0 +1,17 @@
<?php
// ==============================================
// Output Encapsulated Postscript of interleaved 2 of 5
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
echo "Start ...<br>";
$encoder = BarcodeFactory::Create(ENCODING_CODEI25);
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetModuleWidth(2);
$e->SetHeight(70);
$e->SetEPS();
$ps = $e->Stroke('3125134772');
echo nl2br(htmlspecialchars($ps));
?>

View File

@ -0,0 +1,12 @@
<?php
// ==============================================
// Output Image using Code Interleaved 2 of 5
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODEI25);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->SetModuleWidth(2);
$e->Stroke('1234');
?>

View File

@ -0,0 +1,74 @@
<?php
// =======================================================
// Example of how to format US Postal shipping information
// =======================================================
require_once ('jpgraph/jpgraph_barcode.php');
// The Full barcode standard is described in
// http://www.usps.com/cpim/ftp/pubs/pub91/91c4.html#508hdr1
//
// The data start with AI=420 which means
// "Ship to/Deliver To Postal Code (within single authority)
//
class USPS_Confirmation {
function USPS_Confirmation() {
}
// Private utility function
function _USPS_chkd($aData) {
$n = strlen($aData);
// Add all even numbers starting from position 1 from the end
$et = 0 ;
for( $i=1; $i <= $n; $i+=2 ) {
$d = intval(substr($aData,-$i,1));
$et += $d;
}
// Add all odd numbers starting from position 2 from the end
$ot = 0 ;
for( $i=2; $i <= $n; $i+=2 ) {
$d = intval(substr($aData,-$i,1));
$ot += $d;
}
$tot = 3*$et + $ot;
$chkdigit = (10 - ($tot % 10))%10;;
return $chkdigit;
}
// Get type 1 of confirmation code (with ZIP)
function GetPICwithZIP($aZIP,$aServiceType,$aDUNS,$aSeqNbr) {
// Convert to USPS format with AI=420 and extension starting with AI=91
$data = '420'. $aZIP . '91' . $aServiceType . $aDUNS . $aSeqNbr;
// Only calculate the checkdigit from the AI=91 and forward
// and do not include the ~1 (FUNC1) in the calculation
$cd = $this->_USPS_chkd(substr($data,8));
$data = '420'. $aZIP . '~191' . $aServiceType . $aDUNS . $aSeqNbr;
return $data . $cd;
}
// Get type 2 of confirmation code (without ZIP)
function GetPIC($aServiceType,$aDUNS,$aSeqNbr) {
// Convert to USPS format with AI=91
$data = '91' . $aServiceType . $aDUNS . $aSeqNbr;
$cd = $this->_USPS_chkd($data);
return $data . $cd;
}
}
$usps = new USPS_Confirmation();
$zip = '92663';
$service = '21';
$DUNS = '805213907';
$seqnr = '04508735';
$data = $usps->GetPICwithZIP($zip,$service,$DUNS,$seqnr);
//$data = $usps->GetPIC('01','123456789','00000001');
$encoder = BarcodeFactory::Create(ENCODING_EAN128);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->SetModuleWidth(2);
$e->SetFont(FF_ARIAL,FS_NORMAL,14);
$e->Stroke($data);
?>

View File

@ -0,0 +1,10 @@
<?php // content="text/plain; charset=utf-8"
if( empty($_GET['id']) ) {
echo 'Incorrect argument(s) to script <b>'.basename(__FILE__).'</b>.';
}
else {
echo 'Some details on bar with id='.$_GET['id'];
}
?>

View File

@ -0,0 +1,41 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some random data to plot
$datay=array(12,26,9,17,31);
// Create the graph.
$graph = new Graph(400,250);
$graph->SetScale("textlin");
// Create a bar pot
$bplot = new BarPlot($datay);
// Create targets for the image maps so that the details are opened in a separate window
$fmtStr = "javascript:window.open('barcsim_details.php?id=%d','_new','width=500,height=300');void(0)";
$n = count($datay);
$targ=array();
$alts=array();
for($i=0; $i < $n; ++$i) {
$targ[$i] = sprintf($fmtStr,$i+1);
$alts[$i] = 'val=%d';
// Note: The format placeholder val=%d will be replaced by the actual value in the ouput HTML by the
// library so that when the user hoovers the mouse over the bar the actual numerical value of the bar
// will be dísplayed
}
$bplot->SetCSIMTargets($targ,$alts);
// Add plot to graph
$graph->Add($bplot);
// Setup the title, also wih a CSIM area
$graph->title->Set("CSIM with popup windows");
$graph->title->SetFont(FF_FONT2,FS_BOLD);
// Assume we can give more details on the graph
$graph->title->SetCSIMTarget(sprintf($fmtStr,-1),'Title for Bar');
// Send back the HTML page which will call this script again to retrieve the image.
$graph->StrokeCSIM();
?>

View File

@ -0,0 +1,30 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$data = array(0.1235,0.4567,0.67,0.45,0.832);
// Callback function
// Get called with the actual value and should return the
// value to be displayed as a string
function cbFmtPercentage($aVal) {
return sprintf("%.1f%%",100*$aVal); // Convert to string
}
// Create the graph.
$graph = new Graph(400,300);
$graph->SetScale("textlin");
// Create a bar plots
$bar1 = new BarPlot($data);
// Setup the callback function
$bar1->value->SetFormatCallback("cbFmtPercentage");
$bar1->value->Show();
// Add the plot to the graph
$graph->Add($bar1);
// .. and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,47 @@
<?php // content="text/plain; charset=utf-8"
// Example for use of JpGraph,
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(0.13,0.25,0.21,0.35,0.31,0.06);
$datax=array("January","February","March","April","May","June");
// Setup the graph.
$graph = new Graph(400,240);
$graph->img->SetMargin(60,20,35,75);
$graph->SetScale("textlin");
$graph->SetMarginColor("lightblue:1.1");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Bar gradient with left reflection");
$graph->title->SetMargin(8);
$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy:0.9","navy:1.85",GRAD_LEFT_REFLECTION);
// Set color for the frame of each bar
$bplot->SetColor("white");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,48 @@
<?php // content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 20:32
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(-0.13,0.25,-0.21,0.35,0.31,0.04);
$datax=array("Jan","Feb","Mar","Apr","May","June");
// Setup the graph.
$graph = new Graph(400,200);
$graph->img->SetMargin(60,20,30,50);
$graph->SetScale("textlin");
$graph->SetMarginColor("silver");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Example negative bars");
$graph->title->SetFont(FF_VERDANA,FS_NORMAL,18);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,12);
$graph->xaxis->SetColor("black","red");
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,11);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","steelblue",GRAD_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,50 @@
<?php // content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 20:32
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(-0.13,0.25,-0.21,0.35,0.31,0.04);
$datax=array("Jan","Feb","Mar","Apr","May","June");
// Setup the graph.
$graph = new Graph(400,200);
$graph->img->SetMargin(60,20,30,50);
$graph->SetScale("textlin");
$graph->SetMarginColor("silver");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Example negative bars");
$graph->title->SetFont(FF_VERDANA,FS_NORMAL,16);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// 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
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","steelblue",GRAD_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,47 @@
<?php // content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 19:44
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(0.3031,0.3044,0.3049,0.3040,0.3024,0.3047);
// Setup the graph.
$graph = new Graph(400,200);
$graph->img->SetMargin(60,30,30,40);
$graph->SetScale("textlin");
$graph->SetMarginColor("teal");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Bargraph with small variations");
$graph->title->SetColor("white");
$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
// Setup color for axis and labels
$graph->xaxis->SetColor("black","white");
$graph->yaxis->SetColor("black","white");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Setup X-axis title (color & font)
$graph->xaxis->title->Set("X-axis");
$graph->xaxis->title->SetColor("white");
$graph->xaxis->title->SetFont(FF_VERDANA,FS_BOLD,10);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$tcol=array(100,100,255);
$fcol=array(255,100,100);
$bplot->SetFillGradient($fcol,$tcol,GRAD_HOR);
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,52 @@
<?php // content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 19:44
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_line.php');
// We need some data
$datay=array(0.3031,0.3044,0.3049,0.3040,0.3024,0.3047);
// Setup the graph.
$graph = new Graph(400,200);
$graph->img->SetMargin(60,30,30,40);
$graph->SetScale("textlin");
$graph->SetMarginColor("teal");
$graph->SetShadow();
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// This is how you make the bar graph start from something other than 0
$bplot->SetYMin(0.302);
// Setup color for gradient fill style
$tcol=array(100,100,255);
$fcol=array(255,100,100);
$bplot->SetFillGradient($fcol,$tcol,GRAD_HOR);
$bplot->SetFillColor("orange");
$graph->Add($bplot);
// Set up the title for the graph
$graph->title->Set("Bargraph which doesn't start from y=0");
$graph->title->SetColor("yellow");
$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
// Setup color for axis and labels
$graph->xaxis->SetColor("black","white");
$graph->yaxis->SetColor("black","white");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Setup X-axis title (color & font)
$graph->xaxis->title->Set("X-axis");
$graph->xaxis->title->SetColor("white");
$graph->xaxis->title->SetFont(FF_VERDANA,FS_BOLD,10);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,51 @@
<?php // content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 20:32
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(-0.13,0.25,-0.21,0.35,0.31,0.04);
$datax=array("Jan","Feb","Mar","Apr","May","June");
// Setup the graph.
$graph = new Graph(500,200);
$graph->img->SetMargin(60,150,30,50);
$graph->SetScale("textlin");
$graph->SetMarginColor("silver");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Example negative bars");
$graph->title->SetFont(FF_VERDANA,FS_NORMAL,16);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// 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
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
$bplot->SetLegend("Result 1999","blue");
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","steelblue",GRAD_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_MIDVER"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_MIDHOR"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDHOR);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_HOR"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_HOR);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_VER"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_VER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_WIDE_MIDVER"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_WIDE_MIDHOR"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDHOR);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_CENTER"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_CENTER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,34 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// We need some data
$datay=array(4,8,6);
// Setup the graph.
$graph = new Graph(200,150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25,15,25,25);
$graph->title->Set('"GRAD_RAISED_PANEL"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient('navy','orange',GRAD_RAISED_PANEL);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,29 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_line.php');
$datay=array(5,3,11,6,3);
$graph = new Graph(400,300,'auto');
$graph->SetScale("textlin");
$graph->title->Set('Images on top of bars');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,13);
$graph->SetTitleBackground('lightblue:1.1',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL);
$bplot = new BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetWidth(0.5);
$lplot = new LinePlot($datay);
$lplot->SetColor('white@1');
$lplot->SetBarCenter();
$lplot->mark->SetType(MARK_IMG_LBALL,'red');
$graph->Add($bplot);
$graph->Add($lplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,48 @@
<?php // content="text/plain; charset=utf-8"
// $Id: barintex1.php,v 1.3 2002/07/11 23:27:28 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$datay=array(1,1,0.5);
// Create the graph and setup the basic parameters
$graph = new Graph(460,200,'auto');
$graph->img->SetMargin(40,30,30,40);
$graph->SetScale("textint");
$graph->SetShadow();
$graph->SetFrame(false); // No border around the graph
// Add some grace to the top so that the scale doesn't
// end exactly at the max value.
$graph->yaxis->scale->SetGrace(100);
// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_FONT2);
// Setup graph title ands fonts
$graph->title->Set("Example of integer Y-scale");
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->title->Set("Year 2002");
$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetWidth(0.5);
$bplot->SetShadow();
// Setup the values that are displayed on top of each bar
$bplot->value->Show();
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
// Black color for positive values and darkred for negative values
$bplot->value->SetColor("black","darkred");
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,57 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$datay=array(3,7,19,11,4,20);
// Create the graph and setup the basic parameters
$graph = new Graph(350,200,'auto');
$graph->img->SetMargin(40,30,40,40);
$graph->SetScale("textint");
$graph->SetFrame(true,'blue',1);
$graph->SetColor('lightblue');
$graph->SetMarginColor('lightblue');
// Add some grace to the top so that the scale doesn't
// end exactly at the max value.
//$graph->yaxis->scale->SetGrace(20);
// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->SetColor('darkblue','black');
// Stup "hidden" y-axis by given it the same color
// as the background
$graph->yaxis->SetColor('lightblue','darkblue');
$graph->ygrid->SetColor('white');
// Setup graph title ands fonts
$graph->title->Set('Example of integer Y-scale');
$graph->subtitle->Set('(With "hidden" y-axis)');
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->title->Set("Year 2002");
$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkblue');
$bplot->SetColor('darkblue');
$bplot->SetWidth(0.5);
$bplot->SetShadow('darkgray');
// Setup the values that are displayed on top of each bar
$bplot->value->Show();
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,8);
$bplot->value->SetFormat('$%d');
// Black color for positive values and darkred for negative values
$bplot->value->SetColor("black","darkred");
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,42 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_bar.php');
$ydata = array(2,3,4,5,6,7,8,9,10,11);
$ydata2 = array(1,2,3,4,5,6,7,8,9,10);
$targ = array("#1","#2","#3","#4","#5","#6","#7","#8","#9","#10");
$alt = array(1,2,3,4,5,6,7,8,9,10);
// Create the graph.
$graph = new Graph(300,200);
$graph->SetScale("textlin");
$graph->img->SetMargin(40,20,30,40);
$graph->title->Set("CSIM example with bar and line");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Setup axis titles
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetWidth(5);
$lineplot->mark->SetColor('black');
$lineplot->mark->SetFillColor('red');
$lineplot->SetCSIMTargets($targ,$alt);
// Create line plot
$barplot=new barPlot($ydata2);
$barplot->SetCSIMTargets($targ,$alt);
// Add the plots to the graph
$graph->Add($lineplot);
$graph->Add($barplot);
$graph->StrokeCSIM();
?>

View File

@ -0,0 +1,74 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_line.php');
// Some "random" data
$ydata = array(10,120,80,190,260,170,60,40,20,230);
$ydata2 = array(10,70,40,120,200,60,80,40,20,5);
// Get a list of month using the current locale
$months = $gDateLocale->GetShortMonth();
// Create the graph.
$graph = new Graph(300,200);
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
// Adjust the margin slightly so that we use the
// entire area (since we don't use a frame)
$graph->SetMargin(30,1,20,5);
// Box around plotarea
$graph->SetBox();
// No frame around the image
$graph->SetFrame(false);
// Setup the tab title
$graph->tabtitle->Set('Year 2003');
$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10);
// Setup the X and Y grid
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Setup month as labels on the X-axis
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(45);
// Create a bar pot
$bplot = new BarPlot($ydata);
$bplot->SetWidth(0.6);
$fcol='#440000';
$tcol='#FF9090';
$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION);
// Set line weigth to 0 so that there are no border
// around each bar
$bplot->SetWeight(0);
$graph->Add($bplot);
// Create filled line plot
$lplot = new LinePlot($ydata2);
$lplot->SetFillColor('skyblue@0.5');
$lplot->SetColor('navy@0.7');
$lplot->SetBarCenter();
$lplot->mark->SetType(MARK_SQUARE);
$lplot->mark->SetColor('blue@0.5');
$lplot->mark->SetFillColor('lightblue');
$lplot->mark->SetSize(6);
$graph->Add($lplot);
// .. and finally send it back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,100 @@
<?php // content="text/plain; charset=utf-8"
//
// Example of CSIM frequence bar that uses the cache
//
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_line.php');
// Utility function to calculate the accumulated frequence
// for a set of values and ocurrences
function accfreq($data) {
rsort($data);
$s = array_sum($data);
$as = array($data[0]);
$asp = array(100*$as[0]/$s);
$n = count($data);
for( $i=1; $i < $n; ++$i ) {
$as[$i] = $as[$i-1]+$data[$i];
$asp[$i] = 100.0*$as[$i]/$s;
}
return $asp;
}
// some data
$data_freq = array(22,20,12,10,5,4,2);
$data_accfreq = accfreq($data_freq);
// Create the graph.
$graph = new Graph(350,250);
// We need to make this extra call for CSIM scripts
// that make use of the cache. If the cache contains this
// graph the HTML wrapper will be returned and then the
// method will call exit() and hence NO LINES AFTER THIS
// CALL WILL BE EXECUTED.
// $graph->CheckCSIMCache('auto');
// Setup some basic graph parameters
$graph->SetScale("textlin");
$graph->SetY2Scale('lin',0,100);
$graph->img->SetMargin(50,70,30,40);
$graph->yaxis->SetTitleMargin(30);
$graph->SetMarginColor('#EEEEEE');
// Setup titles and fonts
$graph->title->Set("Frequence plot");
$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);
// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black','blue');
$graph->y2axis->SetLabelFormat('%3d.0%%');
// Create a bar pot
$bplot = new BarPlot($data_freq);
// Create targets and alt texts for the image maps. One for each bar
// (In this example this is just "dummy" targets)
$targ=array("#1","#2","#3","#4","#5","#6","#7");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$bplot->SetCSIMTargets($targ,$alts);
// Create accumulative graph
$lplot = new LinePlot($data_accfreq);
// We want the line plot data point in the middle of the bars
$lplot->SetBarCenter();
// Use transperancy
$lplot->SetFillColor('lightblue@0.6');
$lplot->SetColor('blue@0.6');
//$lplot->SetColor('blue');
$graph->AddY2($lplot);
// Setup the bars
$bplot->SetFillColor("orange@0.2");
$bplot->SetValuePos('center');
$bplot->value->SetFormat("%d");
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
$bplot->value->Show();
// Add it to the graph
$graph->Add($bplot);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
?>

View File

@ -0,0 +1,83 @@
<?php // content="text/plain; charset=utf-8"
//
// Example of frequence bar
//
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_line.php');
// Utility function to calculate the accumulated frequence
// for a set of values and ocurrences
function accfreq($data) {
rsort($data);
$s = array_sum($data);
$as = array($data[0]);
$asp = array(100*$as[0]/$s);
$n = count($data);
for( $i=1; $i < $n; ++$i ) {
$as[$i] = $as[$i-1]+$data[$i];
$asp[$i] = 100.0*$as[$i]/$s;
}
return $asp;
}
// some data
$data_freq = array(22,20,12,10,5,4,2);
$data_accfreq = accfreq($data_freq);
// Create the graph.
$graph = new Graph(350,250);
// Setup some basic graph parameters
$graph->SetScale("textlin");
$graph->SetY2Scale('lin',0,100);
$graph->img->SetMargin(50,70,30,40);
$graph->yaxis->SetTitleMargin(30);
$graph->SetMarginColor('#EEEEEE');
// Setup titles and fonts
$graph->title->Set("Frequence plot");
$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);
// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black','blue');
$graph->y2axis->SetLabelFormat('%3d.0%%');
// Create a bar pot
$bplot = new BarPlot($data_freq);
// Create accumulative graph
$lplot = new LinePlot($data_accfreq);
// We want the line plot data point in the middle of the bars
$lplot->SetBarCenter();
// Use transperancy
$lplot->SetFillColor('lightblue@0.6');
$lplot->SetColor('blue@0.6');
$graph->AddY2($lplot);
// Setup the bars
$bplot->SetFillColor("orange@0.2");
$bplot->SetValuePos('center');
$bplot->value->SetFormat("%d");
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
$bplot->value->Show();
// Add it to the graph
$graph->Add($bplot);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->Stroke();
?>

View File

@ -0,0 +1,33 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_line.php');
$datay=array(2,3,5,8.5,11.5,6,3);
// Create the graph.
$graph = new Graph(350,300);
$graph->SetScale("textlin");
$graph->SetMarginColor('navy:1.9');
$graph->SetBox();
$graph->title->Set('Bar Pattern');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,20);
$graph->SetTitleBackground('lightblue:1.3',TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL);
$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'lightblue','blue');
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkorange');
$bplot->SetWidth(0.6);
$bplot->SetPattern(PATTERN_CROSS1,'navy');
$graph->Add($bplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,63 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Callback function for Y-scale to get 1000 separator on labels
function separator1000($aVal) {
return number_format($aVal);
}
function separator1000_usd($aVal) {
return '$'.number_format($aVal);
}
// Some data
$datay=array(120567,134013,192000,87000);
// Create the graph and setup the basic parameters
$graph = new Graph(500,300,'auto');
$graph->img->SetMargin(80,30,30,40);
$graph->SetScale('textint');
$graph->SetShadow();
$graph->SetFrame(false); // No border around the graph
// Add some grace to the top so that the scale doesn't
// end exactly at the max value.
// The grace value is the percetage of additional scale
// value we add. Specifying 50 means that we add 50% of the
// max value
$graph->yaxis->scale->SetGrace(50);
$graph->yaxis->SetLabelFormatCallback('separator1000');
// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_FONT2);
// Setup graph title ands fonts
$graph->title->Set('Example of Y-scale callback formatting');
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('orange');
$bplot->SetWidth(0.5);
$bplot->SetShadow();
// Setup the values that are displayed on top of each bar
$bplot->value->Show();
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
$bplot->value->SetFormatCallback('separator1000_usd');
// Black color for positive values and darkred for negative values
$bplot->value->SetColor('black','darkred');
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
?>

View File

@ -0,0 +1,35 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$databary=array(12,7,16,5,7,14,9,3);
// New graph with a drop shadow
$graph = new Graph(300,200);
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Set title and subtitle
$graph->title->Set("Elementary barplot with a text scale");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
//$b1->SetAbsWidth(6);
//$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,90 @@
<?php // content="text/plain; charset=utf-8"
// A medium complex example of JpGraph
// Note: You can create a graph in far fewwr lines of code if you are
// willing to go with the defaults. This is an illustrative example of
// some of the capabilities of JpGraph.
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_bar.php');
$month=array(
"Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec");
// Create some datapoints
$steps=100;
for($i=0; $i<$steps; ++$i) {
$databarx[]=sprintf("198%d %s",floor($i/12),$month[$i%12]);
$datay[$i]=log(pow($i,$i/10)+1)*sin($i/15)+35;
if( $i % 6 == 0 && $i<$steps-6) {
$databary[]=abs(25*sin($i)+5);
}
else {
$databary[]=0;
}
}
// New graph with a background image and drop shadow
$graph = new Graph(450,300);
$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME);
$graph->SetShadow();
// Use text X-scale so we can text labels on the X-axis
$graph->SetScale("textlin");
// Y2-axis is linear
$graph->SetY2Scale("lin");
// Color the two Y-axis to make them easier to associate
// to the corresponding plot (we keep the axis black though)
$graph->yaxis->SetColor("black","red");
$graph->y2axis->SetColor("black","orange");
// 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 (don't need TTF support)
$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.03,0.5,"right","center");
// Display every 6:th tickmark
$graph->xaxis->SetTextTickInterval(6);
// Label every 2:nd tick mark
$graph->xaxis->SetTextLabelInterval(2);
// Setup the labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetFillColor("orange");
$b1->SetAbsWidth(8);
// Drop shadow on bars adjust the default values a little bit
$b1->SetShadow("steelblue",2,2);
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->AddY2($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$databary=array(12,7,16,6,7,14,9,3);
$months=$gDateLocale->GetShortMonth();
// New graph with a drop shadow
$graph = new Graph(300,200,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
// Set title and subtitle
$graph->title->Set("Textscale with specified labels");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
//$b1->SetAbsWidth(6);
//$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,44 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$months=$gDateLocale->GetShortMonth();
srand ((double) microtime() * 1000000);
for( $i=0; $i<25; ++$i) {
$databary[]=rand(1,50);
$databarx[]=$months[$i%12];
}
// New graph with a drop shadow
$graph = new Graph(300,200,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($databarx);
// Set title and subtitle
$graph->title->Set("Bar tutorial example 3");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
//$b1->SetAbsWidth(6);
//$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,47 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$months=$gDateLocale->GetShortMonth();
srand ((double) microtime() * 1000000);
for( $i=0; $i<25; ++$i) {
$databary[]=rand(1,50);
$databarx[]=$months[$i%12];
}
// New graph with a drop shadow
$graph = new Graph(300,200,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
//$databarx = array('tXi','','','xxx','','','iXii','','','OOO','','','tOO');
$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL);
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetTextLabelInterval(3);
// Set title and subtitle
$graph->title->Set("Displaying only every third label");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
//$b1->SetAbsWidth(6);
//$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,45 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$months=$gDateLocale->GetShortMonth();
srand ((double) microtime() * 1000000);
for( $i=0; $i<25; ++$i) {
$databary[]=rand(1,50);
$databarx[]=$months[$i%12];
}
// New graph with a drop shadow
$graph = new Graph(300,200,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetTextLabelInterval(1);
$graph->xaxis->SetTextTickInterval(3);
// Set title and subtitle
$graph->title->Set("Bar tutorial example 5");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetWidth(0.4);
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,47 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
// Some data
$months=$gDateLocale->GetShortMonth();
srand ((double) microtime() * 1000000);
for( $i=0; $i<25; ++$i) {
$databary[]=rand(1,50);
$databarx[]=$months[$i%12];
}
// New graph with a drop shadow
$graph = new Graph(300,200,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetTextLabelInterval(3);
// Hide the tick marks
$graph->xaxis->HideTicks();
// Set title and subtitle
$graph->title->Set("Bar tutorial example 6");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetWidth(0.4);
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4),
array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2),
array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3),
array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4),
array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,43 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4),
array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2),
array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3),
array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4),
array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array ( 12,7,3,15 ),
array ( 18,5,1, 9 ),
array ( 13,9,5,12),
array ( 5,3,8, 9 ),
array ( 1,8,5, 7 ));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data,10,1);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array ( 12,7,3,15 ),
array ( 18,5,1, 9 ),
array ( 13,9,5,12),
array ( 5,3,8, 9 ),
array ( 1,8,5, 7 ));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data,10,2);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array ( 12,7,3,15 ),
array ( 18,5,1, 9 ),
array ( 13,9,5,12),
array ( 5,3,8, 9 ),
array ( 1,8,5, 7 ));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data,10,3);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,43 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4),
array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2),
array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3),
array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4),
array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data,5);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,46 @@
<?php // content="text/plain; charset=utf-8"
// Basic contour plot example
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_contour.php');
$data = array(
array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4),
array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2),
array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3),
array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4),
array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4),
array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4),
array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2));
// Basic contour graph
$graph = new Graph(350,250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30,100,40,30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new ContourPlot($data);
// Flip the data around its center line
$cp->SetInvert();
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
?>

View File

@ -0,0 +1,54 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_scatter.php');
require_once ('jpgraph/jpgraph_regstat.php');
// Original data points
$xdata = array(1,3,12,15);
$ydata = array(5,15,2,19);
// Get the interpolated values by creating
// a new Spline object.
$bez = new Bezier($xdata,$ydata);
// For the new data set we want 40 points to
// get a smooth curve.
list($newx,$newy) = $bez->Get(50);
// Create the graph
$g = new Graph(300,200);
$g->SetMargin(30,20,40,30);
$g->title->Set("Bezier interpolation");
$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.
$bplot = new ScatterPlot($ydata,$xdata);
$bplot->mark->SetFillColor('red@0.3');
$bplot->mark->SetColor('red@0.5');
// And a line plot to stroke the smooth curve we got
// from the original control points
$lplot = new LinePlot($newy,$newx);
$lplot->SetColor('navy');
// Add the plots to the graph and stroke
$g->Add($lplot);
$g->Add($bplot);
$g->Stroke();
?>

View File

@ -0,0 +1,79 @@
<?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(300,200);
$graph->SetScale('textlin');
$graph->SetMargin(40,20,20,40);
$graph->SetMarginColor('white:0.9');
$graph->SetColor('white');
$graph->SetShadow();
// Adjust the position of the legend box
$graph->legend->Pos(0.03,0.10);
// 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);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('navy');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,83 @@
<?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(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_UP,100,180);
// Adjust the position of the legend box
$graph->legend->Pos(0.03,0.10);
// 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);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('navy');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,83 @@
<?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(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.10);
// 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);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('navy');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,83 @@
<?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(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_LEFT,350,320,true);
// Adjust the position of the legend box
$graph->legend->Pos(0.03,0.10);
// 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);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('navy');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

View File

@ -0,0 +1,83 @@
<?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(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_RIGHT,350,320,true);
// Adjust the position of the legend box
$graph->legend->Pos(0.03,0.10);
// 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);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('navy');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,37 @@
<?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,median
$datay = array(
34,42,27,45,36,
55,25,14,59,40,
15,40,12,47,23,
62,38,25,65,57,
38,49,32,64,45);
// Setup a simple graph
$graph = new Graph(300,200);
$graph->SetScale("textlin");
$graph->SetMarginColor('lightblue');
$graph->title->Set('Box Stock chart example');
// Create a new stock plot
$p1 = new BoxPlot($datay);
// Setup URL target for image map
$p1->SetCSIMTargets(array('#1','#2','#3','#4','#5'));
// Width of the bars (in pixels)
$p1->SetWidth(9);
//$p1->SetCenter();
// 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->StrokeCSIM();
?>

View File

@ -0,0 +1,33 @@
<?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,median
$datay = array(
34,42,27,45,36,
55,25,14,59,40,
15,40,12,47,23,
62,38,25,65,57,
38,49,32,64,45);
// Setup a simple graph
$graph = new Graph(300,200);
$graph->SetScale('textlin');
$graph->SetMarginColor('lightblue');
$graph->title->Set('Box Stock chart example');
// Create a new stock plot
$p1 = new BoxPlot($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();
?>

View File

@ -0,0 +1,38 @@
<?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,median
$datay = array(
34,42,27,45,36,
55,25,14,59,40,
15,40,12,47,23,
62,38,25,65,57,
38,49,32,64,45);
// Setup a simple graph
$graph = new Graph(300,200);
$graph->SetScale("textlin");
$graph->SetMarginColor('lightblue');
$graph->title->Set('Box Stock chart example');
$graph->subtitle->Set('(Indented X-axis)');
// Create a new stock plot
$p1 = new BoxPlot($datay);
// Width of the bars (in pixels)
$p1->SetWidth(9);
// Indent bars so they dont start and end at the edge of the
// plot area
$p1->SetCenter();
// 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();
?>

View File

@ -0,0 +1,66 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_plotline.php');
$datay1 = array(2,6,7,12,13,18);
$datay2 = array(5,12,12,19,25,20);
// Setup the graph
$graph = new Graph(350,200);
$graph->SetMargin(30,20,60,20);
$graph->SetMarginColor('white');
$graph->SetScale("linlin");
// Hide the frame around the graph
$graph->SetFrame(false);
// Setup title
$graph->title->Set("Using Builtin PlotMarks");
$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
// Note: requires jpgraph 1.12p or higher
// $graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_PLOT);
$graph->tabtitle->Set('Region 1' );
$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 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 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();
?>

View File

@ -0,0 +1,143 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvas_jpgarchex.php,v 1.3 2002/08/29 10:14:19 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_canvtools.php');
// Scale we are using
$ymax=24;
$xmax=20;
// Setup the basic canvas
$g = new CanvasGraph(700,650,'auto');
$g->SetMargin(2,3,2,3);
$g->SetMarginColor("teal");
$g->InitFrame();
// ... and a scale
$scale = new CanvasScale($g);
$scale->Set(0,$xmax,0,$ymax);
// ... we need shape since we want the indented rectangle
$shape = new Shape($g,$scale);
$shape->SetColor('black');
// ... basic parameters for the overall image
$l = 2; // Left margin
$r = 18; // Row number to start the lowest line on
$width = 16; // Total width
// Setup the two basic rectangle text object we will use
$tt = new CanvasRectangleText();
$tt->SetFont(FF_ARIAL,FS_NORMAL,14);
$tt->SetFillColor('');
$tt->SetColor('');
$tt->SetFontColor('navy');
$t = new CanvasRectangleText();
$t->SetFont(FF_ARIAL,FS_NORMAL,14);
$t->SetFillColor('goldenrod1');
$t->SetFontColor('navy');
// Now start drawing the arch overview from the bottom and up
// This is all pretty manual and one day I will write a proper
// framework to make it easy to construct these types of architecture
// overviews. But for now, just plain old coordinates..
// Line: GD Library and image libraries
$h=3;
$s = 3; $d=$l + $width-9;
$t->SetFillColor('cadetblue3');
$t->Set("TTF",$d,$r+2,$s,1);
$t->Stroke($g->img,$scale);
$t->Set("PNG",$d+$s,$r+2,$s,1);
$t->Stroke($g->img,$scale);
$t->Set("JPEG",$d+2*$s,$r+2,$s,1);
$t->Stroke($g->img,$scale);
$shape->IndentedRectangle($l,$r,$width,$h,$s*3,1,2,'lightgreen');
$tt->Set("GD Basic library\n(1.8.x or 2.x)",$l,$r,$width,$h-1);
$tt->Stroke($g->img,$scale);
// Area: Basic internal JpGraph architecture
$t->SetFillColor('goldenrod1');
$h = 2;
$r -= $h; $d=8;
$t->Set("Image primitives\n(RGB, Anti-aliasing,\nGD Abstraction)",$l,$r-0.5,$width*0.5,$h+0.5);
$t->Stroke($g->img,$scale);
$t->Set("Image Cache &\nStreaming",$l+0.5*$width,$r,$width*0.4,$h);
$t->Stroke($g->img,$scale);
$r -= $h; $d=8;
$t->Set("2D Rot & Transformation",$l,$r,$width*0.5,$h-0.5); $t->Stroke($g->img,$scale);
$r -= 2; $h = 4;
$shape->IndentedRectangle($l,$r,$width*0.9,$h,$d,2,3,'goldenrod1');
$tt->Set("Axis, Labelling, (Auto)-Scaling",$l,$r,$width*0.9,$h-2); $tt->Stroke($g->img,$scale);
$r -= 1;
$shape->IndentedRectangle($l,$r,$width,7,$width*0.9,6,3,'goldenrod1');
$tt->Set("Error handling & Utility classes",$l,$r,$width,1); $tt->Stroke($g->img,$scale);
// Area: Top area with graph components
$t->SetFillColor('gold1');
$r -= 3;
$w = $width*0.55/4; $h = 2;
$t->Set("Gantt\nGraph",$l,$r,$w,$h);
$t->Stroke($g->img,$scale);
$t->Set("Pie\nGraph",$l+$w,$r,$w,$h);
$t->Stroke($g->img,$scale);
$t->Set("Radar\nGraph",$l+$w*2,$r,$w,$h);
$t->Stroke($g->img,$scale);
$shape->IndentedRectangle($l,$r,$width,3,4*$w,2,0,'gold1');
$tt->Set("Base Graph\n(Orthogonal\ncoordinate system)",$l+4*$w,$r,$width-$w*4,3);
$tt->Stroke($g->img,$scale);
$r -= 2;
$d = 0.7;
$shape->IndentedRectangle($l+3*$w,$r,$w,4, $w*$d,2,0,'gold1');
$t->Set("Canv\nUtil",$l+3*$w,$r,$w*$d,$h); $t->Stroke($g->img,$scale);
$tt->Set("Canvas\nGraph",$l+3*$w,$r+2,$w,2); $tt->Stroke($g->img,$scale);
// Top line of plotting plugins
$t->SetFillColor('cyan');
$t->Set("Gantt\nPlot",$l,$r,$w,$h); $t->Stroke($g->img,$scale);
$t->Set("2D\nPlot",$l+$w,$r,$w/2,$h); $t->Stroke($g->img,$scale);
$t->Set("3D\nPlot",$l+$w+$w/2,$r,$w/2,$h);$t->Stroke($g->img,$scale);
$t->Set("Radar\nPlot",$l+2*$w,$r,$w,$h); $t->Stroke($g->img,$scale);
$wp = ($width - 4*$w)/4;
$t->Set("Error\nPlot",$l+4*$w,$r,$wp,$h); $t->Stroke($g->img,$scale);
$t->Set("Line\nPlot",$l+4*$w+$wp,$r,$wp,$h); $t->Stroke($g->img,$scale);
$t->Set("Bar\nPlot",$l+4*$w+2*$wp,$r,$wp,$h); $t->Stroke($g->img,$scale);
$t->Set("Scatter\nPlot",$l+4*$w+3*$wp,$r,$wp,$h); $t->Stroke($g->img,$scale);
// Show application top
$r -= 2.5; $h=2;
$t->SetFillColor('blue');
$t->SetFontColor('white');
$t->SetFont(FF_ARIAL,FS_BOLD,20);
$t->Set("PHP Application",$l,$r,$width,$h); $t->Stroke($g->img,$scale);
// Stroke title
$r = 0.5;
$tt->SetFontColor('black');
$tt->SetFont(FF_TIMES,FS_BOLD,28);
$tt->Set("JpGraph Architecture Overview",$l,$r,$width,1);
$tt->Stroke($g->img,$scale);
// Stroke footer
$tt->SetFont(FF_VERDANA,FS_NORMAL,10);
$tt->Set("Generated: ".date("ymd H:m",time()),0.1,$ymax*0.95);
$tt->Stroke($g->img,$scale);
// .. and stream it all back
$g->Stroke();
?>

View File

@ -0,0 +1,40 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasbezierex1.php,v 1.1 2002/10/05 21:04:28 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_canvtools.php');
// Setup canvas graph
$g = new CanvasGraph(400,300);
$scale = new CanvasScale($g);
$shape = new Shape($g,$scale);
$g->title->Set('Bezier line with control points');
// Setup control point for bezier
$p = array(3,6,
6,9,
5,3,
7,4);
// Visualize control points
$shape->SetColor('blue');
$shape->Line($p[0],$p[1],$p[2],$p[3]);
$shape->FilledCircle($p[2],$p[3],-6);
$shape->SetColor('red');
$shape->Line($p[4],$p[5],$p[6],$p[7]);
$shape->FilledCircle($p[4],$p[5],-6);
// Draw bezier
$shape->SetColor('black');
$shape->Bezier($p);
// Frame it with a square
$shape->SetColor('navy');
$shape->Rectangle(0.5,2,9.5,9.5);
// ... and stroke it
$g->Stroke();
?>

View File

@ -0,0 +1,37 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasex01.php,v 1.3 2002/10/23 08:17:23 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
// Setup a basic canvas we can work
$g = new CanvasGraph(400,300,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Draw a text box in the middle
$txt="This\nis\na TEXT!!!";
$t = new Text($txt,200,10);
$t->SetFont(FF_ARIAL,FS_BOLD,40);
// How should the text box interpret the coordinates?
$t->Align('center','top');
// How should the paragraph be aligned?
$t->ParagraphAlign('center');
// Add a box around the text, white fill, black border and gray shadow
$t->SetBox("white","black","gray");
// Stroke the text
$t->Stroke($g->img);
// Stroke the graph
$g->Stroke();
?>

View File

@ -0,0 +1,42 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasex02.php,v 1.1 2002/08/27 20:08:57 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
// Setup a basic canvas we can work
$g = new CanvasGraph(400,200,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Add a black line
$g->img->SetColor('black');
$g->img->Line(0,0,100,100);
// .. and a circle (x,y,diameter)
$g->img->Circle(100,100,50);
// .. and a filled circle (x,y,diameter)
$g->img->SetColor('red');
$g->img->FilledCircle(200,100,50);
// .. add a rectangle
$g->img->SetColor('green');
$g->img->FilledRectangle(10,10,50,50);
// .. add a filled rounded rectangle
$g->img->SetColor('green');
$g->img->FilledRoundedRectangle(300,30,350,80,10);
// .. with a darker border
$g->img->SetColor('darkgreen');
$g->img->RoundedRectangle(300,30,350,80,10);
// Stroke the graph
$g->Stroke();
?>

View File

@ -0,0 +1,58 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasex03.php,v 1.1 2002/08/27 20:08:57 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_canvtools.php');
// Define work space
$xmax=20;
$ymax=20;
// Setup a basic canvas we can work
$g = new CanvasGraph(400,200,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0,$xmax,0,$ymax);
// The shape class is wrapper around the Imgae class which translates
// the coordinates for us
$shape = new Shape($g,$scale);
$shape->SetColor('black');
// Add a black line
$shape->SetColor('black');
$shape->Line(0,0,20,20);
// .. and a circle (x,y,diameter)
$shape->Circle(5,14,2);
// .. and a filled circle (x,y,diameter)
$shape->SetColor('red');
$shape->FilledCircle(11,8,3);
// .. add a rectangle
$shape->SetColor('green');
$shape->FilledRectangle(15,8,19,14);
// .. add a filled rounded rectangle
$shape->SetColor('green');
$shape->FilledRoundedRectangle(2,3,8,6);
// .. with a darker border
$shape->SetColor('darkgreen');
$shape->RoundedRectangle(2,3,8,6);
// Stroke the graph
$g->Stroke();
?>

View File

@ -0,0 +1,58 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasex04.php,v 1.1 2002/08/27 20:08:57 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_canvtools.php');
// Define work space
$xmax=20;
$ymax=20;
// Setup a basic canvas we can work
$g = new CanvasGraph(200,100,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0,$xmax,0,$ymax);
// The shape class is wrapper around the Imgae class which translates
// the coordinates for us
$shape = new Shape($g,$scale);
$shape->SetColor('black');
// Add a black line
$shape->SetColor('black');
$shape->Line(0,0,20,20);
// .. and a circle (x,y,diameter)
$shape->Circle(5,14,2);
// .. and a filled circle (x,y,diameter)
$shape->SetColor('red');
$shape->FilledCircle(11,8,3);
// .. add a rectangle
$shape->SetColor('green');
$shape->FilledRectangle(15,8,19,14);
// .. add a filled rounded rectangle
$shape->SetColor('green');
$shape->FilledRoundedRectangle(2,3,8,6);
// .. with a darker border
$shape->SetColor('darkgreen');
$shape->RoundedRectangle(2,3,8,6);
// Stroke the graph
$g->Stroke();
?>

View File

@ -0,0 +1,58 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasex05.php,v 1.1 2002/08/27 20:08:57 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_canvtools.php');
// Define work space
$xmax=40;
$ymax=40;
// Setup a basic canvas we can work
$g = new CanvasGraph(400,200,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0,$xmax,0,$ymax);
// The shape class is wrapper around the Imgae class which translates
// the coordinates for us
$shape = new Shape($g,$scale);
$shape->SetColor('black');
// Add a black line
$shape->SetColor('black');
$shape->Line(0,0,20,20);
// .. and a circle (x,y,diameter)
$shape->Circle(5,14,2);
// .. and a filled circle (x,y,diameter)
$shape->SetColor('red');
$shape->FilledCircle(11,8,3);
// .. add a rectangle
$shape->SetColor('green');
$shape->FilledRectangle(15,8,19,14);
// .. add a filled rounded rectangle
$shape->SetColor('green');
$shape->FilledRoundedRectangle(2,3,8,6);
// .. with a darker border
$shape->SetColor('darkgreen');
$shape->RoundedRectangle(2,3,8,6);
// Stroke the graph
$g->Stroke();
?>

View File

@ -0,0 +1,42 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvasex06.php,v 1.1 2002/08/27 20:08:57 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_canvtools.php');
// Define work space
$xmax=40;
$ymax=40;
// Setup a basic canvas we can work
$g = new CanvasGraph(400,200,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0,$xmax,0,$ymax);
// The shape class is wrapper around the Imgae class which translates
// the coordinates for us
$shape = new Shape($g,$scale);
$shape->SetColor('black');
$shape->IndentedRectangle(1,2,15,15,8,8,CORNER_TOPLEFT,'khaki');
$shape->IndentedRectangle(1,20,15,15,8,8,CORNER_BOTTOMLEFT,'khaki');
$shape->IndentedRectangle(20,2,15,15,8,8,CORNER_TOPRIGHT,'khaki');
$shape->IndentedRectangle(20,20,15,15,8,8,CORNER_BOTTOMRIGHT,'khaki');
// Stroke the graph
$g->Stroke();
?>

View File

@ -0,0 +1,78 @@
<?php // content="text/plain; charset=utf-8"
// $Id: canvaspiralex1.php,v 1.1 2002/10/26 11:35:42 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
if( empty($_GET['r']) )
$r = 0.44;
else
$r = $_GET['r'];
if( empty($_GET['w']) )
$w=150;
else
$w = $_GET['w'];
if( empty($_GET['h']) )
$h=240;
else
$h = $_GET['h'];
if( $w < 60 ) $w=60;
if( $h < 60 ) $h=60;
function SeaShell($img,$x,$y,$w,$h,$r,$n=12,$color1='navy',$color2='red') {
$x += $w;
$w = (1-$r)/$r*$w;
$sa = 0;
$ea = 90;
$s1 = 1;
$s2 = -1;
$x_old=$x; $y_old=$y;
for($i=1; $i < $n; ++$i) {
$sa += 90;
$ea += 90;
if( $i % 2 == 1 ) {
$y = $y + $s1*$h*$r;
$h = (1-$r)*$h;
$w = $w / (1-$r) * $r ;
$s1 *= -1;
$img->SetColor($color1);
$img->Line($x,$y,$x+$s1*$w,$y);
}
else {
$x = $x + $s2*$w*$r;
$w = (1-$r)*$w;
$h = $h / (1-$r) * $r;
$s2 *= -1;
$img->SetColor($color1);
$img->Line($x,$y,$x,$y-$s2*$h);
}
$img->SetColor($color2);
$img->FilledRectangle($x-1,$y-1,$x+1,$y+1);
$img->Arc($x,$y,2*$w+1,2*$h+1,$sa,$ea);
$img->Arc($x,$y,2*$w,2*$h,$sa,$ea);
$img->Arc($x,$y,2*$w-1,2*$h-1,$sa,$ea);
$img->Line($x_old,$y_old,$x,$y);
$x_old=$x; $y_old=$y;
}
}
$g = new CanvasGraph($w,$h);
//$gr = 1.61803398874989484820;
$p = SeaShell($g->img,0,20,$w-1,$h-21,$r,19);
$g->img->SetColor('black');
$g->img->Rectangle(0,20,$w-1,$h-1);
$g->img->SetFont(FF_FONT2,FS_BOLD);
$g->img->SetTextAlign('center','top');
$g->img->StrokeText($w/2,0,"Canvas Spiral");
$g->Stroke();
?>

View File

@ -0,0 +1,36 @@
<?php // content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_plotmark.inc.php';
require_once 'jpgraph/jpgraph_scatter.php';
require_once 'ccbpgraph.class.php';
$graph = new CCBPGraph(600,400);
$graph->SetTitle('Buffer penetration','(history added)');
$graph->SetColorMap(0);
// Two "fake tasks with hostory
$datax=array(75,83); $datay=array(110,64);
$datax1 = array(33,50,67,83); $datay1 = array(86,76,80,64);
$datax2 = array(18,47,58,75); $datay2 = array(80,97,105,110);
$sp = new ScatterPlot($datay,$datax);
$sp->mark->SetType(MARK_DIAMOND);
$sp->mark->SetFillColor('white');
$sp->mark->SetSize(12);
$sp_hist = array();
$sp_hist[0] = new LinePlot($datay1,$datax1);
$sp_hist[0]->SetWeight(1);
$sp_hist[0]->SetColor('white');
$sp_hist[1] = new LinePlot($datay2,$datax2);
$sp_hist[1]->SetWeight(1);
$sp_hist[1]->SetColor('white');
$graph->Add($sp_hist);
$graph->Add($sp);
$graph->Stroke();
?>

View File

@ -0,0 +1,36 @@
<?php // content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_plotmark.inc.php';
require_once 'jpgraph/jpgraph_scatter.php';
require_once 'ccbpgraph.class.php';
$graph = new CCBPGraph(600,400);
$graph->SetTitle('Buffer penetration','(history added)');
$graph->SetColorMap(1);
// Two "fake tasks with hostory
$datax=array(75,83); $datay=array(110,64);
$datax1 = array(33,50,67,83); $datay1 = array(86,76,80,64);
$datax2 = array(18,47,58,75); $datay2 = array(80,97,105,110);
$sp = new ScatterPlot($datay,$datax);
$sp->mark->SetType(MARK_DIAMOND);
$sp->mark->SetFillColor('white');
$sp->mark->SetSize(12);
$sp_hist = array();
$sp_hist[0] = new LinePlot($datay1,$datax1);
$sp_hist[0]->SetWeight(1);
$sp_hist[0]->SetColor('white');
$sp_hist[1] = new LinePlot($datay2,$datax2);
$sp_hist[1]->SetWeight(1);
$sp_hist[1]->SetColor('white');
$graph->Add($sp_hist);
$graph->Add($sp);
$graph->Stroke();
?>

View File

@ -0,0 +1,257 @@
<?php // content="text/plain; charset=utf-8"
/**
* Class CCBPGraph
* Utility class to create Critical Chain Buffer penetration charts
*/
class CCBPGraph {
const TickStep = 25;
const YTitle = '% Buffer used';
const XTitle = '% CC Completed';
const NColorMaps = 2;
private $graph=null;
private $iWidth,$iHeight;
private $iPlots=array();
private $iXMin=-50, $iXMax = 100;
private $iYMin=-50, $iYMax = 150;
private $iColorInd = array(
array(5,75), /* Green */
array(25,85), /* Yellow */
array(50,100));/* Red */
private $iColorMap = 0;
private $iColorSpec = array(
array('darkgreen:1.0','yellow:1.4','red:0.8','darkred:0.85'),
array('#c6e9af','#ffeeaa','#ffaaaa','#de8787'));
private $iMarginColor = array('darkgreen@0.7','darkgreen@0.9');
private $iSubTitle='',$iTitle = 'CC Buffer penetration';
/**
* Construct a new instance of CCBPGraph
*
* @param int $aWidth
* @param int $aHeight
* @return CCBPGraph
*/
public function __construct($aWidth, $aHeight) {
$this->iWidth = $aWidth;
$this->iHeight = $aHeight;
}
/**
* Set the title and subtitle for the graph
*
* @param string $aTitle
* @param string $aSubTitle
*/
public function SetTitle($aTitle, $aSubTitle) {
$this->iTitle = $aTitle;
$this->iSubTitle = $aSubTitle;
}
/**
* Set the x-axis min and max values
*
* @param int $aMin
* @param int $aMax
*/
public function SetXMinMax($aMin, $aMax) {
$this->iXMin = floor($aMin/CCBPGraph::TickStep)*CCBPGraph::TickStep;
$this->iXMax = ceil($aMax/CCBPGraph::TickStep)*CCBPGraph::TickStep;
}
/**
* Specify what color map to use
*
* @param int $aMap
*/
public function SetColorMap($aMap) {
$this->iColorMap = $aMap % CCBPGraph::NColorMaps;
}
/**
* Set the y-axis min and max values
*
* @param int $aMin
* @param int $aMax
*/
public function SetYMinMax($aMin,$aMax) {
$this->iYMin = floor($aMin/CCBPGraph::TickStep)*CCBPGraph::TickStep;
$this->iYMax = ceil($aMax/CCBPGraph::TickStep)*CCBPGraph::TickStep;
}
/**
* Set the specification of the color backgrounds and also the
* optional exact colors to be used
*
* @param mixed $aSpec An array of 3 1x2 arrays. Each array specify the
* color indication value at x=0 and x=max x in order to determine the slope
* @param mixed $aColors An array with four elements specifying the colors
* of each color indicator
*/
public function SetColorIndication(array $aSpec,array $aColors=null) {
if( count($aSpec) !== 3 ) {
JpgraphError::Raise('Specification of scale values for background indicators must be an array with three elements.');
}
$this->iColorInd = $aSpec;
if( $aColors !== null ) {
if( is_array($aColors) && count($aColors) == 4 ) {
$this->iColorSpec = $aColors;
}
else {
JpGraphError::Raise('Color specification for background indication must have four colors.');
}
}
}
/**
* Construct the graph
*
*/
private function Init() {
// Setup limits for color indications
$lowx = $this->iXMin; $highx= $this->iXMax;
$lowy = $this->iYMin; $highy = $this->iYMax;
$width=$this->iWidth; $height=$this->iHeight;
// Margins
$lm=50; $rm=40;
$tm=60; $bm=40;
if( $width <= 300 || $height <= 250 ) {
$labelsize = 8;
$lm=25; $rm=25;
$tm=45; $bm=25;
}
elseif( $width <= 450 || $height <= 300 ) {
$labelsize = 8;
$lm=30; $rm=30;
$tm=50; $bm=30;
}
elseif( $width <= 600 || $height <= 400 ) {
$labelsize = 9;
}
else {
$labelsize = 11;
}
if( $this->iSubTitle == '' ) {
$tm -= $labelsize+4;
}
$graph = new Graph($width,$height);
$graph->SetScale('intint',$lowy,$highy,$lowx,$highx);
$graph->SetMargin($lm,$rm,$tm,$bm);
$graph->SetMarginColor($this->iMarginColor[$this->iColorMap]);
$graph->SetClipping();
$graph->title->Set($this->iTitle);
$graph->subtitle->Set($this->iSubTitle);
$graph->title->SetFont(FF_ARIAL,FS_BOLD,$labelsize+4);
$graph->subtitle->SetFont(FF_ARIAL,FS_BOLD,$labelsize+1);
$graph->SetBox(true,'black@0.3');
$graph->xaxis->SetFont(FF_ARIAL,FS_BOLD,$labelsize);
$graph->yaxis->SetFont(FF_ARIAL,FS_BOLD,$labelsize);
$graph->xaxis->scale->ticks->Set(CCBPGraph::TickStep,CCBPGraph::TickStep);
$graph->yaxis->scale->ticks->Set(CCBPGraph::TickStep,CCBPGraph::TickStep);
$graph->xaxis->HideZeroLabel();
$graph->yaxis->HideZeroLabel();
$graph->xaxis->SetLabelFormatString('%d%%');
$graph->yaxis->SetLabelFormatString('%d%%');
// For the x-axis we adjust the color so labels on the left of the Y-axis are in black
$n1 = floor(abs($this->iXMin/25))+1;
$n2 = floor($this->iXMax/25);
if( $this->iColorMap == 0 ) {
$xlcolors=array();
for( $i = 0; $i < $n1; ++$i ) {
$xlcolors[$i] = 'black';
}
for( $i = 0; $i < $n2; ++$i ) {
$xlcolors[$n1+$i] = 'lightgray:1.5';
}
$graph->xaxis->SetColor('gray',$xlcolors);
$graph->yaxis->SetColor('gray','lightgray:1.5');
}
else {
$graph->xaxis->SetColor('darkgray','darkgray:0.8');
$graph->yaxis->SetColor('darkgray','darkgray:0.8');
}
$graph->SetGridDepth(DEPTH_FRONT);
$graph->ygrid->SetColor('gray@0.6');
$graph->ygrid->SetLineStyle('dotted');
$graph->ygrid->Show();
$graph->xaxis->SetWeight(1);
$graph->yaxis->SetWeight(1);
$ytitle = new Text(CCBPGraph::YTitle,floor($lm*.75),($height-$tm-$bm)/2+$tm);
#$ytitle->SetFont(FF_VERA,FS_BOLD,$labelsize+1);
$ytitle->SetAlign('right','center');
$ytitle->SetAngle(90);
$graph->Add($ytitle);
$xtitle = new Text(CCBPGraph::XTitle,($width-$lm-$rm)/2+$lm,$height - 10);
#$xtitle->SetFont(FF_VERA,FS_BOLD,$labelsize);
$xtitle->SetAlign('center','bottom');
$graph->Add($xtitle);
$df = 'D j:S M, Y';
if( $width < 400 ) {
$df = 'D j:S M';
}
$time = new Text(date($df),$width-10,$height-10);
$time->SetAlign('right','bottom');
#$time->SetFont(FF_VERA,FS_NORMAL,$labelsize-1);
$time->SetColor('darkgray');
$graph->Add($time);
// Use an accumulated fille line graph to create the colored bands
$n = 3;
for( $i=0; $i < $n; ++$i ) {
$b = $this->iColorInd[$i][0];
$k = ($this->iColorInd[$i][1] - $this->iColorInd[$i][0])/$this->iXMax;
$colarea[$i] = array( array($lowx,$lowx*$k+$b), array($highx,$highx*$k+$b) );
}
$colarea[3] = array( array($lowx,$highy), array($highx,$highy) );
$cb = array();
for( $i=0; $i < 4; ++$i ) {
$cb[$i] = new LinePlot(array($colarea[$i][0][1],$colarea[$i][1][1]),
array($colarea[$i][0][0],$colarea[$i][1][0]));
$cb[$i]->SetFillColor($this->iColorSpec[$this->iColorMap][$i]);
$cb[$i]->SetFillFromYMin();
}
$graph->Add(array_slice(array_reverse($cb),0,4));
$this->graph = $graph;
}
/**
* Add a line or scatter plot to the graph
*
* @param mixed $aPlots
*/
public function Add($aPlots) {
if( is_array($aPlots) ) {
$this->iPlots = array_merge($this->iPlots,$aPlots);
}
else {
$this->iPlots[] = $aPlots;
}
}
/**
* Stroke the graph back to the client or to a file
*
* @param mixed $aFile
*/
public function Stroke($aFile='') {
$this->Init();
if( count($this->iPlots) > 0 ) {
$this->graph->Add($this->iPlots);
}
$this->graph->Stroke($aFile);
}
}
?>

View File

@ -0,0 +1,35 @@
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_error.php');
//$datax = array(3.5,3.7,3,4,6.2,6,3.5,8,14,8,11.1,13.7);
$datay = array(1.23,1.9,1.6,3.1,3.4,2.8,2.1,1.9);
$graph = new Graph(300,200);
$graph->img->SetMargin(40,40,40,40);
$graph->img->SetAntiAliasing();
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set("Example of line centered plot");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Use 20% "grace" to get slightly larger scale then min/max of
// data
$graph->yscale->SetGrace(20);
$p1 = new 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();
?>

Some files were not shown because too many files have changed in this diff Show More