JpGraph サンプル

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

// We accept a URI argument to adjust the angle at what we display the text
if( empty($_GET['a']) ) {
else {

// Caption below the image
$caption = "Demonstration of different anchor points for texts as specified with\n".
    "TextAlign(). The red cross marks the coordinate that was given to\n".
    "stroke each instance of the string.\n(The green box is the bounding rectangle for the text.)";


// Initial width and height since we need a "dummy" canvas to
// calculate the height of the text strings

$g = new CanvasGraph($w,$h);

// Make the image easier to access
$img = $g->img;

// Get the bounding box for text


// Calculate needed height for the image
$h = 3*$th+2*$ym + $ch;
$g = new CanvasGraph($w,$h);
$img = $g->img;

// Alignment for anchor points to use
$anchors = array('left','top',

$n = count($anchors)/2;

for( $i=0,$r=0,$c=0; $i < $n; ++$i ) {

    $x = $c*($tw+$xm)+$xm/2;
    $y = $r*($th+$ym)+$ym/2-10;


    $align = sprintf('("%s","%s")',$anchors[$i*2],$anchors[$i*2+1]);

    if( $c==3 ) {

// Draw the caption text


// .. and send back to browser


← 一覧に戻る