From dc97d2f46b04be5e87a90eff770750fff8de02bc Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 30 Dec 2013 23:44:42 +0000 Subject: [PATCH] Improve fluent interface in charting methods --- Classes/PHPExcel/Chart/DataSeries.php | 10 +++++++++ Classes/PHPExcel/Chart/Layout.php | 30 ++++++++++++++++++++++++++- Classes/PHPExcel/Chart/PlotArea.php | 3 +++ Classes/PHPExcel/Chart/Title.php | 3 +++ Examples/runall.php | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Chart/DataSeries.php b/Classes/PHPExcel/Chart/DataSeries.php index 0822de3f..92588c7f 100644 --- a/Classes/PHPExcel/Chart/DataSeries.php +++ b/Classes/PHPExcel/Chart/DataSeries.php @@ -170,9 +170,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Type * * @param string $plotType + * @return PHPExcel_Chart_DataSeries */ public function setPlotType($plotType = '') { $this->_plotType = $plotType; + return $this; } /** @@ -188,9 +190,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Grouping Type * * @param string $groupingType + * @return PHPExcel_Chart_DataSeries */ public function setPlotGrouping($groupingType = null) { $this->_plotGrouping = $groupingType; + return $this; } /** @@ -206,9 +210,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Direction * * @param string $plotDirection + * @return PHPExcel_Chart_DataSeries */ public function setPlotDirection($plotDirection = null) { $this->_plotDirection = $plotDirection; + return $this; } /** @@ -281,9 +287,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Style * * @param string $plotStyle + * @return PHPExcel_Chart_DataSeries */ public function setPlotStyle($plotStyle = null) { $this->_plotStyle = $plotStyle; + return $this; } /** @@ -332,9 +340,11 @@ class PHPExcel_Chart_DataSeries * Set Smooth Line * * @param boolean $smoothLine + * @return PHPExcel_Chart_DataSeries */ public function setSmoothLine($smoothLine = TRUE) { $this->_smoothLine = $smoothLine; + return $this; } public function refresh(PHPExcel_Worksheet $worksheet) { diff --git a/Classes/PHPExcel/Chart/Layout.php b/Classes/PHPExcel/Chart/Layout.php index 8401245c..7c37ef92 100644 --- a/Classes/PHPExcel/Chart/Layout.php +++ b/Classes/PHPExcel/Chart/Layout.php @@ -167,9 +167,11 @@ class PHPExcel_Chart_Layout * Set Layout Target * * @param Layout Target $value + * @return PHPExcel_Chart_Layout */ public function setLayoutTarget($value) { $this->_layoutTarget = $value; + return $this; } /** @@ -185,9 +187,11 @@ class PHPExcel_Chart_Layout * Set X-Mode * * @param X-Mode $value + * @return PHPExcel_Chart_Layout */ public function setXMode($value) { $this->_xMode = $value; + return $this; } /** @@ -203,9 +207,11 @@ class PHPExcel_Chart_Layout * Set Y-Mode * * @param Y-Mode $value + * @return PHPExcel_Chart_Layout */ public function setYMode($value) { $this->_yMode = $value; + return $this; } /** @@ -221,9 +227,11 @@ class PHPExcel_Chart_Layout * Set X-Position * * @param X-Position $value + * @return PHPExcel_Chart_Layout */ public function setXPosition($value) { $this->_xPos = $value; + return $this; } /** @@ -239,9 +247,11 @@ class PHPExcel_Chart_Layout * Set Y-Position * * @param Y-Position $value + * @return PHPExcel_Chart_Layout */ public function setYPosition($value) { $this->_yPos = $value; + return $this; } /** @@ -257,9 +267,11 @@ class PHPExcel_Chart_Layout * Set Width * * @param Width $value + * @return PHPExcel_Chart_Layout */ public function setWidth($value) { $this->_width = $value; + return $this; } /** @@ -275,9 +287,11 @@ class PHPExcel_Chart_Layout * Set Height * * @param Height $value + * @return PHPExcel_Chart_Layout */ public function setHeight($value) { $this->_height = $value; + return $this; } @@ -295,9 +309,11 @@ class PHPExcel_Chart_Layout * Specifies that legend keys should be shown in data labels. * * @param boolean $value Show legend key + * @return PHPExcel_Chart_Layout */ public function setShowLegendKey($value) { $this->_showLegendKey = $value; + return $this; } /** @@ -314,9 +330,11 @@ class PHPExcel_Chart_Layout * Specifies that the value should be shown in data labels. * * @param boolean $value Show val + * @return PHPExcel_Chart_Layout */ public function setShowVal($value) { $this->_showVal = $value; + return $this; } /** @@ -333,9 +351,11 @@ class PHPExcel_Chart_Layout * Specifies that the category name should be shown in data labels. * * @param boolean $value Show cat name + * @return PHPExcel_Chart_Layout */ public function setShowCatName($value) { $this->_showCatName = $value; + return $this; } /** @@ -351,10 +371,12 @@ class PHPExcel_Chart_Layout * Set show ser name * Specifies that the series name should be shown in data labels. * - * @param boolean $value Show ser name + * @param boolean $value Show series name + * @return PHPExcel_Chart_Layout */ public function setShowSerName($value) { $this->_showSerName = $value; + return $this; } /** @@ -371,9 +393,11 @@ class PHPExcel_Chart_Layout * Specifies that the percentage should be shown in data labels. * * @param boolean $value Show percentage + * @return PHPExcel_Chart_Layout */ public function setShowPercent($value) { $this->_showPercent = $value; + return $this; } /** @@ -390,9 +414,11 @@ class PHPExcel_Chart_Layout * Specifies that the bubble size should be shown in data labels. * * @param boolean $value Show bubble size + * @return PHPExcel_Chart_Layout */ public function setShowBubbleSize($value) { $this->_showBubbleSize = $value; + return $this; } /** @@ -409,9 +435,11 @@ class PHPExcel_Chart_Layout * Specifies that leader lines should be shown in data labels. * * @param boolean $value Show leader lines + * @return PHPExcel_Chart_Layout */ public function setShowLeaderLines($value) { $this->_showLeaderLines = $value; + return $this; } } diff --git a/Classes/PHPExcel/Chart/PlotArea.php b/Classes/PHPExcel/Chart/PlotArea.php index 2975c093..cc512cde 100644 --- a/Classes/PHPExcel/Chart/PlotArea.php +++ b/Classes/PHPExcel/Chart/PlotArea.php @@ -111,9 +111,12 @@ class PHPExcel_Chart_PlotArea * Set Plot Series * * @param [PHPExcel_Chart_DataSeries] + * @return PHPExcel_Chart_PlotArea */ public function setPlotSeries($plotSeries = array()) { $this->_plotSeries = $plotSeries; + + return $this; } public function refresh(PHPExcel_Worksheet $worksheet) { diff --git a/Classes/PHPExcel/Chart/Title.php b/Classes/PHPExcel/Chart/Title.php index cacfae34..0883a219 100644 --- a/Classes/PHPExcel/Chart/Title.php +++ b/Classes/PHPExcel/Chart/Title.php @@ -72,9 +72,12 @@ class PHPExcel_Chart_Title * Set caption * * @param string $caption + * @return PHPExcel_Chart_Title */ public function setCaption($caption = null) { $this->_caption = $caption; + + return $this; } /** diff --git a/Examples/runall.php b/Examples/runall.php index 4d2e207f..d4124939 100644 --- a/Examples/runall.php +++ b/Examples/runall.php @@ -92,6 +92,7 @@ $aTests = array( , '34chartupdate.php' , '35chartrender.php' , '36chartreadwriteHTML.php' + , '36chartreadwritePDF.php' , '37page_layout_view.php' , '38cloneWorksheet.php' , '40duplicateStyle.php'