Example #1
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(350, 100);
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo1 = new Odometer();
$odo2 = new Odometer();
$odo1->SetColor("lightgray:1.9");
$odo2->SetColor("lightgray:1.9");
// Adjust start and end angle for the scale
$odo2->scale->SetAngle(110, 250);
$odo1->scale->label->SetFont(FF_ARIAL, FS_BOLD, 10);
$odo2->scale->label->SetFont(FF_ARIAL, FS_BOLD, 10);
$odo2->AddIndication(-15, 0, 'lightgray');
$odo2->AddIndication(100, 115, 'lightgray');
// Set display value for the odometer
$odo1->needle->Set(70);
$odo2->needle->Set(70);
// Add drop shadow for needle
$odo1->needle->SetShadow();
$odo2->needle->SetShadow();
// Specify the layout for the two odometers
$row = new LayoutHor(array($odo1, $odo2));
// Add the odometer to the graph
$graph->Add($row);
// ... and finally stroke and stream the image back to the browser
Example #2
0
$graph->subtitle->Set("2002-02-13");
$graph->subtitle->SetColor("white");
//---------------------------------------------------------------------
// Specify caption.
// * (This is the text at the bottom of the graph.) The margins will
// automatically adjust to fit the height of the text. A caption
// may have multiple lines by including a '\n' character in the
// string.
//---------------------------------------------------------------------
$graph->caption->Set("First caption row\n... second row");
$graph->caption->SetColor("white");
//---------------------------------------------------------------------
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
//---------------------------------------------------------------------
$odo = new Odometer();
//---------------------------------------------------------------------
// Set color indication
//---------------------------------------------------------------------
$odo->AddIndication(0, 50, "green");
$odo->AddIndication(50, 80, "yellow");
$odo->AddIndication(80, 100, "red");
//---------------------------------------------------------------------
// Set display value for the odometer
//---------------------------------------------------------------------
$odo->needle->Set(30);
//---------------------------------------------------------------------
// Add the odometer to the graph
//---------------------------------------------------------------------
$graph->Add($odo);
//---------------------------------------------------------------------
Example #3
0
$graph->subtitle->Set("2002-02-13");
$graph->subtitle->SetColor("white");
//---------------------------------------------------------------------
// Specify caption.
// * (This is the text at the bottom of the graph.) The margins will
// automatically adjust to fit the height of the text. A caption
// may have multiple lines by including a '\n' character in the
// string.
//---------------------------------------------------------------------
$graph->caption->Set("First caption row\n... second row");
$graph->caption->SetColor("white");
//---------------------------------------------------------------------
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
//---------------------------------------------------------------------
$odo = new Odometer(ODO_FULL);
//---------------------------------------------------------------------
// Set color indication
//---------------------------------------------------------------------
$odo->AddIndication(0, 50, "green");
$odo->AddIndication(50, 80, "yellow");
$odo->AddIndication(80, 100, "red");
//---------------------------------------------------------------------
// Set the center area that will not be affected by the color bands
//---------------------------------------------------------------------
$odo->SetCenterAreaWidth(0.4);
// Fraction of radius
//---------------------------------------------------------------------
// Adjust scale ticks to be shown at 10 steps interval and scale
// labels at every second tick
//---------------------------------------------------------------------
Example #4
0
//---------------------------------------------------------------------
// Specify caption.
// * (This is the text at the bottom of the graph.) The margins will
// automatically adjust to fit the height of the text. A caption
// may have multiple lines by including a '\n' character in the
// string.
//---------------------------------------------------------------------
$graph->caption->Set("Fig1. Values within 85%\nconfidence intervall");
$graph->caption->SetColor("white");
//---------------------------------------------------------------------
// We will display three odometers stacked vertically
// The first thing to do is to create them
//---------------------------------------------------------------------
$odo1 = new Odometer();
$odo2 = new Odometer();
$odo3 = new Odometer();
//---------------------------------------------------------------------
// Set caption for each odometer
//---------------------------------------------------------------------
$odo1->caption->Set("April");
$odo1->caption->SetFont(FF_FONT2, FS_BOLD);
$odo2->caption->Set("May");
$odo2->caption->SetFont(FF_FONT2, FS_BOLD);
$odo3->caption->Set("June");
$odo3->caption->SetFont(FF_FONT2, FS_BOLD);
//---------------------------------------------------------------------
// Set Indicator bands for the odometers
//---------------------------------------------------------------------
$odo1->AddIndication(80, 100, "red");
$odo2->AddIndication(20, 30, "green");
$odo2->AddIndication(65, 100, "red");
Example #5
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(250, 140);
// Setup a title
$graph->title->Set('An example with drop shadows');
// Add drop shadow for graph
$graph->SetShadow();
// Set some nonstandard colors
$color = array(205, 220, 205);
$graph->SetMarginColor($color);
$graph->SetColor($color);
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo = new Odometer();
$odo->SetColor('white');
// Set display value for the odometer
$odo->needle->Set(70);
// Add drop shadow for needle
$odo->needle->SetShadow();
// Add the odometer to the graph
$graph->Add($odo);
// ... and finally stroke and stream the image back to the browser
$graph->Stroke();
Example #6
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(250, 150);
$graph->title->Set('Example with scale indicators');
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo = new Odometer(ODO_HALF);
// Add color indications
$odo->AddIndication(0, 20, "green:0.7");
$odo->AddIndication(20, 30, "green:0.9");
$odo->AddIndication(30, 60, "yellow");
$odo->AddIndication(60, 80, "orange");
$odo->AddIndication(80, 100, "red");
$odo->SetCenterAreaWidth(0.45);
// Set display value for the odometer
$odo->needle->Set(90);
// Add scale labels
$odo->label->Set("mBar");
$odo->label->SetFont(FF_FONT2, FS_BOLD);
// Add drop shadow for needle
$odo->needle->SetShadow();
// Add the odometer to the graph
$graph->Add($odo);
// ... and finally stroke and stream the image back to the browser
$graph->Stroke();
Example #7
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(250, 160);
$graph->title->Set('Custom scale');
$graph->title->SetColor('white');
$graph->title->SetFont(FF_ARIAL, FS_BOLD);
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo = new Odometer();
$odo->SetColor('lightyellow');
// Setup the scale
$odo->scale->Set(100, 600);
$odo->scale->SetTicks(50, 2);
// Set display value for the odometer
$odo->needle->Set(280);
// Add drop shadow for needle
$odo->needle->SetShadow();
// Add the odometer to the graph
$graph->Add($odo);
// ... and finally stroke and stream the image back to the browser
$graph->Stroke();
Example #8
0
$graph->subtitle->Set("2002-02-13");
$graph->subtitle->SetColor("white");
//---------------------------------------------------------------------
// Specify caption.
// * (This is the text at the bottom of the graph.) The margins will
// automatically adjust to fit the height of the text. A caption
// may have multiple lines by including a '\n' character in the
// string.
//---------------------------------------------------------------------
$graph->caption->Set("First caption row\n... second row");
$graph->caption->SetColor("white");
//---------------------------------------------------------------------
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
//---------------------------------------------------------------------
$odo = new Odometer();
//---------------------------------------------------------------------
// Set color indication between values 80 and 100 as red
//---------------------------------------------------------------------
$odo->AddIndication(80, 100, "red");
//---------------------------------------------------------------------
// Set display value for the odometer
//---------------------------------------------------------------------
$odo->needle->Set(30);
//---------------------------------------------------------------------
// Add the odometer to the graph
//---------------------------------------------------------------------
$graph->Add($odo);
//---------------------------------------------------------------------
// ... and finally stroke and stream the image back to the browser
//---------------------------------------------------------------------
Example #9
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(250, 140);
// Setup a title
$graph->title->Set('An example with thick border');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 11);
// Add drop shadow for graph
$graph->SetShadow();
// Set some nonstandard colors
$color = array(205, 220, 205);
$graph->SetMarginColor($color);
$graph->SetColor($color);
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo = new Odometer();
$odo->SetColor('white');
$odo->SetBorder('darkgreen:0.8', 5);
$odo->scale->label->SetFont(FF_ARIAL, FS_BOLD, 10);
$odo->scale->label->SetColor('brown:0.6');
// Set display value for the odometer
$odo->needle->Set(70);
// Add drop shadow for needle
$odo->needle->SetShadow();
// Add the odometer to the graph
$graph->Add($odo);
// ... and finally stroke and stream the image back to the browser
$graph->Stroke();
Example #10
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(250, 150);
$graph->title->Set('Example with scale indicators');
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo = new Odometer(ODO_HALF);
// Add color indications
$odo->AddIndication(0, 20, "green:0.7");
$odo->AddIndication(20, 30, "green:0.9");
$odo->AddIndication(30, 60, "yellow");
$odo->AddIndication(60, 80, "orange");
$odo->AddIndication(80, 100, "red");
// Set display value for the odometer
$odo->needle->Set(90);
//---------------------------------------------------------------------
// Add drop shadow for needle
//---------------------------------------------------------------------
$odo->needle->SetShadow();
//---------------------------------------------------------------------
// Add the odometer to the graph
//---------------------------------------------------------------------
$graph->Add($odo);
//---------------------------------------------------------------------
// ... and finally stroke and stream the image back to the browser
//---------------------------------------------------------------------
Example #11
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(250, 170);
// Setup graph titles
$graph->title->Set('Custom formatting');
$graph->title->SetColor('white');
$graph->title->SetFont(FF_ARIAL, FS_BOLD);
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
$odo = new Odometer();
$odo->SetColor("lightgray:1.9");
// Setup the scale
$odo->scale->Set(100, 600);
$odo->scale->SetTicks(50, 2);
$odo->scale->SetTickColor('brown');
$odo->scale->SetTickLength(0.05);
$odo->scale->SetTickWeight(2);
$odo->scale->SetLabelPos(0.75);
$odo->scale->label->SetFont(FF_FONT1, FS_BOLD);
$odo->scale->label->SetColor('brown');
$odo->scale->label->SetFont(FF_ARIAL, FS_NORMAL, 10);
// Setup a label with a degree mark
$odo->scale->SetLabelFormat('%dC' . SymChar::Get('degree'));
// Set display value for the odometer
$odo->needle->Set(280);
// Add drop shadow for needle
$odo->needle->SetShadow();
Example #12
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph
$graph = new OdoGraph(300, 320);
// Setup graph titles
$graph->title->Set('Manual positioning');
$graph->title->SetColor('white');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
$odo1 = new Odometer();
$odo2 = new Odometer();
$odo1->SetColor('lightgray:1.9');
$odo2->SetColor('lightgray:1.9');
// Set display value for the odometer
$odo1->needle->Set(37);
$odo2->needle->Set(73);
// Add drop shadow for needle
$odo1->needle->SetShadow();
$odo2->needle->SetShadow();
// Specify the position for the two odometers
$odo1->SetPos(180, 110);
$odo1->SetSize(100);
$odo2->SetPos(110, 250);
$odo2->SetSize(100);
// Set captions for the odometers
$odo1->caption->Set("(x,y) = (180,120)\nradius=100");
$odo2->caption->Set("(x,y) = (110,270)\nradius=100");
Example #13
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_odo.php';
// Create a new odometer graph (width=250, height=200 pixels)
$graph = new OdoGraph(350, 100);
// Add drop shadow for graph
$graph->SetShadow();
// Now we need to create an odometer to add to the graph.
// By default the scale will be 0 to 100
$odo1 = new Odometer();
$odo2 = new Odometer();
$odo1->SetColor("lightgray:1.9");
$odo2->SetColor("lightgray:1.9");
// Adjust start and end angle for the scale
$odo2->scale->SetAngle(110, 250);
$odo1->scale->label->SetFont(FF_ARIAL, FS_BOLD, 10);
$odo2->scale->label->SetFont(FF_ARIAL, FS_BOLD, 10);
// Set display value for the odometer
$odo1->needle->Set(70);
$odo2->needle->Set(70);
// Add drop shadow for needle
$odo1->needle->SetShadow();
$odo2->needle->SetShadow();
// Specify the layout for the two odometers
$row = new LayoutHor(array($odo1, $odo2));
// Add the odometer to the graph
$graph->Add($row);
// ... and finally stroke and stream the image back to the browser
$graph->Stroke();