chart = $chart; $this->title = $title; $this->width = (int)$width; $this->height = (int)$height; $this->attributes = $attributes; } /** * @return string */ public function render() { return sprintf( '
%s' . '
' . ' ' . ' ' . '
' . '
', $this->renderAttributes(), $this->renderTitle(), uniqid(null, false), $this->width, $this->height, $this->chart->toJson() ); } /** * @return string */ protected function renderAttributes() { $result = ''; foreach ($this->attributes as $key => $value) { $result .= sprintf(' %s="%s"', $key, $value); } return trim($result); } /** * @return string */ protected function renderTitle() { if (empty($this->title)) { return ''; } return sprintf('
%s
', $this->title); } }