<?php
set_include_path( "/user/php/jpgraph-1.21b/src" );
include ("jpgraph.php");
include ("jpgraph_bar.php");
$datay=array(12,8,19,3,10,5);
// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");
$graph->SetScale("textlin");
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40,30,20,40);
// Create a bar pot
$bplot = new BarPlot($datay);
$graph->Add($bplot);
// Setup the titles
$graph->title->Set("A simple bar graph");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// Display the graph
$graph->Stroke();
?>
1) include_path に、ライブラリのパスを設定する
2) include の記述を変更
拡張子:
set_include_path( "/user/php/jpgraph-1.21b/src" );
include ("jpgraph.php");
include ("jpgraph_bar.php");
//------------------------------------------------------------------------// Directories for cache and font directory.
//
// CACHE_DIR:// The full absolute name of the directory to be used to store the// cached image files. This directory will not be used if the USE_CACHE// define (further down) is false. If you enable the cache please note that// this directory MUST be readable and writable for the process running PHP.// Must end with '/'
//
// TTF_DIR:// Directory where TTF fonts can be found. Must end with '/'
//
// The default values used if these defines are left commented out are:
//
// UNIX:// CACHE_DIR /tmp/jpgraph_cache/// TTF_DIR /usr/X11R6/lib/X11/fonts/truetype/// MBTTF_DIR /usr/share/fonts/ja/TrueType/
//
// WINDOWS:// CACHE_DIR $SERVER_TEMP/jpgraph_cache/// TTF_DIR $SERVER_SYSTEMROOT/fonts/// MBTTF_DIR $SERVER_SYSTEMROOT/fonts/
//
//------------------------------------------------------------------------// DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");// DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/");// DEFINE("MBTTF_DIR","/usr/share/fonts/ja/TrueType/");DEFINE("TTF_DIR","/user/php/font/");DEFINE("MBTTF_DIR","/user/php/font/");
拡張子:
// Japanese TrueType font used with FF_MINCHO, FF_PMINCHO, FF_GOTHIC, FF_PGOTHIC
DEFINE('MINCHO_TTF_FONT','elenat.ttf');
DEFINE('PMINCHO_TTF_FONT','elenat.ttf');
DEFINE('GOTHIC_TTF_FONT','elenat.ttf');
DEFINE('PGOTHIC_TTF_FONT','elenat.ttf');
<?php
set_include_path( "/user/php/jpgraph-1.21b/src" );
include ("jpgraph.php");
include ("jpgraph_bar.php");
$datay=array(12,8,19,3,10,5);
// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");
$graph->SetScale("textlin");
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40,30,20,40);
// Create a bar pot
$bplot = new BarPlot($datay);
$graph->Add($bplot);
// Setup the titles// 内部コード設定
mb_language( "ja" );
mb_internal_encoding("EUC-JP");
// UTF-8 に変換
$str = "シンプル棒グラフ";
$str = mb_convert_encoding ( $str, "UTF-8" );
$graph->title->Set( $str );
$graph->xaxis->title->Set( mb_convert_encoding ( "x 座標", "UTF-8" ) );
$graph->yaxis->title->Set( mb_convert_encoding ( "y 座標", "UTF-8" ) );
// フリーフォントの指定
$graph->title->SetFont(FF_GOTHIC);
$graph->yaxis->title->SetFont(FF_GOTHIC);
$graph->xaxis->title->SetFont(FF_GOTHIC);
// Display the graph
$graph->Stroke();
?>