PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-06-09 (17 days ago) RSS 2.0 feedStarStarStarStarStar 80%Total: 161 This week: 2All time: 8,009 This week: 545Up
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: 6 packages by
Country: Argentina Argentina
Age: 43
All time rank: 216328 in Argentina Argentina
Week rank: 128 Up1 in Argentina Argentina Up
Innovation award
Innovation award
Nominee: 4x

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 folder image Files  
File Role Description
Files folder imagefont (4 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file example.pdf Data Auxiliary data
Accessible without login Plain text file example.php Example Example script
Accessible without login Image file example.png Output Example
Plain text file fpdf.php Class Class source
Plain text file PHP2PDFGraphCompare.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  font  
File Role Description
  Accessible without login Plain text file helvetica.php Aux. Auxiliary script
  Accessible without login Plain text file helveticab.php Aux. Auxiliary script
  Accessible without login Plain text file helveticabi.php Aux. Auxiliary script
  Accessible without login Plain text file helveticai.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 91%
Total:161
This week:2
All time:8,009
This week:545Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:80%StarStarStarStarStar
Rank:11