JpGraph サンプル

← 一覧に戻る
<?php // content="text/plain; charset=utf-8"
require_once ("jpgraph/jpgraph.php");
require_once ("jpgraph/jpgraph_bar.php");


// Size of graph

// Set the basic parameters of the graph 
$graph = new Graph($width,$height,'auto');

$top = 50;
$bottom = 80;
$left = 50;
$right = 20;


// Nice shadow

// Setup title
$graph->title->Set("Horizontal bar graph ex 3");
$graph->subtitle->Set("(Axis at bottom)");

// Setup X-axis

// Some extra margin looks nicer

// Label align for X-axis

// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area

// Setup the Y-axis to be displayed in the bottom of the 
// graph. We also finetune the exact layout of the title,
// ticks and labels to make them look nice.

// First make the labels look right

// The fix the tick marks

// Finally setup the title

// To align the title to the right use :
$graph->yaxis->SetTitle('Turnaround 2002','high');

// To center the title use :
//$graph->yaxis->SetTitle('Turnaround 2002','center');


// If you want the labels at an angle other than 0 or 90
// you need to use TTF fonts

// Now create a bar pot
$bplot = new BarPlot($datay);

//You can change the width of the bars if you like

// We want to display the value of each bar at the top
$bplot->value->SetFormat('%.1f mkr');

// Add the bar to the graph

← 一覧に戻る