PHP PDF Line Chart: Generate line charts to compare data in PDF

Recommend this page to a friend!
  Info   Example   Screenshots   View files (11)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
80%Total: 343 This week: 1All time: 6,948 This week: 255
Version License PHP version Categories
php2pdfgraphcompare 1.1GNU General Publi...4Graphics, Files and Folders, Printing
Description Author

This class can generate line charts to compare data in PDF.

It extends the FPDF class to add line charts to a PDF document from a given data set to allow each set of values to be visually compared.

The class takes as parameters the title, position coordinates and size of the chart to be added to the PDF document.

Innovation Award
PHP Programming Innovation award nominee
March 2016
Number 7


Prize: One downloadable copy of Komodo IDE
PDF is a popular format to generate documents that are meant to be printed.

Sometimes it is necessary to display charts on documents to be printed.

This class can generate PDF documents that show line charts to compare multiple sets of data.

Manuel Lemos
Picture of Luciano Salvino
  Performance   Level  
Name: Luciano Salvino <contact>
Classes: 11 packages by
Country: Argentina Argentina
Age: 47
All time rank: 143317 in Argentina Argentina
Week rank: 259 3 in Argentina Argentina
Innovation award
Innovation award
Nominee: 9x

Details

PHP2PDFGraphCompare

PHP2PDFGraphCompare is a PHP class that create PDF file with line graph comparatives like google analytics. FPDF class extended

Usage

$pdf = new PDF( '$p_orient', 'mm', '$p_size' );
$pdf->Open();
$pdf->AddPage();

// define position and dimentions
$x = 15;
$y = 30; 
$w = ($pdf->w - 20);
$h = 80;
	
// define title	
$repTitle = "Visits";
				
$arrData = array();

// define old data
$arrData[] = array(
	"title" => "Last Month",
	"color" => array(55,00,122),
	"data" => array(
		array(
			"key"   => 1,
			"value" => 800
		),
		array(
			"key"   => 2,
			"value" => 3100
		),
		array(
			"key"   => 3,
			"value" => 2700
		),
		array(
			"key"   => 4,
			"value" => 2100
		),
		array(
			"key"   => 5,
			"value" => 2000
		),
		array(
			"key"   => 6,
			"value" => 2700
		),
		array(
			"key"   => 7,
			"value" => 3000
		),
		array(
			"key"   => 8,
			"value" => 3600
		),
		array(
			"key"   => 9,
			"value" => 3250
		),
		array(
			"key"   => 10,
			"value" => 3150
		),
	)
);
// define current data
$arrData[] = array(
	"title" => "Current",
	"color" => array(237,125,22),
	"data" => array(
		array(
			"key"   => 1,
			"value" => 1800
		),
		array(
			"key"   => 2,
			"value" => 2900
		),
		array(
			"key"   => 3,
			"value" => 3700
		),
		array(
			"key"   => 4,
			"value" => 3100
		),
		array(
			"key"   => 5,
			"value" => 4100
		),
		array(
			"key"   => 6,
			"value" => 3800
		),
		array(
			"key"   => 7,
			"value" => 3900
		),
		array(
			"key"   => 8,
			"value" => 3600
		),
		array(
			"key"   => 9,
			"value" => 3800
		),
		array(
			"key"   => 10,
			"value" => 3750
		),
	)
);
// gen line charts
$pdf->LineChart($x,$y,$w,$h,$repTitle,$arrData);

// gen pdf file
$pdf->Output();
Screenshots  
  • example-pdf.png
  Files  
File Role Description
font (4 files)
composer.json Data Auxiliary data
example.pdf Data Auxiliary data
example.php Example Example script
example.png Output Example
fpdf.php Class Class source
PHP2PDFGraphCompare.php Class Class source
README.md Doc. Documentation

  Files  /  font  
File Role Description
   helvetica.php Aux. Auxiliary script
   helveticab.php Aux. Auxiliary script
   helveticabi.php Aux. Auxiliary script
   helveticai.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 91%
Total:343
This week:1
All time:6,948
This week:255
 User Ratings  
 
 All time
Utility:100%
Consistency:100%
Documentation:100%
Examples:100%
Tests:-
Videos:-
Overall:80%
Rank:22
  

For more information send a message to info at phpclasses dot org.