Автор: Nick Sagona, III (nick@popphp.org)
Пример #1
0
 /**
  * Method to calculate which quadrant a point is in.
  *
  * @param  array $point
  * @param  array $center
  * @return int
  */
 protected function getQuadrant($point, $center)
 {
     $quad = 0;
     if ($this->graph->adapter() instanceof \Pop\Pdf\Pdf) {
         if ($point['x'] >= $center['x']) {
             $quad = $point['y'] >= $center['y'] ? 4 : 1;
         } else {
             $quad = $point['y'] >= $center['y'] ? 3 : 2;
         }
     } else {
         if ($point['x'] >= $center['x']) {
             $quad = $point['y'] <= $center['y'] ? 4 : 1;
         } else {
             $quad = $point['y'] <= $center['y'] ? 3 : 2;
         }
     }
     return $quad;
 }
Пример #2
0
 public function testAddPieChart()
 {
     $pie = array('x' => 320, 'y' => 240, 'w' => 200, 'h' => 100);
     $percents = array(array(10, new Rgb(200, 15, 15)), array(8, new Rgb(80, 5, 10)), array(12, new Rgb(80, 180, 100)), array(18, new Rgb(50, 125, 210)), array(22, new Rgb(80, 180, 10)), array(18, new Rgb(100, 125, 210)), array(12, new Rgb(80, 180, 10)));
     $this->setExpectedException('Pop\\Http\\Exception');
     $g = new Graph($this->pdfOptions);
     $g->addFont('Arial')->setFontColor(new Rgb(128, 128, 128))->showText(true)->createPieChart($pie, $percents, 20)->output();
 }
Пример #3
0
<?php

require_once '../../bootstrap.php';
use Pop\Color\Space\Rgb;
use Pop\Graph\Graph;
try {
    $x = array('1995', '2000', '2005', '2010', '2015');
    $y = array('0M', '50M', '100M', '150M', '200M');
    $data = array(array(1995, 0), array(1997, 35), array(1998, 25), array(2002, 100), array(2004, 84), array(2006, 98), array(2007, 76), array(2010, 122), array(2012, 175), array(2015, 162));
    $graph = new Graph(array('filename' => 'graph.gif', 'width' => 640, 'height' => 480));
    $graph->addFont('../assets/fonts/times.ttf')->setFontColor(new Rgb(128, 128, 128))->setFillColor(new Rgb(10, 125, 210))->showY(true)->showText(true)->createLineGraph($data, $x, $y)->output();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Пример #4
0
<?php

require_once '../../bootstrap.php';
use Pop\Color\Space\Rgb;
use Pop\Graph\Graph;
try {
    $pie = array('x' => 320, 'y' => 240, 'w' => 200, 'h' => 100);
    $percents = array(array(10, new Rgb(200, 15, 15)), array(8, new Rgb(80, 5, 10)), array(12, new Rgb(80, 180, 100)), array(18, new Rgb(50, 125, 210)), array(22, new Rgb(80, 180, 10)), array(18, new Rgb(100, 125, 210)), array(12, new Rgb(80, 180, 10)));
    $graph = new Graph(array('filename' => 'graph.gif', 'width' => 640, 'height' => 480));
    $graph->addFont('../assets/fonts/times.ttf')->setFontColor(new Rgb(128, 128, 128))->showText(true)->createPieChart($pie, $percents, 20)->output();
} catch (\Exception $e) {
    echo $e->getMessage();
}