Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
0f03f337 | 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
32 | */ |
33 | ||
34 | require_once 'packages/OpenFlashChart/php-ofc-library/open-flash-chart.php'; | |
35 | ||
36 | /** | |
37 | * Build various graphs using Open Flash Chart library. | |
38 | */ | |
39 | class CRM_Utils_OpenFlashChart { | |
40 | ||
41 | /** | |
100fef9d | 42 | * Colours. |
6a488035 | 43 | * @var array |
6a488035 TO |
44 | */ |
45 | private static $_colours = array( | |
353ffa53 TO |
46 | "#C3CC38", |
47 | "#C8B935", | |
48 | "#CEA632", | |
49 | "#D3932F", | |
50 | "#D9802C", | |
51 | "#FA6900", | |
52 | "#DC9B57", | |
53 | "#F78F01", | |
54 | "#5AB56E", | |
55 | "#6F8069", | |
56 | "#C92200", | |
57 | "#EB6C5C", | |
6a488035 TO |
58 | ); |
59 | ||
60 | /** | |
61 | * Build The Bar Gharph. | |
62 | * | |
77855840 TO |
63 | * @param array $params |
64 | * Assoc array of name/value pairs. | |
6a488035 | 65 | * |
a6c01b45 CW |
66 | * @return object |
67 | * $chart object of open flash chart. | |
6a488035 | 68 | */ |
00be9182 | 69 | public static function &barChart(&$params) { |
6a488035 TO |
70 | $chart = NULL; |
71 | if (empty($params)) { | |
72 | return $chart; | |
73 | } | |
a7488080 | 74 | if (empty($params['multiValues'])) { |
0c98098b DS |
75 | $params['multiValues'] = array($params['values']); |
76 | } | |
6a488035 | 77 | |
0c98098b | 78 | $values = CRM_Utils_Array::value('multiValues', $params); |
6a488035 TO |
79 | if (!is_array($values) || empty($values)) { |
80 | return $chart; | |
81 | } | |
82 | ||
83 | // get the required data. | |
0d8afee2 | 84 | $chartTitle = !empty($params['legend']) ? $params['legend'] : ts('Bar Chart'); |
6a488035 | 85 | |
0c98098b DS |
86 | $xValues = $yValues = array(); |
87 | $xValues = array_keys($values[0]); | |
88 | $yValues = array_values($values[0]); | |
89 | ||
50bfb460 | 90 | // set y axis parameters. |
6a488035 TO |
91 | $yMin = 0; |
92 | ||
93 | // calculate max scale for graph. | |
94 | $yMax = ceil(max($yValues)); | |
95 | if ($mod = $yMax % (str_pad(5, strlen($yMax) - 1, 0))) { | |
96 | $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod; | |
97 | } | |
98 | $ySteps = $yMax / 5; | |
99 | ||
0c98098b | 100 | $bars = array(); |
6a488035 TO |
101 | $config = CRM_Core_Config::singleton(); |
102 | $symbol = $config->defaultCurrencySymbol; | |
0c98098b DS |
103 | foreach ($values as $barCount => $barVal) { |
104 | $bars[$barCount] = new bar_glass(); | |
6a488035 | 105 | |
0c98098b DS |
106 | $yValues = array_values($barVal); |
107 | foreach ($yValues as &$yVal) { | |
108 | // type casting is required for chart to render values correctly | |
109 | $yVal = (double) $yVal; | |
110 | } | |
111 | $bars[$barCount]->set_values($yValues); | |
112 | if ($barCount > 0) { | |
113 | // FIXME: for bars > 2, we'll need to come out with other colors | |
481a74f4 | 114 | $bars[$barCount]->colour('#BF3B69'); |
0c98098b | 115 | } |
d7797bc2 | 116 | |
0c98098b | 117 | if ($barKey = CRM_Utils_Array::value($barCount, CRM_Utils_Array::value('barKeys', $params))) { |
e7292422 | 118 | $bars[$barCount]->key($barKey, 12); |
0c98098b DS |
119 | } |
120 | ||
121 | // call user define function to handle on click event. | |
122 | if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) { | |
123 | $bars[$barCount]->set_on_click($onClickFunName); | |
124 | } | |
125 | ||
126 | // get the currency to set in tooltip. | |
127 | $tooltip = CRM_Utils_Array::value('tip', $params, "$symbol #val#"); | |
128 | $bars[$barCount]->set_tooltip($tooltip); | |
129 | } | |
6a488035 TO |
130 | |
131 | // create x axis label obj. | |
132 | $xLabels = new x_axis_labels(); | |
d7797bc2 | 133 | // set_labels function requires xValues array of string or x_axis_label |
5a0052f4 | 134 | // so type casting array values to string values |
353ffa53 | 135 | array_walk($xValues, function (&$value, $index) { |
e7292422 TO |
136 | $value = (string) $value; |
137 | }); | |
6a488035 TO |
138 | $xLabels->set_labels($xValues); |
139 | ||
140 | // set angle for labels. | |
141 | if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) { | |
142 | $xLabels->rotate($xLabelAngle); | |
143 | } | |
144 | ||
145 | // create x axis obj. | |
146 | $xAxis = new x_axis(); | |
147 | $xAxis->set_labels($xLabels); | |
148 | ||
50bfb460 | 149 | // create y axis and set range. |
6a488035 TO |
150 | $yAxis = new y_axis(); |
151 | $yAxis->set_range($yMin, $yMax, $ySteps); | |
152 | ||
153 | // create chart title obj. | |
154 | $title = new title($chartTitle); | |
155 | ||
156 | // create chart. | |
157 | $chart = new open_flash_chart(); | |
158 | ||
159 | // add x axis w/ labels to chart. | |
160 | $chart->set_x_axis($xAxis); | |
161 | ||
162 | // add y axis values to chart. | |
163 | $chart->add_y_axis($yAxis); | |
164 | ||
165 | // set title to chart. | |
166 | $chart->set_title($title); | |
167 | ||
168 | // add bar element to chart. | |
0c98098b DS |
169 | foreach ($bars as $bar) { |
170 | $chart->add_element($bar); | |
171 | } | |
6a488035 TO |
172 | |
173 | // add x axis legend. | |
174 | if ($xName = CRM_Utils_Array::value('xname', $params)) { | |
175 | $xLegend = new x_legend($xName); | |
176 | $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}"); | |
177 | $chart->set_x_legend($xLegend); | |
178 | } | |
179 | ||
180 | // add y axis legend. | |
181 | if ($yName = CRM_Utils_Array::value('yname', $params)) { | |
182 | $yLegend = new y_legend($yName); | |
183 | $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}"); | |
184 | $chart->set_y_legend($yLegend); | |
185 | } | |
186 | ||
187 | return $chart; | |
188 | } | |
189 | ||
190 | /** | |
191 | * Build The Pie Gharph. | |
192 | * | |
77855840 TO |
193 | * @param array $params |
194 | * Assoc array of name/value pairs. | |
6a488035 | 195 | * |
a6c01b45 CW |
196 | * @return object |
197 | * $chart object of open flash chart. | |
6a488035 | 198 | */ |
00be9182 | 199 | public static function &pieChart(&$params) { |
6a488035 TO |
200 | $chart = NULL; |
201 | if (empty($params)) { | |
202 | return $chart; | |
203 | } | |
204 | $allValues = CRM_Utils_Array::value('values', $params); | |
205 | if (!is_array($allValues) || empty($allValues)) { | |
206 | return $chart; | |
207 | } | |
208 | ||
209 | // get the required data. | |
210 | $values = array(); | |
211 | foreach ($allValues as $label => $value) { | |
e7292422 | 212 | $values[] = new pie_value((double) $value, $label); |
6a488035 | 213 | } |
0d8afee2 | 214 | $graphTitle = !empty($params['legend']) ? $params['legend'] : ts('Pie Chart'); |
6a488035 | 215 | |
50bfb460 | 216 | // get the currency. |
6a488035 TO |
217 | $config = CRM_Core_Config::singleton(); |
218 | $symbol = $config->defaultCurrencySymbol; | |
219 | ||
220 | $pie = new pie(); | |
221 | $pie->radius(100); | |
222 | ||
223 | // call user define function to handle on click event. | |
224 | if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) { | |
225 | $pie->on_click($onClickFunName); | |
226 | } | |
227 | ||
228 | $pie->set_start_angle(35); | |
229 | $pie->add_animation(new pie_fade()); | |
230 | $pie->add_animation(new pie_bounce(2)); | |
231 | ||
232 | // set the tooltip. | |
233 | $tooltip = CRM_Utils_Array::value('tip', $params, "Amount is $symbol #val# of $symbol #total# <br>#percent#"); | |
234 | $pie->set_tooltip($tooltip); | |
235 | ||
236 | // set colours. | |
237 | $pie->set_colours(self::$_colours); | |
238 | ||
239 | $pie->set_values($values); | |
240 | ||
50bfb460 | 241 | // create chart. |
6a488035 TO |
242 | $chart = new open_flash_chart(); |
243 | ||
244 | // create chart title obj. | |
245 | $title = new title($graphTitle); | |
246 | $chart->set_title($title); | |
247 | ||
248 | $chart->add_element($pie); | |
249 | $chart->x_axis = NULL; | |
250 | ||
251 | return $chart; | |
252 | } | |
253 | ||
254 | /** | |
255 | * Build The 3-D Bar Gharph. | |
256 | * | |
77855840 TO |
257 | * @param array $params |
258 | * Assoc array of name/value pairs. | |
6a488035 | 259 | * |
a6c01b45 CW |
260 | * @return object |
261 | * $chart object of open flash chart. | |
6a488035 | 262 | */ |
00be9182 | 263 | public static function &bar_3dChart(&$params) { |
6a488035 TO |
264 | $chart = NULL; |
265 | if (empty($params)) { | |
266 | return $chart; | |
267 | } | |
268 | ||
269 | // $params['values'] should contains the values for each | |
270 | // criteria defined in $params['criteria'] | |
271 | $values = CRM_Utils_Array::value('values', $params); | |
b44e3f84 DS |
272 | $criteria = CRM_Utils_Array::value('criteria', $params); |
273 | if (!is_array($values) || empty($values) || !is_array($criteria) || empty($criteria)) { | |
6a488035 TO |
274 | return $chart; |
275 | } | |
276 | ||
277 | // get the required data. | |
278 | $xReferences = $xValueLabels = $xValues = $yValues = array(); | |
279 | ||
280 | foreach ($values as $xVal => $yVal) { | |
281 | if (!is_array($yVal) || empty($yVal)) { | |
282 | continue; | |
283 | } | |
284 | ||
e7292422 | 285 | $xValueLabels[] = (string) $xVal; |
b44e3f84 | 286 | foreach ($criteria as $criteria) { |
e7292422 TO |
287 | $xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0); |
288 | $yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0); | |
6a488035 TO |
289 | } |
290 | } | |
291 | ||
292 | if (empty($xReferences)) { | |
293 | ||
294 | return $chart; | |
295 | ||
296 | } | |
297 | ||
298 | // get the currency. | |
299 | $config = CRM_Core_Config::singleton(); | |
300 | $symbol = $config->defaultCurrencySymbol; | |
301 | ||
302 | // set the tooltip. | |
303 | $tooltip = CRM_Utils_Array::value('tip', $params, "$symbol #val#"); | |
304 | ||
305 | $count = 0; | |
306 | foreach ($xReferences as $criteria => $values) { | |
307 | $toolTipVal = $tooltip; | |
b44e3f84 | 308 | // for separate tooltip for each criteria |
6a488035 TO |
309 | if (is_array($tooltip)) { |
310 | $toolTipVal = CRM_Utils_Array::value($criteria, $tooltip, "$symbol #val#"); | |
311 | } | |
312 | ||
313 | // create bar_3d object | |
314 | $xValues[$count] = new bar_3d(); | |
315 | // set colour pattel | |
316 | $xValues[$count]->set_colour(self::$_colours[$count]); | |
b44e3f84 | 317 | // define colur pattel with bar criteria |
e7292422 | 318 | $xValues[$count]->key((string) $criteria, 12); |
6a488035 TO |
319 | // define bar chart values |
320 | $xValues[$count]->set_values(array_values($values)); | |
321 | ||
322 | // set tooltip | |
323 | $xValues[$count]->set_tooltip($toolTipVal); | |
324 | $count++; | |
325 | } | |
326 | ||
0d8afee2 | 327 | $chartTitle = !empty($params['legend']) ? $params['legend'] : ts('Bar Chart'); |
6a488035 | 328 | |
50bfb460 | 329 | // set y axis parameters. |
6a488035 TO |
330 | $yMin = 0; |
331 | ||
332 | // calculate max scale for graph. | |
333 | $yMax = ceil(max($yValues)); | |
334 | if ($mod = $yMax % (str_pad(5, strlen($yMax) - 1, 0))) { | |
335 | $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod; | |
336 | } | |
337 | ||
338 | // if max value of y-axis <= 0, then set default values | |
339 | if ($yMax <= 0) { | |
340 | $ySteps = 1; | |
341 | $yMax = 5; | |
342 | } | |
343 | else { | |
344 | $ySteps = $yMax / 5; | |
345 | } | |
346 | ||
347 | // create x axis label obj. | |
348 | $xLabels = new x_axis_labels(); | |
349 | $xLabels->set_labels($xValueLabels); | |
350 | ||
351 | // set angle for labels. | |
352 | if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) { | |
353 | $xLabels->rotate($xLabelAngle); | |
354 | } | |
355 | ||
356 | // create x axis obj. | |
357 | $xAxis = new x_axis(); | |
358 | $xAxis->set_labels($xLabels); | |
359 | ||
50bfb460 | 360 | // create y axis and set range. |
6a488035 TO |
361 | $yAxis = new y_axis(); |
362 | $yAxis->set_range($yMin, $yMax, $ySteps); | |
363 | ||
364 | // create chart title obj. | |
365 | $title = new title($chartTitle); | |
366 | ||
367 | // create chart. | |
368 | $chart = new open_flash_chart(); | |
369 | ||
370 | // add x axis w/ labels to chart. | |
371 | $chart->set_x_axis($xAxis); | |
372 | ||
373 | // add y axis values to chart. | |
374 | $chart->add_y_axis($yAxis); | |
375 | ||
376 | // set title to chart. | |
377 | $chart->set_title($title); | |
378 | ||
379 | foreach ($xValues as $bar) { | |
380 | // add bar element to chart. | |
381 | $chart->add_element($bar); | |
382 | } | |
383 | ||
384 | // add x axis legend. | |
385 | if ($xName = CRM_Utils_Array::value('xname', $params)) { | |
386 | $xLegend = new x_legend($xName); | |
387 | $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}"); | |
388 | $chart->set_x_legend($xLegend); | |
389 | } | |
390 | ||
391 | // add y axis legend. | |
392 | if ($yName = CRM_Utils_Array::value('yname', $params)) { | |
393 | $yLegend = new y_legend($yName); | |
394 | $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}"); | |
395 | $chart->set_y_legend($yLegend); | |
396 | } | |
397 | ||
398 | return $chart; | |
399 | } | |
400 | ||
5bc392e6 EM |
401 | /** |
402 | * @param $rows | |
403 | * @param $chart | |
404 | * @param $interval | |
405 | * | |
406 | * @return array | |
407 | */ | |
00be9182 | 408 | public static function chart($rows, $chart, $interval) { |
891a34b4 | 409 | $lcInterval = strtolower($interval); |
410 | $label = ucfirst($lcInterval); | |
0c98098b | 411 | $chartData = $dateKeys = array(); |
891a34b4 | 412 | $intervalLabels = array( |
58f49704 | 413 | 'year' => ts('Yearly'), |
414 | 'fiscalyear' => ts('Yearly (Fiscal)'), | |
891a34b4 | 415 | 'month' => ts('Monthly'), |
416 | 'quarter' => ts('Quarterly'), | |
417 | 'week' => ts('Weekly'), | |
58f49704 | 418 | 'yearweek' => ts('Weekly'), |
891a34b4 | 419 | ); |
420 | ||
421 | switch ($lcInterval) { | |
422 | case 'month': | |
423 | case 'quarter': | |
424 | case 'week': | |
58f49704 | 425 | case 'yearweek': |
6a488035 TO |
426 | foreach ($rows['receive_date'] as $key => $val) { |
427 | list($year, $month) = explode('-', $val); | |
58f49704 | 428 | $dateKeys[] = substr($rows[$interval][$key], 0, 3) . ' of ' . $year; |
6a488035 | 429 | } |
891a34b4 | 430 | $legend = $intervalLabels[$lcInterval]; |
6a488035 TO |
431 | break; |
432 | ||
891a34b4 | 433 | default: |
6a488035 TO |
434 | foreach ($rows['receive_date'] as $key => $val) { |
435 | list($year, $month) = explode('-', $val); | |
0c98098b | 436 | $dateKeys[] = $year; |
6a488035 | 437 | } |
891a34b4 | 438 | $legend = ts("%1", array(1 => $label)); |
58f49704 | 439 | if (!empty($intervalLabels[$lcInterval])) { |
440 | $legend = $intervalLabels[$lcInterval]; | |
441 | } | |
6a488035 TO |
442 | break; |
443 | } | |
444 | ||
0c98098b DS |
445 | if (!empty($dateKeys)) { |
446 | $graph = array(); | |
447 | if (!array_key_exists('multiValue', $rows)) { | |
448 | $rows['multiValue'] = array($rows['value']); | |
449 | } | |
450 | foreach ($rows['multiValue'] as $key => $val) { | |
451 | $graph[$key] = array_combine($dateKeys, $rows['multiValue'][$key]); | |
452 | } | |
317fceb4 | 453 | $chartData = array( |
454 | 'legend' => "$legend " . CRM_Utils_Array::value('legend', $rows, ts('Contribution')) . ' ' . ts('Summary'), | |
455 | 'values' => $graph[0], | |
456 | 'multiValues' => $graph, | |
457 | 'barKeys' => CRM_Utils_Array::value('barKeys', $rows, array()), | |
458 | ); | |
0c98098b DS |
459 | } |
460 | ||
6a488035 | 461 | // rotate the x labels. |
0c98098b | 462 | $chartData['xLabelAngle'] = CRM_Utils_Array::value('xLabelAngle', $rows, 0); |
a7488080 | 463 | if (!empty($rows['tip'])) { |
6a488035 TO |
464 | $chartData['tip'] = $rows['tip']; |
465 | } | |
466 | ||
50bfb460 | 467 | // legend |
6a488035 TO |
468 | $chartData['xname'] = CRM_Utils_Array::value('xname', $rows); |
469 | $chartData['yname'] = CRM_Utils_Array::value('yname', $rows); | |
470 | ||
471 | // carry some chart params if pass. | |
472 | foreach (array( | |
353ffa53 TO |
473 | 'xSize', |
474 | 'ySize', | |
317fceb4 | 475 | 'divName', |
353ffa53 | 476 | ) as $f) { |
a7488080 | 477 | if (!empty($rows[$f])) { |
6a488035 TO |
478 | $chartData[$f] = $rows[$f]; |
479 | } | |
480 | } | |
481 | ||
482 | return self::buildChart($chartData, $chart); | |
483 | } | |
484 | ||
5bc392e6 EM |
485 | /** |
486 | * @param $rows | |
487 | * @param $chart | |
488 | * @param $interval | |
489 | * @param $chartInfo | |
490 | * | |
491 | * @return array | |
492 | */ | |
00be9182 | 493 | public static function reportChart($rows, $chart, $interval, &$chartInfo) { |
6a488035 TO |
494 | foreach ($interval as $key => $val) { |
495 | $graph[$val] = $rows['value'][$key]; | |
496 | } | |
497 | ||
498 | $chartData = array( | |
499 | 'values' => $graph, | |
500 | 'legend' => $chartInfo['legend'], | |
501 | 'xname' => $chartInfo['xname'], | |
502 | 'yname' => $chartInfo['yname'], | |
503 | ); | |
504 | ||
505 | // rotate the x labels. | |
506 | $chartData['xLabelAngle'] = CRM_Utils_Array::value('xLabelAngle', $chartInfo, 20); | |
a7488080 | 507 | if (!empty($chartInfo['tip'])) { |
6a488035 TO |
508 | $chartData['tip'] = $chartInfo['tip']; |
509 | } | |
510 | ||
511 | // carry some chart params if pass. | |
512 | foreach (array( | |
353ffa53 TO |
513 | 'xSize', |
514 | 'ySize', | |
317fceb4 | 515 | 'divName', |
353ffa53 | 516 | ) as $f) { |
a7488080 | 517 | if (!empty($rows[$f])) { |
6a488035 TO |
518 | $chartData[$f] = $rows[$f]; |
519 | } | |
520 | } | |
521 | ||
522 | return self::buildChart($chartData, $chart); | |
523 | } | |
524 | ||
5bc392e6 | 525 | /** |
c490a46a | 526 | * @param array $params |
5bc392e6 EM |
527 | * @param $chart |
528 | * | |
529 | * @return array | |
530 | */ | |
00be9182 | 531 | public static function buildChart(&$params, $chart) { |
6a488035 TO |
532 | $openFlashChart = array(); |
533 | if ($chart && is_array($params) && !empty($params)) { | |
534 | // build the chart objects. | |
0e6e8724 | 535 | $chartObj = CRM_Utils_OpenFlashChart::$chart($params); |
6a488035 TO |
536 | |
537 | $openFlashChart = array(); | |
538 | if ($chartObj) { | |
539 | // calculate chart size. | |
540 | $xSize = CRM_Utils_Array::value('xSize', $params, 400); | |
541 | $ySize = CRM_Utils_Array::value('ySize', $params, 300); | |
542 | if ($chart == 'barChart') { | |
543 | $ySize = CRM_Utils_Array::value('ySize', $params, 250); | |
544 | $xSize = 60 * count($params['values']); | |
50bfb460 | 545 | // hack to show tooltip. |
6a488035 TO |
546 | if ($xSize < 200) { |
547 | $xSize = (count($params['values']) > 1) ? 100 * count($params['values']) : 170; | |
548 | } | |
549 | elseif ($xSize > 600 && count($params['values']) > 1) { | |
550 | $xSize = (count($params['values']) + 400 / count($params['values'])) * count($params['values']); | |
551 | } | |
552 | } | |
553 | ||
554 | // generate unique id for this chart instance | |
555 | $uniqueId = md5(uniqid(rand(), TRUE)); | |
556 | ||
557 | $openFlashChart["chart_{$uniqueId}"]['size'] = array('xSize' => $xSize, 'ySize' => $ySize); | |
558 | $openFlashChart["chart_{$uniqueId}"]['object'] = $chartObj; | |
559 | ||
560 | // assign chart data to template | |
561 | $template = CRM_Core_Smarty::singleton(); | |
562 | $template->assign('uniqueId', $uniqueId); | |
563 | $template->assign("openFlashChartData", json_encode($openFlashChart)); | |
564 | } | |
565 | } | |
566 | ||
567 | return $openFlashChart; | |
568 | } | |
96025800 | 569 | |
6a488035 | 570 | } |