fpdf
PHP powered
home was ist fpdf? downloads & add-ons dokumentation faq forum impressum links kontakt
 

Downloads > Add-On

 
         
 

Example with PHPlot

Informations

Author: Ulrich Taaken
License: Freeware

Description

This script shows how to embed a graph generated by PHPlot in a PDF. It makes use of the script Memory images.
The important thing to note is the call to the SetPrintImage() method to prevent the image from being sent to the browser. Then the GD handle is retrieved via $graph->img.
This example works with PHPlot 4.4.6.

Source

<?php
require('mem_image.php');
require(
'phplot/phplot.php');

$graph = new PHPlot(500, 250);
$graph->SetDataType('linear-linear');

//Specify some data
$data = array(
    array('', 2000,   750),
    array('', 2010, 1700),
    array('', 2015, 2000),
    array('', 2020, 1800),
    array('', 2025, 1300),
    array('', 2030,   400)
);
$graph->SetDataValues($data);

//Specify plotting area details
$graph->SetPlotType('lines');
$graph->SetTitleFontSize('2');
$graph->SetTitle('Social Security trust fund asset estimates, in $ billions');
$graph->SetPlotAreaWorld(2000, 0, 2035, 2000);
$graph->SetPlotBgColor('white');
$graph->SetPlotBorderType('left');
$graph->SetBackgroundColor('white');
$graph->SetDataColors(array('red'), array('black'));

//Define the X axis
$graph->SetXLabel('Year');
$graph->SetHorizTickIncrement('5');
$graph->SetXGridLabelType('default');

//Define the Y axis
$graph->SetVertTickIncrement('500');
$graph->SetPrecisionY('0');
$graph->SetYGridLabelType('right');
$graph->SetLightGridColor('blue');

//Disable image output
$graph->SetPrintImage(false);
//Draw the graph
$graph->DrawGraph();

$pdf = new MEM_IMAGE();
$pdf->AddPage();
$pdf->GDImage($graph->img, 30, 20, 140);
$pdf->Output();
?>

View the result here.

Download

ZIP | TGZ
 






 
         
         
 
 
fpdf.de © Copyright 2004-2006 carrib internet solutions - Beachten Sie bitte die Nutzungsbedingungen
Eine Verwendung der auf fpdf.de befindlichen Inhalte (Texte, Grafiken) ist nur mit Zustimmung des Betreibers zulässig.