JpGraph サンプル

← 一覧に戻る
<?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

// Create the graph and setup the basic parameters
$graph = new Graph(500,300,'auto');
$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

// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();

// Setup graph title ands fonts
$graph->title->Set('Example of Y-scale callback formatting');
$graph->xaxis->title->Set('Year 2002');

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

// Setup the values that are displayed on top of each bar

// Must use TTF fonts if we want text at an arbitrary angle

// Black color for positive values and darkred for negative values

// Finally stroke the graph
← 一覧に戻る