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