Rev 15079 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
namespace LeadersLinked\Library;
use Fpdf\Fpdf;
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
class SelfEvaluationPdf extends FPDF {
public $header;
public $footer;
/**
* Header PDF
*/
function Header() {
if ($this->header != '') {
$this->Image($this->header, 10, 1, 190);
$this->SetY(55);
}
}
/**
* Header custom PDF
* @param string $headerFormName
* @param string $headerUsername
*/
function customHeader($headerFormName, $headerUsername) {
$s = Functions::utf8_decode(' Página: ' . $this->PageNo());
$this->SetFont('Arial', '', 10);
$this->SetY(40);
$this->Cell(190, 10, $s, 0, 0, 'R');
$this->SetFont('Arial', 'B', 15);
$this->SetY(50);
$this->Cell(180, 10, $headerFormName, 0, 0, 'C');
$this->setY($this->getY() + 8);
$this->SetFont('Arial', '', 10);
$this->Cell(180, 10, $headerUsername, 0, 0, 'C');
$this->setY($this->getY() + 10);
}
/**
* Footer PDF
*/
function Footer() {
if ($this->footer != '') {
$this->SetY(-40);
$this->Image($this->footer, 10,$this->getY() , 190);
}
}
/**
* Create chart PDF
* @param string[] $labels
* @param float[] $values
* @param string $title
* @param string $filename
*/
function pieChart($labels, $values, $title, $filename) {
// We need some data
$datay = $values;
$datax = $labels;
// Setup the graph.
$graph = new Graph\PieGraph(400, 240);
$graph->clearTheme();
$graph->img->SetMargin(60, 20, 35, 75);
$graph->SetScale("textlin");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set($title);
$graph->title->SetMargin(8);
$graph->title->SetColor("darkred");
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Create the bar pot
$bplot = new Plot\PiePlot($datay);
// Setup color for gradient fill style
// Set color for the frame of each bar
$bplot->SetColor("white");
$graph->Add($bplot);
$graph->Stroke($filename);
}
}