DataSeries.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. /**
  8. * PHPExcel_Chart_DataSeries
  9. *
  10. * @category PHPExcel
  11. * @package PHPExcel_Chart
  12. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  13. */
  14. class PHPExcel_Chart_DataSeries
  15. {
  16. const TYPE_BARCHART = 'barChart';
  17. const TYPE_BARCHART_3D = 'bar3DChart';
  18. const TYPE_LINECHART = 'lineChart';
  19. const TYPE_LINECHART_3D = 'line3DChart';
  20. const TYPE_AREACHART = 'areaChart';
  21. const TYPE_AREACHART_3D = 'area3DChart';
  22. const TYPE_PIECHART = 'pieChart';
  23. const TYPE_PIECHART_3D = 'pie3DChart';
  24. const TYPE_DOUGHTNUTCHART = 'doughnutChart';
  25. const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
  26. const TYPE_SCATTERCHART = 'scatterChart';
  27. const TYPE_SURFACECHART = 'surfaceChart';
  28. const TYPE_SURFACECHART_3D = 'surface3DChart';
  29. const TYPE_RADARCHART = 'radarChart';
  30. const TYPE_BUBBLECHART = 'bubbleChart';
  31. const TYPE_STOCKCHART = 'stockChart';
  32. const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
  33. const GROUPING_CLUSTERED = 'clustered';
  34. const GROUPING_STACKED = 'stacked';
  35. const GROUPING_PERCENT_STACKED = 'percentStacked';
  36. const GROUPING_STANDARD = 'standard';
  37. const DIRECTION_BAR = 'bar';
  38. const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
  39. const DIRECTION_COL = 'col';
  40. const DIRECTION_COLUMN = self::DIRECTION_COL;
  41. const DIRECTION_VERTICAL = self::DIRECTION_COL;
  42. const STYLE_LINEMARKER = 'lineMarker';
  43. const STYLE_SMOOTHMARKER = 'smoothMarker';
  44. const STYLE_MARKER = 'marker';
  45. const STYLE_FILLED = 'filled';
  46. /**
  47. * Series Plot Type
  48. *
  49. * @var string
  50. */
  51. private $plotType;
  52. /**
  53. * Plot Grouping Type
  54. *
  55. * @var boolean
  56. */
  57. private $plotGrouping;
  58. /**
  59. * Plot Direction
  60. *
  61. * @var boolean
  62. */
  63. private $plotDirection;
  64. /**
  65. * Plot Style
  66. *
  67. * @var string
  68. */
  69. private $plotStyle;
  70. /**
  71. * Order of plots in Series
  72. *
  73. * @var array of integer
  74. */
  75. private $plotOrder = array();
  76. /**
  77. * Plot Label
  78. *
  79. * @var array of PHPExcel_Chart_DataSeriesValues
  80. */
  81. private $plotLabel = array();
  82. /**
  83. * Plot Category
  84. *
  85. * @var array of PHPExcel_Chart_DataSeriesValues
  86. */
  87. private $plotCategory = array();
  88. /**
  89. * Smooth Line
  90. *
  91. * @var string
  92. */
  93. private $smoothLine;
  94. /**
  95. * Plot Values
  96. *
  97. * @var array of PHPExcel_Chart_DataSeriesValues
  98. */
  99. private $plotValues = array();
  100. /**
  101. * Create a new PHPExcel_Chart_DataSeries
  102. */
  103. public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null)
  104. {
  105. $this->plotType = $plotType;
  106. $this->plotGrouping = $plotGrouping;
  107. $this->plotOrder = $plotOrder;
  108. $keys = array_keys($plotValues);
  109. $this->plotValues = $plotValues;
  110. if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
  111. $plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
  112. }
  113. $this->plotLabel = $plotLabel;
  114. if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
  115. $plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
  116. }
  117. $this->plotCategory = $plotCategory;
  118. $this->smoothLine = $smoothLine;
  119. $this->plotStyle = $plotStyle;
  120. if (is_null($plotDirection)) {
  121. $plotDirection = self::DIRECTION_COL;
  122. }
  123. $this->plotDirection = $plotDirection;
  124. }
  125. /**
  126. * Get Plot Type
  127. *
  128. * @return string
  129. */
  130. public function getPlotType()
  131. {
  132. return $this->plotType;
  133. }
  134. /**
  135. * Set Plot Type
  136. *
  137. * @param string $plotType
  138. * @return PHPExcel_Chart_DataSeries
  139. */
  140. public function setPlotType($plotType = '')
  141. {
  142. $this->plotType = $plotType;
  143. return $this;
  144. }
  145. /**
  146. * Get Plot Grouping Type
  147. *
  148. * @return string
  149. */
  150. public function getPlotGrouping()
  151. {
  152. return $this->plotGrouping;
  153. }
  154. /**
  155. * Set Plot Grouping Type
  156. *
  157. * @param string $groupingType
  158. * @return PHPExcel_Chart_DataSeries
  159. */
  160. public function setPlotGrouping($groupingType = null)
  161. {
  162. $this->plotGrouping = $groupingType;
  163. return $this;
  164. }
  165. /**
  166. * Get Plot Direction
  167. *
  168. * @return string
  169. */
  170. public function getPlotDirection()
  171. {
  172. return $this->plotDirection;
  173. }
  174. /**
  175. * Set Plot Direction
  176. *
  177. * @param string $plotDirection
  178. * @return PHPExcel_Chart_DataSeries
  179. */
  180. public function setPlotDirection($plotDirection = null)
  181. {
  182. $this->plotDirection = $plotDirection;
  183. return $this;
  184. }
  185. /**
  186. * Get Plot Order
  187. *
  188. * @return string
  189. */
  190. public function getPlotOrder()
  191. {
  192. return $this->plotOrder;
  193. }
  194. /**
  195. * Get Plot Labels
  196. *
  197. * @return array of PHPExcel_Chart_DataSeriesValues
  198. */
  199. public function getPlotLabels()
  200. {
  201. return $this->plotLabel;
  202. }
  203. /**
  204. * Get Plot Label by Index
  205. *
  206. * @return PHPExcel_Chart_DataSeriesValues
  207. */
  208. public function getPlotLabelByIndex($index)
  209. {
  210. $keys = array_keys($this->plotLabel);
  211. if (in_array($index, $keys)) {
  212. return $this->plotLabel[$index];
  213. } elseif (isset($keys[$index])) {
  214. return $this->plotLabel[$keys[$index]];
  215. }
  216. return false;
  217. }
  218. /**
  219. * Get Plot Categories
  220. *
  221. * @return array of PHPExcel_Chart_DataSeriesValues
  222. */
  223. public function getPlotCategories()
  224. {
  225. return $this->plotCategory;
  226. }
  227. /**
  228. * Get Plot Category by Index
  229. *
  230. * @return PHPExcel_Chart_DataSeriesValues
  231. */
  232. public function getPlotCategoryByIndex($index)
  233. {
  234. $keys = array_keys($this->plotCategory);
  235. if (in_array($index, $keys)) {
  236. return $this->plotCategory[$index];
  237. } elseif (isset($keys[$index])) {
  238. return $this->plotCategory[$keys[$index]];
  239. }
  240. return false;
  241. }
  242. /**
  243. * Get Plot Style
  244. *
  245. * @return string
  246. */
  247. public function getPlotStyle()
  248. {
  249. return $this->plotStyle;
  250. }
  251. /**
  252. * Set Plot Style
  253. *
  254. * @param string $plotStyle
  255. * @return PHPExcel_Chart_DataSeries
  256. */
  257. public function setPlotStyle($plotStyle = null)
  258. {
  259. $this->plotStyle = $plotStyle;
  260. return $this;
  261. }
  262. /**
  263. * Get Plot Values
  264. *
  265. * @return array of PHPExcel_Chart_DataSeriesValues
  266. */
  267. public function getPlotValues()
  268. {
  269. return $this->plotValues;
  270. }
  271. /**
  272. * Get Plot Values by Index
  273. *
  274. * @return PHPExcel_Chart_DataSeriesValues
  275. */
  276. public function getPlotValuesByIndex($index)
  277. {
  278. $keys = array_keys($this->plotValues);
  279. if (in_array($index, $keys)) {
  280. return $this->plotValues[$index];
  281. } elseif (isset($keys[$index])) {
  282. return $this->plotValues[$keys[$index]];
  283. }
  284. return false;
  285. }
  286. /**
  287. * Get Number of Plot Series
  288. *
  289. * @return integer
  290. */
  291. public function getPlotSeriesCount()
  292. {
  293. return count($this->plotValues);
  294. }
  295. /**
  296. * Get Smooth Line
  297. *
  298. * @return boolean
  299. */
  300. public function getSmoothLine()
  301. {
  302. return $this->smoothLine;
  303. }
  304. /**
  305. * Set Smooth Line
  306. *
  307. * @param boolean $smoothLine
  308. * @return PHPExcel_Chart_DataSeries
  309. */
  310. public function setSmoothLine($smoothLine = true)
  311. {
  312. $this->smoothLine = $smoothLine;
  313. return $this;
  314. }
  315. public function refresh(PHPExcel_Worksheet $worksheet)
  316. {
  317. foreach ($this->plotValues as $plotValues) {
  318. if ($plotValues !== null) {
  319. $plotValues->refresh($worksheet, true);
  320. }
  321. }
  322. foreach ($this->plotLabel as $plotValues) {
  323. if ($plotValues !== null) {
  324. $plotValues->refresh($worksheet, true);
  325. }
  326. }
  327. foreach ($this->plotCategory as $plotValues) {
  328. if ($plotValues !== null) {
  329. $plotValues->refresh($worksheet, false);
  330. }
  331. }
  332. }
  333. }