JpGraph サンプル

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

// Get a dataset stored in $xdata and $ydata
require_once ('');

$dateUtils = new DateScaleUtils();

// Setup a basic graph
$width=500; $height=300;
$graph = new Graph($width, $height);

// We set the x-scale min/max values to avoid empty space
// on the side of the plot

// Setup the titles
$graph->title->Set('Development since 1984');
$graph->subtitle->Set('(Example using DateScaleUtils class)');

// Setup the labels to be correctly format on the X-axis

// The second paramter set to 'true' will make the library interpret the
// format string as a date format. We use a Month + Year format
$graph->xaxis->SetLabelFormatString('M, Y',true);

// Get manual tick every second year
list($tickPos,$minTickPos) = $dateUtils->getTicks($xdata,DSUTILS_YEAR2);

// First add an area plot
$lp1 = new LinePlot($ydata,$xdata);

// And then add line. We use two plots in order to get a
// more distinct border on the graph
$lp2 = new LinePlot($ydata,$xdata);

// And send back to the client

← 一覧に戻る