* @package Mammut\Chart */ class BarHistoryChart extends AbstractCoordinateChart { public function __construct() { $this->background = new Color(255, 255, 255); } public function render(iRenderer $renderer) { $renderer->start($this->width, $this->height, $this->background, iRenderer::HINT_LINE); $this->drawGrid($renderer, 10, 10, $this->width-15, $this->height-15); } // public function createImage($type = 'png') { // $image = imagecreatetruecolor($this->width, $this->height); // $bgColor = imagecolorexact($image, $this->background[0], $this->background[1], $this->background[2]); // imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), $bgColor); // $maxValueText = (string) $this->maxValue; // $numberSize = strlen($maxValueText) * imagefontwidth(1) + 5; // $lineColor = imagecolorexact($image, 0, 0, 0); // $barColor = imagecolorexact($image, 200, 0, 0); // $realWidth = $this->width - 20; // $barWidth = $realWidth / count($this->datalines[0]); // $x = 20; // $realHeight = $this->height - 20; // $size = ($barWidth - 2) / count($this->datalines); // foreach($this->datalines as $key=>$line) { // $x = 20; // $realHeight = $this->height - 20; // $lastX = 20; // $lastY = $realHeight; // $barColor = imagecolorexact($image, $this->lineColor[$key][0], $this->lineColor[$key][1], $this->lineColor[$key][2]); // foreach($line as $value) { // $realValue = round(($value / $this->maxValue) * $realHeight); // imagefilledrectangle($image, $x + 2 + ($size * $key), imagesy($image) - 20, $x + 2 + ($size * $key) + $size - 1, imagesy($image) - 20 - $realValue, $barColor); // $x += $barWidth; // } // } // // imageline ($image, 20, 0, 20, imagesy($image)-20, $lineColor); // // imageline ($image, imagesx($image), imagesy($image)-20, 20, imagesy($image)-20, $lineColor); // $this->drawGrid($image, 0, 0, imagesx($image), imagesy($image), $numberSize, 20); // ob_start(); // imagepng($image); // return ob_get_clean(); // } }