1<?php 2/** 3 * Matomo - free/libre analytics platform 4 * 5 * @link https://matomo.org 6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later 7 * 8 */ 9namespace Piwik\Plugins\ImageGraph\StaticGraph; 10 11use CpChart\Data; 12use Piwik\Plugins\ImageGraph\StaticGraph; 13 14/** 15 * 16 */ 17class Exception extends StaticGraph 18{ 19 const MESSAGE_RIGHT_MARGIN = 5; 20 21 /** 22 * @var \Exception 23 */ 24 private $exception; 25 26 public function setException(\Exception $exception) 27 { 28 $this->exception = $exception; 29 } 30 31 protected function getDefaultColors() 32 { 33 return array(); 34 } 35 36 public function setWidth($width) 37 { 38 if (empty($width)) { 39 $width = 450; 40 } 41 parent::setWidth($width); 42 } 43 44 public function setHeight($height) 45 { 46 if (empty($height)) { 47 $height = 300; 48 } 49 parent::setHeight($height); 50 } 51 52 public function renderGraph() 53 { 54 $this->pData = new Data(); 55 56 $message = $this->exception->getMessage(); 57 list($textWidth, $textHeight) = $this->getTextWidthHeight($message); 58 59 if ($this->width == null) { 60 $this->width = $textWidth + self::MESSAGE_RIGHT_MARGIN; 61 } 62 63 if ($this->height == null) { 64 $this->height = $textHeight; 65 } 66 67 $this->initpImage(); 68 69 $this->drawBackground(); 70 71 $this->pImage->drawText( 72 0, 73 $textHeight, 74 $message, 75 $this->textColor 76 ); 77 } 78} 79