PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/fsn-site-central/library/PHPExcel/Chart/DataSeries.php

https://gitlab.com/team_fsn/fsn-php
PHP | 365 lines | 152 code | 38 blank | 175 comment | 12 complexity | e7076e005301be41adf52a58e0824be7 MD5 | raw file
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Chart
  23. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.8.0, 2014-03-02
  26. */
  27. /**
  28. * PHPExcel_Chart_DataSeries
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Chart
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Chart_DataSeries
  35. {
  36. const TYPE_BARCHART = 'barChart';
  37. const TYPE_BARCHART_3D = 'bar3DChart';
  38. const TYPE_LINECHART = 'lineChart';
  39. const TYPE_LINECHART_3D = 'line3DChart';
  40. const TYPE_AREACHART = 'areaChart';
  41. const TYPE_AREACHART_3D = 'area3DChart';
  42. const TYPE_PIECHART = 'pieChart';
  43. const TYPE_PIECHART_3D = 'pie3DChart';
  44. const TYPE_DOUGHTNUTCHART = 'doughnutChart';
  45. const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
  46. const TYPE_SCATTERCHART = 'scatterChart';
  47. const TYPE_SURFACECHART = 'surfaceChart';
  48. const TYPE_SURFACECHART_3D = 'surface3DChart';
  49. const TYPE_RADARCHART = 'radarChart';
  50. const TYPE_BUBBLECHART = 'bubbleChart';
  51. const TYPE_STOCKCHART = 'stockChart';
  52. const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
  53. const GROUPING_CLUSTERED = 'clustered';
  54. const GROUPING_STACKED = 'stacked';
  55. const GROUPING_PERCENT_STACKED = 'percentStacked';
  56. const GROUPING_STANDARD = 'standard';
  57. const DIRECTION_BAR = 'bar';
  58. const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
  59. const DIRECTION_COL = 'col';
  60. const DIRECTION_COLUMN = self::DIRECTION_COL;
  61. const DIRECTION_VERTICAL = self::DIRECTION_COL;
  62. const STYLE_LINEMARKER = 'lineMarker';
  63. const STYLE_SMOOTHMARKER = 'smoothMarker';
  64. const STYLE_MARKER = 'marker';
  65. const STYLE_FILLED = 'filled';
  66. /**
  67. * Series Plot Type
  68. *
  69. * @var string
  70. */
  71. private $_plotType = null;
  72. /**
  73. * Plot Grouping Type
  74. *
  75. * @var boolean
  76. */
  77. private $_plotGrouping = null;
  78. /**
  79. * Plot Direction
  80. *
  81. * @var boolean
  82. */
  83. private $_plotDirection = null;
  84. /**
  85. * Plot Style
  86. *
  87. * @var string
  88. */
  89. private $_plotStyle = null;
  90. /**
  91. * Order of plots in Series
  92. *
  93. * @var array of integer
  94. */
  95. private $_plotOrder = array();
  96. /**
  97. * Plot Label
  98. *
  99. * @var array of PHPExcel_Chart_DataSeriesValues
  100. */
  101. private $_plotLabel = array();
  102. /**
  103. * Plot Category
  104. *
  105. * @var array of PHPExcel_Chart_DataSeriesValues
  106. */
  107. private $_plotCategory = array();
  108. /**
  109. * Smooth Line
  110. *
  111. * @var string
  112. */
  113. private $_smoothLine = null;
  114. /**
  115. * Plot Values
  116. *
  117. * @var array of PHPExcel_Chart_DataSeriesValues
  118. */
  119. private $_plotValues = array();
  120. /**
  121. * Create a new PHPExcel_Chart_DataSeries
  122. */
  123. public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null)
  124. {
  125. $this->_plotType = $plotType;
  126. $this->_plotGrouping = $plotGrouping;
  127. $this->_plotOrder = $plotOrder;
  128. $keys = array_keys($plotValues);
  129. $this->_plotValues = $plotValues;
  130. if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
  131. $plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
  132. }
  133. $this->_plotLabel = $plotLabel;
  134. if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
  135. $plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
  136. }
  137. $this->_plotCategory = $plotCategory;
  138. $this->_smoothLine = $smoothLine;
  139. $this->_plotStyle = $plotStyle;
  140. }
  141. /**
  142. * Get Plot Type
  143. *
  144. * @return string
  145. */
  146. public function getPlotType() {
  147. return $this->_plotType;
  148. }
  149. /**
  150. * Set Plot Type
  151. *
  152. * @param string $plotType
  153. * @return PHPExcel_Chart_DataSeries
  154. */
  155. public function setPlotType($plotType = '') {
  156. $this->_plotType = $plotType;
  157. return $this;
  158. }
  159. /**
  160. * Get Plot Grouping Type
  161. *
  162. * @return string
  163. */
  164. public function getPlotGrouping() {
  165. return $this->_plotGrouping;
  166. }
  167. /**
  168. * Set Plot Grouping Type
  169. *
  170. * @param string $groupingType
  171. * @return PHPExcel_Chart_DataSeries
  172. */
  173. public function setPlotGrouping($groupingType = null) {
  174. $this->_plotGrouping = $groupingType;
  175. return $this;
  176. }
  177. /**
  178. * Get Plot Direction
  179. *
  180. * @return string
  181. */
  182. public function getPlotDirection() {
  183. return $this->_plotDirection;
  184. }
  185. /**
  186. * Set Plot Direction
  187. *
  188. * @param string $plotDirection
  189. * @return PHPExcel_Chart_DataSeries
  190. */
  191. public function setPlotDirection($plotDirection = null) {
  192. $this->_plotDirection = $plotDirection;
  193. return $this;
  194. }
  195. /**
  196. * Get Plot Order
  197. *
  198. * @return string
  199. */
  200. public function getPlotOrder() {
  201. return $this->_plotOrder;
  202. }
  203. /**
  204. * Get Plot Labels
  205. *
  206. * @return array of PHPExcel_Chart_DataSeriesValues
  207. */
  208. public function getPlotLabels() {
  209. return $this->_plotLabel;
  210. }
  211. /**
  212. * Get Plot Label by Index
  213. *
  214. * @return PHPExcel_Chart_DataSeriesValues
  215. */
  216. public function getPlotLabelByIndex($index) {
  217. $keys = array_keys($this->_plotLabel);
  218. if (in_array($index,$keys)) {
  219. return $this->_plotLabel[$index];
  220. } elseif(isset($keys[$index])) {
  221. return $this->_plotLabel[$keys[$index]];
  222. }
  223. return false;
  224. }
  225. /**
  226. * Get Plot Categories
  227. *
  228. * @return array of PHPExcel_Chart_DataSeriesValues
  229. */
  230. public function getPlotCategories() {
  231. return $this->_plotCategory;
  232. }
  233. /**
  234. * Get Plot Category by Index
  235. *
  236. * @return PHPExcel_Chart_DataSeriesValues
  237. */
  238. public function getPlotCategoryByIndex($index) {
  239. $keys = array_keys($this->_plotCategory);
  240. if (in_array($index,$keys)) {
  241. return $this->_plotCategory[$index];
  242. } elseif(isset($keys[$index])) {
  243. return $this->_plotCategory[$keys[$index]];
  244. }
  245. return false;
  246. }
  247. /**
  248. * Get Plot Style
  249. *
  250. * @return string
  251. */
  252. public function getPlotStyle() {
  253. return $this->_plotStyle;
  254. }
  255. /**
  256. * Set Plot Style
  257. *
  258. * @param string $plotStyle
  259. * @return PHPExcel_Chart_DataSeries
  260. */
  261. public function setPlotStyle($plotStyle = null) {
  262. $this->_plotStyle = $plotStyle;
  263. return $this;
  264. }
  265. /**
  266. * Get Plot Values
  267. *
  268. * @return array of PHPExcel_Chart_DataSeriesValues
  269. */
  270. public function getPlotValues() {
  271. return $this->_plotValues;
  272. }
  273. /**
  274. * Get Plot Values by Index
  275. *
  276. * @return PHPExcel_Chart_DataSeriesValues
  277. */
  278. public function getPlotValuesByIndex($index) {
  279. $keys = array_keys($this->_plotValues);
  280. if (in_array($index,$keys)) {
  281. return $this->_plotValues[$index];
  282. } elseif(isset($keys[$index])) {
  283. return $this->_plotValues[$keys[$index]];
  284. }
  285. return false;
  286. }
  287. /**
  288. * Get Number of Plot Series
  289. *
  290. * @return integer
  291. */
  292. public function getPlotSeriesCount() {
  293. return count($this->_plotValues);
  294. }
  295. /**
  296. * Get Smooth Line
  297. *
  298. * @return boolean
  299. */
  300. public function getSmoothLine() {
  301. return $this->_smoothLine;
  302. }
  303. /**
  304. * Set Smooth Line
  305. *
  306. * @param boolean $smoothLine
  307. * @return PHPExcel_Chart_DataSeries
  308. */
  309. public function setSmoothLine($smoothLine = TRUE) {
  310. $this->_smoothLine = $smoothLine;
  311. return $this;
  312. }
  313. public function refresh(PHPExcel_Worksheet $worksheet) {
  314. foreach($this->_plotValues as $plotValues) {
  315. if ($plotValues !== NULL)
  316. $plotValues->refresh($worksheet, TRUE);
  317. }
  318. foreach($this->_plotLabel as $plotValues) {
  319. if ($plotValues !== NULL)
  320. $plotValues->refresh($worksheet, TRUE);
  321. }
  322. foreach($this->_plotCategory as $plotValues) {
  323. if ($plotValues !== NULL)
  324. $plotValues->refresh($worksheet, FALSE);
  325. }
  326. }
  327. }