diff options
author | JulienMoumne <julien@piwik.org> | 2012-02-09 21:23:39 +0400 |
---|---|---|
committer | JulienMoumne <julien@piwik.org> | 2012-02-09 21:23:39 +0400 |
commit | 586387a008c90c517ea95831a3dd36ab5e1c5079 (patch) | |
tree | 0ee15c82a58a575905406a8940349251fceb78e6 /core/ReportRenderer.php | |
parent | a240a5c808de82187c987a2f4c73bbc2f22aadcd (diff) |
refs #2862 distinct static graph resolutions for portrait and landscape
git-svn-id: http://dev.piwik.org/svn/trunk@5792 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/ReportRenderer.php')
-rw-r--r-- | core/ReportRenderer.php | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php index 642161d786..87300cf685 100644 --- a/core/ReportRenderer.php +++ b/core/ReportRenderer.php @@ -116,16 +116,6 @@ abstract class Piwik_ReportRenderer abstract public function renderReport($processedReport); /** - * @param int height of the static graph drawn by the report renderer - */ - abstract public function getStaticGraphHeight(); - - /** - * @param int width of the static graph drawn by the report renderer - */ - abstract public function getStaticGraphWidth(); - - /** * Append $extension to $filename * * @static @@ -192,4 +182,32 @@ abstract class Piwik_ReportRenderer $reportColumns, ); } + + public static function getStaticGraph($imageGraphUrl, $width, $height) { + + $request = new Piwik_API_Request( + $imageGraphUrl . + '&outputType='.Piwik_ImageGraph_API::GRAPH_OUTPUT_PHP. + '&format=original&serialize=0'. + '&filter_truncate='. + '&width='.$width. + '&height='.$height + ); + + try { + $imageGraph = $request->process(); + + // Get image data as string + ob_start(); + imagepng($imageGraph); + $imageGraphData = ob_get_contents(); + ob_end_clean(); + imagedestroy($imageGraph); + + return $imageGraphData; + + } catch(Exception $e) { + throw new Exception("ImageGraph API returned an error: ".$e->getMessage()."\n"); + } + } } |