17 require_once SQ_CORE_PACKAGE_PATH.
'/files/image/image_edit_fns.inc';
37 public $graph_types = Array(
38 'Image_Graph_Plot_Bar',
39 'Image_Graph_Plot_Line',
40 'Image_Graph_Plot_Area',
41 'Image_Graph_Plot_Smoothed_Line',
42 'Image_Graph_Plot_Smoothed_Area',
43 'Image_Graph_Plot_Pie',
44 'Image_Graph_Plot_Step',
45 'Image_Graph_Plot_Impulse',
46 'Image_Graph_Plot_Dot',
47 'Image_Graph_Plot_Radar',
48 'Image_Graph_Plot_CandleStick',
49 'Image_Graph_Plot_Band',
56 public $fill_grad_types = Array(
57 'none' =>
'-- Leave Empty --',
58 'IMAGE_GRAPH_GRAD_VERTICAL' =>
'Vertically',
59 'IMAGE_GRAPH_GRAD_HORIZONTAL' =>
'Horizontally',
60 'IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED' =>
'Mirrored Vertically (the color grades from a-b-a vertically)',
61 'IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED' =>
'Mirrored Horizontally (the color grades from a-b-a horizontally)',
62 'IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR' =>
'Diagonally from top-left to right-bottom',
63 'IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR' =>
'Diagonally from bottom-left to top-right',
64 'IMAGE_GRAPH_GRAD_RADIAL' =>
'Radially (concentric circles in the center)',
72 public $marker_types = Array(
73 'none' =>
'-- Leave Empty --',
74 'Image_Graph_Marker_Asterisk' =>
'Mark Asterisk For A Dataset',
75 'Image_Graph_Marker_Average' =>
'Mark Average For A Dataset',
76 'Image_Graph_Marker_Box' =>
'Mark Box For A Dataset',
77 'Image_Graph_Marker_Cross' =>
'Mark Cross For A Dataset',
78 'Image_Graph_Marker_Diamond' =>
'Mark Diamond For A Dataset',
79 'Image_Graph_Marker_Plus' =>
'Mark Plus For A Dataset',
80 'Image_Graph_Marker_Star' =>
'Mark Star For A Dataset',
81 'Image_Graph_Marker_Triangle' =>
'Mark Triangle For A Dataset',
82 'Image_Graph_Marker_Value' =>
'Mark Value For A Dataset',
83 'Image_Graph_Marker_Bubble' =>
'Mark Bubble For A Dataset',
90 public $value_marker_types = Array(
91 'IMAGE_GRAPH_VALUE_X' =>
'Mark x-Axis Values',
92 'IMAGE_GRAPH_VALUE_Y' =>
'Mark y-Axis Values',
99 public $pointing_types = Array(
100 'none' =>
'-- Leave Empty --',
101 'Image_Graph_Marker_Pointing_Angular' =>
'Image_Graph_Marker_Pointing_Angular',
102 'Image_Graph_Marker_Pointing_Radial' =>
'Image_Graph_Marker_Pointing_Radial',
103 'Image_Graph_Marker_ReversePinpoint' =>
'Image_Graph_Marker_ReversePinpoint',
113 parent::__construct();
133 $wa = $asset->writeAccess(
'attributes');
135 $o->openField(
'Name');
136 text_box($prefix.
'_new_name',
'',
'20',
'20');
138 $o->openField(
'Data Source');
139 asset_finder($prefix.
'_new_data_source', 0, Array(
'data_source_db' =>
'I',
'data_source_rss' =>
'I'));
143 $datasets = $asset->attr(
'datasets');
144 $plot_order = $asset->attr(
'plot_order');
145 if (!empty($datasets)) {
146 $o->openField(
'Current Plots');
147 echo
'<table class="sq-backend-table">';
150 <td>Data Source</td>';
151 if ($wa) echo
'<td>Delete?</td>';
153 foreach ($plot_order as $key => $plot_name) {
156 <td><?php echo $plot_name; ?></td>
157 <td><?php echo get_asset_tag_line($datasets[$plot_name][
'assetid']); ?></td>
161 check_box($prefix.
'_delete_plot_'.$plot_name, $plot_name);
171 $o->openField(
'Current Plots');
172 echo
'There is no plot.';
192 $datasets = $asset->attr(
'datasets');
193 $plot_order = $asset->attr(
'plot_order');
195 if (!empty($_POST[$prefix.
'_new_name']) && $_POST[$prefix.
'_new_data_source'][
'assetid'] !=
'0') {
196 $datasets = $asset->attr(
'datasets');
197 $dataset_assetid = $_POST[$prefix.
'_new_data_source'][
'assetid'];
201 $axis_default_val =
'Not saved';
202 $data_source_asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($dataset_assetid);
203 if (!is_null($data_source_asset)) {
204 $first_result = reset($data_source_asset->getResultSet(
'default'));
205 if (is_array($first_result)) {
206 $data = array_keys($first_result);
208 $axis_default_val = reset($data);
212 $datasets[$_POST[$prefix.
'_new_name']] = Array(
213 'assetid' => $dataset_assetid,
215 'plot_name' => $_POST[$prefix.
'_new_name'],
216 'display_name' => $_POST[$prefix.
'_new_name'],
217 'graph_type' =>
'Image_Graph_Plot_Bar',
218 'x_axis' => $axis_default_val,
219 'y_axis' => $axis_default_val,
221 'fill_colour' =>
'ffffff',
222 'gradient_type' =>
'none',
223 'gradient_1' =>
'000000',
224 'gradient_2' =>
'000000',
225 'line_colour' =>
'000000',
226 'marker_font_colour' =>
'ffffff',
227 'marker_line_colour' =>
'000000',
228 'marker_fill_colour' =>
'000000',
230 'use_stacked' => FALSE,
231 'marker_type' =>
'none',
232 'value_marker_type' =>
'IMAGE_GRAPH_VALUE_X',
233 'pointer_type' =>
'none',
234 'pointer_length' => 20,
238 $index = count($plot_order);
239 $plot_order[$index] = $_POST[$prefix.
'_new_name'];
243 $_POST[$prefix.
'_plot_name'] = $index;
244 $_POST[$prefix.
'_prev_plot_name'] = $index;
247 if (!empty($datasets)) {
248 foreach ($datasets as $key => $dataset) {
249 if (isset($_POST[$prefix.
'_delete_plot_'.str_replace(
' ',
'_', $key)]) && !empty($_POST[$prefix.
'_delete_plot_'.str_replace(
' ',
'_', $key)])) {
250 unset($datasets[$key]);
251 unset($plot_order[array_search($key, $plot_order)]);
254 if (!empty($datasets)) {
255 $keys = array_keys($plot_order);
256 ksort($keys, SORT_NUMERIC);
259 $new_plot_order = Array();
260 foreach ($keys as $key) {
261 $new_plot_order[$index] = $plot_order[$key];
264 $plot_order = $new_plot_order;
270 $asset->setAttrValue(
'datasets', $datasets);
271 $asset->setAttrValue(
'plot_order', $plot_order);
289 $plot_order = $asset->attr(
'plot_order');
290 $o->openField(
'Choose a plot');
292 $plot_name = isset($_POST[$prefix.
'_plot_name']) ? $_POST[$prefix.
'_plot_name'] :
'0';
294 combo_box($prefix.
'_plot_name', $plot_order, FALSE, $plot_name);
296 <br /><b>Note</b> : If you choose a plot other than one displayed below and submit, then the current changes in the plot settings <b>WILL NOT</b> be applied,
297 i.e. If you want to submit the changes in the plot settings, <b>DO NOT</b> choose a
new plot here
299 hidden_field($prefix.
'_prev_plot_name', $plot_name);
335 $wa = $asset->writeAccess(
'attributes');
336 $datasets = $asset->attr(
'datasets');
337 $plot_order = $asset->attr(
'plot_order');
339 if (isset($_POST[$prefix.
'_plot_name'])) {
340 $plot_not_deleted = !empty($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
341 if ($plot_not_deleted) {
342 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
344 $plot_name = $plot_order[0];
347 $plot_name = $plot_order[0];
350 $data_source_asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($datasets[$plot_name][
'assetid']);
351 $result = $data_source_asset->getResultSet(
'default');
352 $data = array_keys($result[0]);
353 foreach ($data as $field) {
354 $fields[$field] = $field;
357 $o->openField(
'Plot Name');
358 echo
'<b>'.$plot_name.
'</b>';
362 $o->openField(
'Display Name');
363 if (empty($datasets[$plot_name][
'settings'][
'display_name']) || $datasets[$plot_name][
'settings'][
'display_name'] == $plot_name) {
364 $display_name = $plot_name;
366 $display_name = $datasets[$plot_name][
'settings'][
'display_name'];
368 text_box($prefix.
'_display_name', $display_name);
371 $o->openField(
'Move the plot');
372 combo_box($prefix.
'_move_this_plot', Array(0 =>
'-- Leave Empty --', 1 =>
'Backward', 2 =>
'Forward'), FALSE, 0);
374 <br /><b>Note</b> : You can move
this plot <b>backward</b> or <b>forward</b> as shown in the
final graph
378 $o->openField(
'Data Source');
379 asset_finder($prefix.
'_data_source', !empty($datasets[$plot_name][
'assetid']) ? $datasets[$plot_name][
'assetid'] :
'0', Array(
'data_source_db' =>
'I',
'data_source_rss' =>
'I'));
381 $o->openField(translate(
'choose').
' x-Axis');
382 combo_box($prefix.
'_x_axis', $fields, FALSE, empty($datasets[$plot_name][
'settings'][
'x_axis']) ? current($fields) : $datasets[$plot_name][
'settings'][
'x_axis']);
384 $o->openField(translate(
'choose').
' y-Axis');
385 combo_box($prefix.
'_y_axis', $fields, FALSE, empty($datasets[$plot_name][
'settings'][
'y_axis']) ? current($fields) : $datasets[$plot_name][
'settings'][
'y_axis']);
387 $o->openField(translate(
'choose').
' '.translate(
'graph_type'));
388 combo_box($prefix.
'_graph_type', $this->graph_types, FALSE, array_search($datasets[$plot_name][
'settings'][
'graph_type'], $this->graph_types));
390 $o->openField(
'Accumulative?');
391 combo_box($prefix.
'_accumulative', Array(1 =>
'Yes', 0 =>
'No'), FALSE, $datasets[$plot_name][
'settings'][
'accumulative']);
393 <br /><b>Note</b> : If it
's yes, y-Axis values are accumulated
395 hidden_field($prefix.'_plot_settings_submit
', '1
');
398 $o->openField('Fill
Colour');
399 colour_box($prefix.'_fill_colour
', empty($datasets[$plot_name]['settings
']['fill_colour
']) ? 'ffffff
' : $datasets[$plot_name]['settings
']['fill_colour
']);
401 $o->openField('Line
Colour');
402 colour_box($prefix.'_line_colour
', empty($datasets[$plot_name]['settings
']['line_colour
']) ? '000000
' : $datasets[$plot_name]['settings
']['line_colour
']);
404 $o->openField('Fill Gradient Type
');
405 combo_box($prefix.'_gradient_type
', $this->fill_grad_types, FALSE, $datasets[$plot_name]['settings
']['gradient_type
']);
407 <br /><b>Note</b> : If the type is set other than 'Leave Empty
', a fill colour is ignored
410 $o->openField('Gradient
Colour 1
');
411 colour_box($prefix.'_gradient_1
', empty($datasets[$plot_name]['settings
']['gradient_1
']) ? '000000
' : $datasets[$plot_name]['settings
']['gradient_1
']);
413 $o->openField('Gradient
Colour 2
');
414 colour_box($prefix.'_gradient_2
', empty($datasets[$plot_name]['settings
']['gradient_2
']) ? '000000
' : $datasets[$plot_name]['settings
']['gradient_2
']);
419 $o->openField('Display Name
');
420 echo $datasets[$plot_name]['settings
']['display_name
'];
422 $o->openField('Data Source
');
423 echo get_asset_tag_line($datasets[$plot_name]['assetid
']);
425 $o->openField('x-Axis
');
426 echo $datasets[$plot_name]['settings
']['x_axis
'];
428 $o->openField('y-Axis
');
429 echo $datasets[$plot_name]['settings
']['y_axis
'];
431 $o->openField('Type of Graph
');
432 echo $datasets[$plot_name]['settings
']['graph_type
'];
434 $o->openField('Accumulative
');
435 echo (intval($datasets[$plot_name]['settings
']['accumulative
'])) ? 'Yes
' : 'No
';
437 <br /><b>Note</b> : If it's yes, y-Axis values are accumulated
440 $o->openField(
'Fill Colour');
441 if (empty($datasets[$plot_name][
'settings'][
'fill_colour'])) {
445 <td width="20" height="13" style="background-color: #'.$datasets[$plot_name][
'settings'][
'fill_colour'].
'"></td>
446 <td> #'.$datasets[$plot_name][
'settings'][
'fill_colour'].
'</td>
450 $o->openField(
'Line Colour');
451 if (empty($datasets[$plot_name][
'settings'][
'line_colour'])) {
455 <td width="20" height="13" style="background-color: #'.$datasets[$plot_name][
'settings'][
'line_colour'].
'"></td>
456 <td> #'.$datasets[$plot_name][
'settings'][
'line_colour'].
'</td>
460 $o->openField(
'Fill Gradient Type');
461 echo $datasets[$plot_name][
'settings'][
'gradient_type'];
463 <br /><b>Note</b> : If the type is
set other than
'Leave Empty', a fill colour is ignored
466 $o->openField(
'Gradient Colour 1');
467 if (empty($datasets[$plot_name][
'settings'][
'gradient_1'])) {
471 <td width="20" height="13" style="background-color: #'.$datasets[$plot_name][
'settings'][
'gradient_1'].
'"></td>
472 <td> #'.$datasets[$plot_name][
'settings'][
'gradient_1'].
'</td>
476 $o->openField(
'Gradient Colour 2');
477 if (empty($datasets[$plot_name][
'settings'][
'gradient_2'])) {
481 <td width="20" height="13" style="background-color: #'.$datasets[$plot_name][
'settings'][
'gradient_2'].
'"></td>
482 <td> #'.$datasets[$plot_name][
'settings'][
'gradient_2'].
'</td>
505 $plot_settings_submit = isset($_POST[$prefix.
'_plot_settings_submit']);
506 $wa = $asset->writeAccess(
'attributes');
507 if ($wa && $plot_settings_submit) {
508 $datasets = $asset->attr(
'datasets');
509 $plot_order = $asset->attr(
'plot_order');
511 $plot_not_deleted = isset($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
512 $plot_changed = ($_POST[$prefix.
'_plot_name'] !== $_POST[$prefix.
'_prev_plot_name']);
514 if (!$plot_changed && $plot_not_deleted) {
515 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
516 $datasets[$plot_name][
'assetid'] = $_POST[$prefix.
'_data_source'][
'assetid'];
517 $datasets[$plot_name][
'settings'][
'display_name'] = $_POST[$prefix.
'_display_name'];
518 $datasets[$plot_name][
'settings'][
'x_axis'] = $_POST[$prefix.
'_x_axis'];
519 $datasets[$plot_name][
'settings'][
'y_axis'] = $_POST[$prefix.
'_y_axis'];
520 $datasets[$plot_name][
'settings'][
'graph_type'] = $this->graph_types[intval($_POST[$prefix.
'_graph_type'])];
521 $datasets[$plot_name][
'settings'][
'accumulative'] = $_POST[$prefix.
'_accumulative'];
522 $datasets[$plot_name][
'settings'][
'fill_colour'] = $_POST[$prefix.
'_fill_colour'];
523 $datasets[$plot_name][
'settings'][
'line_colour'] = $_POST[$prefix.
'_line_colour'];
524 $datasets[$plot_name][
'settings'][
'gradient_type'] = $_POST[$prefix.
'_gradient_type'];
525 $datasets[$plot_name][
'settings'][
'gradient_1'] = $_POST[$prefix.
'_gradient_1'];
526 $datasets[$plot_name][
'settings'][
'gradient_2'] = $_POST[$prefix.
'_gradient_2'];
527 if (isset($_POST[$prefix.
'_bar_spacing'])) {
528 $datasets[$plot_name][
'settings'][
'bar_spacing'] = $_POST[$prefix.
'_bar_spacing'];
530 $asset->setAttrValue(
'datasets', $datasets);
533 if (isset($_POST[$prefix.
'_move_this_plot']) && $_POST[$prefix.
'_move_this_plot'] !=
'0') {
535 $current_index = array_search($plot_name, $plot_order);
538 switch ($_POST[$prefix.
'_move_this_plot']) {
541 if ($current_index > 0) {
542 $dest_index = $current_index - 1;
548 if ($current_index < (count($plot_order) - 1)) {
549 $dest_index = $current_index + 1;
555 $dest_value = $plot_order[$dest_index];
556 $current_value = $plot_order[$current_index];
557 $plot_order[$dest_index] = $current_value;
558 $plot_order[$current_index] = $dest_value;
559 $asset->setAttrValue(
'plot_order', $plot_order);
563 $_POST[$prefix.
'_plot_name'] = $dest_index;
564 $_POST[$prefix.
'_prev_plot_name'] = $dest_index;
589 $wa = $asset->writeAccess(
'attributes');
590 $datasets = $asset->attr(
'datasets');
591 $plot_order = $asset->attr(
'plot_order');
592 if (isset($_POST[$prefix.
'_plot_name'])) {
593 $plot_not_deleted = !empty($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
594 if ($plot_not_deleted) {
595 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
597 $plot_name = $plot_order[0];
600 $plot_name = $plot_order[0];
603 $data_source_asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($datasets[$plot_name][
'assetid']);
604 $result = $data_source_asset->getResultSet(
'default');
605 $data = array_keys($result[0]);
606 foreach ($data as $field) {
607 $fields[$field] = $field;
610 $plot_type = $datasets[$plot_name][
'settings'][
'graph_type'];
612 switch ($plot_type) {
613 case 'Image_Graph_Plot_Bar' :
614 case 'Image_Graph_Plot_Area' :
615 $o->openField(
'Spacing');
616 text_box($prefix.
'_bar_spacing', empty($datasets[$plot_name][
'settings'][
'bar_spacing']) ?
'0' : $datasets[$plot_name][
'settings'][
'bar_spacing'],
'10');
618 $o->openField(
'Stacked');
619 check_box($prefix.
'_use_stacked',
'1', isset($datasets[$plot_name][
'settings'][
'use_stacked']) ? $datasets[$plot_name][
'settings'][
'use_stacked'] : FALSE);
620 $o->note(
'Do you want to use stacked bar graph?');
622 <table
class=
"sq-backend-table">
624 <td>Title and Data Source</td>
625 <td>Gradient Details</td>
626 <?php
if ($wa) echo
'<td>Delete?</td>'; ?>
631 if (!empty($datasets[$plot_name][
'settings'][
'stacked_data'])) {
632 foreach ($datasets[$plot_name][
'settings'][
'stacked_data'] as $key => $stack_data) {
636 Title : <?php text_box($prefix.
'_stacked_'.strval($key).
'_title', $stack_data[
'title'], 50); ?><br />
638 asset_finder($prefix.
'_stacked_'.strval($key).
'_datasource', $stack_data[
'datasource'], Array(
'data_source_db' =>
'I',
'data_source_rss' =>
'I'));
640 if (!empty($stack_data[
'datasource'])) {
641 $data_source_asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($stack_data[
'datasource']);
642 $result = $data_source_asset->getResultSet(
'default');
643 $data = array_keys($result[0]);
644 foreach ($data as $field) {
645 $fields[$field] = $field;
648 echo
'x-axis : ';
649 combo_box($prefix.
'_stacked_'.strval($key).
'_x_axis', $fields, FALSE, $stack_data[
'x_axis']);
650 echo
'<br />y-axis : ';
651 combo_box($prefix.
'_stacked_'.strval($key).
'_y_axis', $fields, FALSE, $stack_data[
'y_axis']);
655 <?php combo_box($prefix.
'_stacked_'.strval($key).
'_gradient_type', $this->fill_grad_types, FALSE, $stack_data[
'gradient_type']); ?><br />
656 <?php colour_box($prefix.
'_stacked_'.strval($key).
'_gradient_colour_2', $stack_data[
'colour_1']); ?>Gradient
Colour 1<br />
657 <?php colour_box($prefix.
'_stacked_'.strval($key).
'_gradient_colour_1', $stack_data[
'colour_2']); ?>Gradient
Colour 2<br />
662 check_box($prefix.
'_stacked_'.strval($key).
'_delete',
'1', FALSE);
675 Title : <?php text_box($prefix.
'_stacked_'.strval($key).
'_title',
'', 50); ?><br />
676 <?php asset_finder($prefix.
'_stacked_'.strval($key).
'_datasource', 0, Array(
'data_source_db' =>
'I',
'data_source_rss' =>
'I')); ?>
679 <?php combo_box($prefix.
'_stacked_'.strval($key).
'_gradient_type', $this->fill_grad_types, FALSE,
'none'); ?><br />
680 <?php colour_box($prefix.
'_stacked_'.strval($key).
'_gradient_colour_1',
'000000'); ?>Gradient
Colour 1<br />
681 <?php colour_box($prefix.
'_stacked_'.strval($key).
'_gradient_colour_2',
'000000'); ?>Gradient
Colour 2<br />
687 $o->note(
'Note: If the gradient option is not chosen, the first colour is used to fill the bar.');
690 case 'Image_Graph_Plot_Line' :
691 case 'Image_Graph_Plot_Smoothed_Area' :
692 case 'Image_Graph_Plot_Smoothed_Line' :
693 case 'Image_Graph_Plot_Pie' :
694 case 'Image_Graph_Plot_Step' :
695 case 'Image_Graph_Plot_Impulse' :
696 case 'Image_Graph_Plot_Dot' :
697 case 'Image_Graph_Plot_Radar' :
698 case 'Image_Graph_Plot_CandleStick' :
699 case 'Image_Graph_Plot_Band' :
707 switch ($plot_type) {
708 case 'Image_Graph_Plot_Bar' :
709 $o->openField(
'Spacing');
710 echo $datasets[$plot_name][
'settings'][
'bar_spacing'];
712 $o->openField(
'Stacked');
715 case 'Image_Graph_Plot_Line' :
716 case 'Image_Graph_Plot_Area' :
717 case 'Image_Graph_Plot_Smoothed_Line' :
718 case 'Image_Graph_Plot_Smoothed_Area' :
719 case 'Image_Graph_Plot_Pie' :
720 case 'Image_Graph_Plot_Step' :
721 case 'Image_Graph_Plot_Impulse' :
722 case 'Image_Graph_Plot_Dot' :
723 case 'Image_Graph_Plot_Radar' :
724 case 'Image_Graph_Plot_CandleStick' :
725 case 'Image_Graph_Plot_Band' :
726 $o->openField(
'None');
750 $plot_settings_submit = isset($_POST[$prefix.
'_plot_settings_submit']);
751 $wa = $asset->writeAccess(
'attributes');
752 if ($wa && $plot_settings_submit) {
753 $datasets = $asset->attr(
'datasets');
754 $plot_order = $asset->attr(
'plot_order');
756 $plot_not_deleted = isset($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
757 $plot_changed = ($_POST[$prefix.
'_plot_name'] != $_POST[$prefix.
'_prev_plot_name']);
759 if (!$plot_changed && $plot_not_deleted) {
760 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
761 $plot_type = $datasets[$plot_name][
'settings'][
'graph_type'];
762 switch ($plot_type) {
763 case 'Image_Graph_Plot_Bar' :
764 case 'Image_Graph_Plot_Area' :
765 if (isset($_POST[$prefix.
'_bar_spacing'])) {
766 $datasets[$plot_name][
'settings'][
'bar_spacing'] = $_POST[$prefix.
'_bar_spacing'];
768 $datasets[$plot_name][
'settings'][
'use_stacked'] = isset($_POST[$prefix.
'_use_stacked']);
770 if (!empty($datasets[$plot_name][
'settings'][
'stacked_data'])) {
772 foreach ($datasets[$plot_name][
'settings'][
'stacked_data'] as $key => $stack_data) {
773 if (isset($_POST[$prefix.
'_stacked_'.strval($key).
'_delete'])) {
774 unset($datasets[$plot_name][
'settings'][
'stacked_data'][$key]);
775 unset($_POST[$prefix.
'_stacked_'.strval($key).
'_datasource']);
778 if (!empty($datasets[$plot_name][
'settings'][
'stacked_data'])) {
779 foreach ($datasets[$plot_name][
'settings'][
'stacked_data'] as $key => $stack_data) {
780 if (isset($_POST[$prefix.
'_stacked_'.strval($key).
'_title'])) {
781 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'title'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_title'];
782 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'datasource'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_datasource'][
'assetid'];
783 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'colour_1'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_gradient_colour_1'];
784 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'colour_2'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_gradient_colour_2'];
785 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'gradient_type'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_gradient_type'];
786 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'x_axis'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_x_axis'];
787 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'y_axis'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_y_axis'];
795 if (!empty($_POST[$prefix.
'_stacked_'.strval($key).
'_datasource']) && $_POST[$prefix.
'_stacked_'.strval($key).
'_datasource'][
'assetid'] !=
'0') {
796 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'title'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_title'];
797 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'datasource'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_datasource'][
'assetid'];
798 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'colour_1'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_gradient_colour_1'];
799 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'colour_2'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_gradient_colour_2'];
800 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'gradient_type'] = $_POST[$prefix.
'_stacked_'.strval($key).
'_gradient_type'];
802 $data_source_asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($_POST[$prefix.
'_stacked_'.strval($key).
'_datasource'][
'assetid']);
803 $result = $data_source_asset->getResultSet(
'default');
804 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'x_axis'] = array_pop(array_keys($result[0]));
805 $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'y_axis'] = $datasets[$plot_name][
'settings'][
'stacked_data'][$key][
'x_axis'];
808 case 'Image_Graph_Plot_Line' :
809 case 'Image_Graph_Plot_Smoothed_Area' :
810 case 'Image_Graph_Plot_Smoothed_Line' :
811 case 'Image_Graph_Plot_Pie' :
812 case 'Image_Graph_Plot_Step' :
813 case 'Image_Graph_Plot_Impulse' :
814 case 'Image_Graph_Plot_Dot' :
815 case 'Image_Graph_Plot_Radar' :
816 case 'Image_Graph_Plot_CandleStick' :
817 case 'Image_Graph_Plot_Band' :
823 $asset->setAttrValue(
'datasets', $datasets);
846 $wa = $asset->writeAccess(
'attributes');
847 $datasets = $asset->attr(
'datasets');
848 $plot_order = $asset->attr(
'plot_order');
850 if (isset($_POST[$prefix.
'_plot_name'])) {
851 $plot_not_deleted = !empty($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
852 if ($plot_not_deleted) {
853 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
856 $plot_name = array_pop(array_keys($datasets));
860 $plot_name = array_pop(array_keys($datasets));
864 $data_source_asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($datasets[$plot_name][
'assetid']);
865 $result = $data_source_asset->getResultSet(
'default');
866 $data = array_keys($result[0]);
867 foreach ($data as $field) {
868 $fields[$field] = $field;
872 'Set Font Colour' =>
'marker_font_colour',
873 'Set Line Colour' =>
'marker_line_colour',
874 'Set Fill Colour' =>
'marker_fill_colour',
877 $o->openField(
'Choose The Type Of Marker');
878 combo_box($prefix.
'_marker_type', $this->marker_types, FALSE, empty($datasets[$plot_name][
'settings'][
'marker_type']) ?
'none' : $datasets[$plot_name][
'settings'][
'marker_type']);
880 <br /><b>Note</b> : If you don
't want to use marker, leave this empty
883 $o->openField('Choose Value To be Marked On The Graph
');
884 combo_box($prefix.'_value_marker_type
', $this->value_marker_types, FALSE, empty($datasets[$plot_name]['settings
']['value_marker_type
']) ? 'none
' : $datasets[$plot_name]['settings
']['value_marker_type
']);
886 foreach ($colours as $field_title => $key) {
887 $o->openField($field_title);
888 colour_box($prefix.'_
'.$key, empty($datasets[$plot_name]['settings
'][$key]) ? '000000
' : $datasets[$plot_name]['settings
'][$key]);
891 $o->openField('Choose The Marker Pointer
');
892 combo_box($prefix.'_pointer_type
', $this->pointing_types, FALSE, empty($datasets[$plot_name]['settings
']['pointer_type
']) ? 'none
' : $datasets[$plot_name]['settings
']['pointer_type
']);
894 <br /><b>Note</b> : If you don't want to use pointer, leave
this empty
897 $o->openField(
'Set The Length Of The Pointer');
898 text_box($prefix.
'_pointer_length', empty($datasets[$plot_name][
'settings'][
'pointer_length']) ?
'20' : $datasets[$plot_name][
'settings'][
'pointer_length'], 5);
901 $o->openField(
'Choose The Type Of Marker');
902 echo $datasets[$plot_name][
'settings'][
'marker_type'];
904 $o->openField(
'Choose Value To be Marked On The Graph');
905 echo $datasets[$plot_name][
'settings'][
'value_marker_type'];
907 foreach ($colours as $field_title => $key) {
908 $o->openField($field_title);
909 if (empty($datasets[$plot_name][
'settings'][$key])) {
913 <td width="20" height="13" style="background-color: #'.$datasets[$plot_name][
'settings'][$key].
'"></td>
914 <td> #'.$datasets[$plot_name][
'settings'][$key].
'</td>
919 $o->openField(
'Choose The Marker Pointer');
920 echo $datasets[$plot_name][
'settings'][
'pointer_type'];
922 $o->openField(
'Set The Length Of The Pointer');
923 echo $datasets[$plot_name][
'settings'][
'pointer_length'];
943 $wa = $asset->writeAccess(
'attributes');
944 $plot_settings_submit = isset($_POST[$prefix.
'_plot_settings_submit']);
945 if ($wa && $plot_settings_submit) {
946 $datasets = $asset->attr(
'datasets');
947 $plot_order = $asset->attr(
'plot_order');
948 $plot_not_deleted = @isset($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
949 $plot_changed = ($_POST[$prefix.
'_plot_name'] != $_POST[$prefix.
'_prev_plot_name']);
950 if (!$plot_changed && $plot_not_deleted) {
951 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
952 $datasets[$plot_name][
'settings'][
'marker_type'] = $_POST[$prefix.
'_marker_type'];
953 $datasets[$plot_name][
'settings'][
'value_marker_type'] = $_POST[$prefix.
'_value_marker_type'];
954 $datasets[$plot_name][
'settings'][
'marker_font_colour'] = $_POST[$prefix.
'_marker_font_colour'];
955 $datasets[$plot_name][
'settings'][
'marker_line_colour'] = $_POST[$prefix.
'_marker_line_colour'];
956 $datasets[$plot_name][
'settings'][
'marker_fill_colour'] = $_POST[$prefix.
'_marker_fill_colour'];
957 $datasets[$plot_name][
'settings'][
'pointer_type'] = $_POST[$prefix.
'_pointer_type'];
958 $datasets[$plot_name][
'settings'][
'pointer_length'] = $_POST[$prefix.
'_pointer_length'];
959 $asset->setAttrValue(
'datasets', $datasets);
983 $href = $asset->getBackendHref(
'global_settings');
984 $width = $asset->attr(
'width');
985 $height = $asset->attr(
'height');
986 $alt = $asset->attr(
'alt');
987 $title = $asset->attr(
'title');
992 This graph is generated with <b>random dataset</b> to present the look and feel of the graph
995 The front end image <b>WILL NOT</b> be updated until a dataset is added.<br />i.e. the changes on
this screen is not shown in the front end unless a dataset is
set.
998 <img alt=
"<?php echo $alt; ?>" title=
"<?php echo $title; ?>" src=
"<?php echo $href.'&preview_graph=1' ?>" width=
"<?php echo $width; ?>" height=
"<?php echo $height; ?>" alt=
"" />
1035 $datasets = $asset->attr(
'datasets');
1036 $plot_order = $asset->attr(
'plot_order');
1037 $plot_not_deleted = @isset($datasets[$plot_order[intval($_POST[$prefix.
'_plot_name'])]]);
1038 if (!empty($_POST[$prefix.
'_plot_name']) && $plot_not_deleted) {
1039 $plot_name = $plot_order[intval($_POST[$prefix.
'_plot_name'])];
1041 $plot_name = $plot_order[0];
1043 if ($datasets[$plot_name][
'settings'][
'x_axis'] ==
'Not saved' || $datasets[$plot_name][
'settings'][
'y_axis'] ==
'Not saved') {
1045 <b>Not available</b> : Please
set both of x-Axis and y-Axis correctly<br />
1048 $graph_info = serialize($datasets[$plot_name]);
1049 $href = $asset->getBackendHref(
'datasets');
1050 $alt = $asset->attr(
'alt');
1051 $title = $asset->attr(
'title');
1053 <b>Note</b> : This graph is generated with <b>random dataset</b> to present the look and feel of the graph<br /><br />
1054 <img alt=
"<?php echo $alt; ?>" title=
"<?php echo $title; ?>" src=
"<?php echo $href.'&preview_graph=1&graph_info='.urlencode($graph_info) ?>" width=
"<?php echo $asset->attr('width'); ?>" height=
"<?php echo $asset->attr('height'); ?>" />
1091 $datasets = $asset->attr(
'datasets');
1094 foreach ($datasets as $name => $dataset) {
1095 if ($dataset[
'settings'][
'x_axis'] ==
'Not saved' || $dataset[
'settings'][
'y_axis'] ==
'Not saved') {
1103 <b>Not available</b> : Please
set both of x-Axis and y-Axis correctly for <?php echo implode(',', $not_set); ?><br />
1106 $href = $asset->getBackendHref(
'datasets');
1107 $alt = $asset->attr(
'alt');
1108 $title = $asset->attr(
'title');
1110 <b>Note</b> : This graph is the same as one that is printed on the frontend with <b>real datasets</b>.<br /><br />
1111 <img alt=
"<?php echo $alt; ?>" title=
"<?php echo $title; ?>" src=
"<?php echo $href.'&preview_graph=1&final_preview=1' ?>" width=
"<?php echo $asset->attr('width'); ?>" height=
"<?php echo $asset->attr('height'); ?>" alt=
"" />
1151 return $this->
_isMode($asset, $prefix,
'add');
1167 return $this->
_isMode($asset, $prefix,
'edit') &&
1185 $mode = $asset->attr(
'mode');
1186 return ($mode == $type);
1202 $datasets = $asset->attr(
'datasets');
1203 return !empty($datasets);
1219 return count($asset->attr(
'datasets')) > 1;