Example #1
0
function FusionCharts($chart_type = '', $width = "300", $height = "250")
{
    require_once 'fusion/FusionCharts_Gen.php';
    $FC = new FusionCharts($chart_type, $width, $height);
    $FC->setSWFPath(base_url() . "chart/");
    return $FC;
}
Example #2
0
 function makeBar($val, $IDSuffix)
 {
     //---------- Creating First Chart ----------------------------------------------
     # Create FusionCharts PHP object
     $FC = new FusionCharts("Column3D", "300", "250", "myChartId" . $IDSuffix);
     # set the relative path of the swf file
     $FC->setSWFPath("../../FusionCharts/");
     # Define chart attributes#  Set chart attributes
     $strParam = "caption=Weekly Sales;subcaption={$val};xAxisName=Week;yAxisName=Revenue;numberPrefix=\$";
     # Setting chart attributes
     $FC->setChartParams($strParam);
     # add chart values and category names for the First Chart
     $FC->addChartData("40800", "Label=Week 1");
     $FC->addChartData("31400", "Label=Week 2");
     $FC->addChartData("26700", "Label=Week 3");
     $FC->addChartData("54400", "Label=Week 4");
     //-------------------------------------------------------------------
     $FC->renderChart();
 }
Example #3
0
 private function getFusionChartFromDataArr($arr)
 {
     $FC = new FusionCharts("Column2D", "500", "350", null, true);
     $FC->setSWFPath("/fusionCharts_swf/");
     $strParam = "xAxisName=Rating;yAxisName=Number;decimalPrecision=0;formatNumberScale=1";
     $FC->setChartParams($strParam);
     if (isset($arr["NA"])) {
         $FC->addChartData($arr["NA"], "name=N/R");
     }
     $item = $arr["typeObj"];
     if ($item->getId() == EnumItemPeer::RATING_BOOLEAN) {
         for ($i = 0; $i < 2; $i++) {
             $FC->addChartData($arr[$i], "name={$i}");
         }
     } elseif ($item->getParentId() == EnumItemPeer::RATING_SCALE) {
         for ($i = 0; $i < $item->getDescr(); $i++) {
             $FC->addChartData($arr[$i], "name={$i}");
         }
     } else {
         // FIXME type not supported
         throw new Exception("type not supported");
     }
     return $FC;
 }
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Column2D chart Object
$FC = new FusionCharts("column2D", "300", "250");
# set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Define chart attributes
$strParam = "caption=Weekly Sales;xAxisName=Week;yAxisName=Revenue;numberPrefix=\$";
# Set chart attributes
$FC->setChartParams($strParam);
# add chart values and category names
$FC->addChartData("40800", "label=Week 1");
$FC->addChartData("31400", "label=Week 2");
$FC->addChartData("26700", "label=Week 3");
$FC->addChartData("54400", "label=Week 4");
# Add First TrendLine
$FC->addTrendLine("startValue=42000;color=ff0000");
# Add Second TrendLine
$FC->addTrendLine("startValue=30000;color=008800;displayvalue=Average;showOnTop=1");
# Add  TrendZone
$FC->addTrendLine("startValue=50000;endValue=60000;color=0000ff;alpha=20;displayvalue=Dream Sales;showOnTop=1;isTrendZone=1");
?>
<html>
  <head>
    <title>First Chart - Advanced - Add Trendlines : Using FusionCharts PHP Class</title>
    <script language='javascript' src='../FusionCharts/FusionCharts.js'></script>
  </head>
  <body>
Example #5
0
 function getFusionchart()
 {
     $document =& JFactory::getDocument();
     $params =& $this->getParams();
     $worker = new FabrikWorker();
     $fc_version = $params->get('fusionchart_version', 'free_old');
     if ($fc_version == 'free_22') {
         require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FusionChartsFree' . DS . 'Code' . DS . 'PHPClass' . DS . 'Includes' . DS . 'FusionCharts_Gen.php';
         $document->addScript($this->srcBase . "fusionchart/lib/FusionChartsFree/JSClass/FusionCharts.js");
         $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FusionChartsFree/Charts/";
     } else {
         if ($fc_version == 'pro_30') {
             require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FusionCharts' . DS . 'Code' . DS . 'PHPClass' . DS . 'Includes' . DS . 'FusionCharts_Gen.php';
             $document->addScript($this->srcBase . "fusionchart/lib/FusionCharts/Charts/FusionCharts.js");
             $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FusionCharts/Charts/";
         } else {
             require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FCclass' . DS . 'FusionCharts_Gen.php';
             $document->addScript($this->srcBase . "fusionchart/lib/FCcharts/FusionCharts.js");
             $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FCcharts/";
         }
     }
     $calc_prefixes = array('sum___', 'avg___', 'med___', 'cnt___');
     $calc_prefixmap = array('sum___' => 'sums', 'avg___' => 'avgs', 'med___' => 'medians', 'cnt___' => 'count');
     $w = $params->get('fusionchart_width');
     $h = $params->get('fusionchart_height');
     $chartType = $params->get('fusionchart_type');
     // Create new chart
     $FC = new FusionCharts("{$chartType}", "{$w}", "{$h}");
     //$FC->JSC["debugmode"]=true;
     // Define path to FC's SWF
     $FC->setSWFPath($fc_swf_path);
     $this->setChartMessages($FC);
     // Setting Param string
     $strParam = $this->getChartParams();
     $label_step_ratios = (array) $params->get('fusion_label_step_ratio');
     $x_axis_label = (array) $params->get('fusion_x_axis_label');
     $chartElements = (array) $params->get('fusionchart_elementList');
     $chartColours = (array) $params->get('fusionchart_colours');
     $listid = (array) $params->get('fusionchart_table');
     $axisLabels = (array) $params->get('fusionchart_axis_labels');
     foreach ($axisLabels as $axis_key => $axis_val) {
         //$worker->replaceRequest($axis_val);
         $axisLabels[$axis_key] = $worker->parseMessageForPlaceholder($axis_val, null, false);
     }
     $dual_y_parents = $params->get('fusionchart_dual_y_parent');
     $measurement_units = (array) $params->get('fusion_x_axis_measurement_unit');
     $legends = $params->get('fusiongraph_show_legend', '');
     $chartWheres = (array) $params->get('fusionchart_where');
     $c = 0;
     $gdata = array();
     $glabels = array();
     $gcolours = array();
     $gfills = array();
     $max = array();
     $min = array();
     $calculationLabels = array();
     $calculationData = array();
     $calcfound = false;
     $tmodels = array();
     $labelStep = 0;
     foreach ($listid as $tid) {
         $min[$c] = 0;
         $max[$c] = 0;
         if (!array_key_exists($tid, $tmodels)) {
             $listModel = null;
             $listModel = JModel::getInstance('list', 'FabrikFEModel');
             $listModel->setId($tid);
             $tmodels[$tid] = $listModel;
         } else {
             $listModel = $tmodels[$tid];
         }
         $table = $listModel->getTable();
         $form = $listModel->getForm();
         // $$$ hugh - adding plugin query, 2012-02-08
         if (array_key_exists($c, $chartWheres) && !empty($chartWheres[$c])) {
             $chartWhere = $this->_replaceRequest($chartWheres[$c]);
             $listModel->setPluginQueryWhere('fusionchart', $chartWhere);
         } else {
             // if no where clause, explicitly clear any previously set clause
             $listModel->unsetPluginQueryWhere('fusionchart');
         }
         // $$$ hugh - remove pagination BEFORE calling render().  Otherwise render() applies
         // session state/defaults when it calls getPagination, which is then returned as a cached
         // object if we call getPagination after render().  So call it first, then render() will
         // get our cached pagination, rather than vice versa.
         $nav = $listModel->getPagination(0, 0, 0);
         $listModel->render();
         //$listModel->doCalculations();
         $alldata = $listModel->getData();
         $cals = $listModel->getCalculations();
         $column = $chartElements[$c];
         //$measurement_unit = $measurement_units[$c];
         $measurement_unit = JArrayHelper::getValue($measurement_units, $c, '');
         $pref = substr($column, 0, 6);
         $label = JArrayHelper::getValue($x_axis_label, $c, '');
         $tmpgdata = array();
         $tmpglabels = array();
         $colour = array_key_exists($c, $chartColours) ? str_replace("#", '', $chartColours[$c]) : '';
         $gcolours[] = $colour;
         if (in_array($pref, $calc_prefixes)) {
             // you shouldnt mix calculation elements with normal elements when creating the chart
             // so if ONE calculation element is found we use the calculation data rather than normal element data
             // this is because a calculation element only generates one value, if want to compare two averages then
             //they get rendered as tow groups of data and on bar charts this overlays one average over the other, rather than next to it
             $calcfound = true;
             $column = substr($column, 6);
             $calckey = $calc_prefixmap[$pref];
             $caldata = JArrayHelper::getValue($cals[$calckey], $column . '_obj');
             if (is_array($caldata)) {
                 foreach ($caldata as $k => $o) {
                     $calculationData[] = (double) $o->value;
                     $calculationLabels[] = trim(strip_tags($o->label));
                 }
             }
             if (!empty($calculationData)) {
                 $max[$c] = max($calculationData);
                 $min[$c] = min($calculationData);
             }
             $gdata[$c] = implode(',', $tmpgdata);
             $glabels[$c] = implode('|', $tmpglabels);
             // $$$ hugh - playing around with pie charts
             //$gsums[$c] = array_sum($tmpgdata);
             $gsums[$c] = array_sum($calculationData);
         } else {
             $origColumn = $column;
             $column = $column . "_raw";
             //_raw fields are most likely to contain the value
             foreach ($alldata as $group) {
                 foreach ($group as $row) {
                     if (!array_key_exists($column, $row)) {
                         //didnt find a _raw column - revent to orig
                         $column = $origColumn;
                         if (!array_key_exists($column, $row)) {
                             JError::raiseWarning(E_NOTICE, $column . ': NOT FOUND - PLEASE CHECK IT IS PUBLISHED');
                             continue;
                         }
                     }
                     if (trim($row->{$column}) == '') {
                         $tmpgdata[] = -1;
                     } else {
                         $tmpgdata[] = (double) $row->{$column};
                     }
                     $tmpglabels[] = !empty($label) ? strip_tags($row->{$label}) : '';
                 }
                 if (!empty($tmpgdata)) {
                     $max[$c] = max($tmpgdata);
                     $min[$c] = min($tmpgdata);
                 }
                 $gdata[$c] = implode(',', $tmpgdata);
                 $glabels[$c] = implode('|', $tmpglabels);
                 // $$$ hugh - playing around with pie charts
                 $gsums[$c] = array_sum($tmpgdata);
             }
         }
         $c++;
     }
     if ($calcfound) {
         $calculationLabels = array_reverse($calculationLabels);
         // $$$ rob implode with | and not ',' as :
         //$labels = explode('|',$glabels[0]); is used below
         //$glabels = array(implode(',', array_reverse($calculationLabels)));
         $glabels = array(implode('|', array_reverse($calculationLabels)));
         // $$$ rob end
         $gdata = array(implode(',', $calculationData));
     }
     // $$$ hugh - pie chart data has to be summed - the API only takes a
     // single dataset for pie charts.  And it doesn't make sense trying to
     // chart individual row data for multiple elements in a pie chart.
     // Also, labels need to be axisLabels, not $glabels
     switch ($chartType) {
         // Single Series Charts
         case 'AREA2D':
         case 'BAR2D':
         case 'COLUMN2D':
         case 'COLUMN3D':
         case 'DOUGHNUT2D':
         case 'DOUGHNUT3D':
         case 'LINE':
             // $$$ tom - for now I'm enabling Pie charts here so that it displays
             // something until we do it properly as you said hugh
             // Well maybe there's something I don't get but in fact FC already draw
             // the pies by "percenting" the values of each data... if you know what I mean Hugh;)
         // $$$ tom - for now I'm enabling Pie charts here so that it displays
         // something until we do it properly as you said hugh
         // Well maybe there's something I don't get but in fact FC already draw
         // the pies by "percenting" the values of each data... if you know what I mean Hugh;)
         case 'PIE2D':
         case 'PIE3D':
         case 'SCATTER':
             // Adding specific params for Pie charts
             if ($chartType == 'PIE2D' || $chartType == 'PIE3D') {
                 $strParam .= ';pieBorderThickness=' . $params->get('fusionchart_borderthick', '');
                 $strParam .= ';pieBorderAlpha=' . $params->get('fusionchart_cnvalpha', '');
                 $strParam .= ';pieFillAlpha=' . $params->get('fusionchart_elalpha', '');
             }
             if ($c > 1) {
                 $arrCatNames = array();
                 foreach ($axisLabels as $alkey => $al) {
                     $arrCatNames[] = $al;
                 }
                 $arrData = array();
                 $i = 0;
                 foreach ($gsums as $gd) {
                     $arrData[$i][0] = $axisLabels[$i];
                     $arrData[$i][1] = $gd;
                     $i++;
                 }
                 $FC->addChartDataFromArray($arrData, $arrCatNames);
             } else {
                 // single table/elements, so use the row data
                 $labels = explode('|', $glabels[0]);
                 $gsums = explode(',', $gdata[0]);
                 // scale to percentages
                 $tot_sum = array_sum($gsums);
                 $arrData = array();
                 $labelStep = 0;
                 $label_step_ratio = (int) JArrayHelper::getValue($label_step_ratios, 0, 1);
                 if ($label_step_ratio > 1) {
                     $labelStep = (int) (count($gsums) / $label_step_ratio);
                     $strParam .= ";labelStep={$labelStep}";
                 }
                 //$$$tom: inversing array_combine as identical values in gsums will be
                 // dropped otherwise. Should I do that differently?
                 // $$$ hugh - can't use array_combine, as empty labels end up dropping values
                 //$arrComb = array_combine($labels, $gsums);
                 //foreach ($arrComb as $key => $value) {
                 $data_count = 0;
                 foreach ($gsums as $key => $value) {
                     $data_count++;
                     if ($value == '-1') {
                         $value = null;
                     }
                     $label = $labels[$key];
                     $str_params = "name={$label}";
                     if ($labelStep) {
                         if ($data_count != 1 && $data_count % $labelStep != 0) {
                             $str_params .= ";showName=0";
                         }
                     }
                     $FC->addChartData("{$value}", $str_params);
                 }
             }
             break;
         case 'MSBAR2D':
         case 'MSBAR3D':
         case 'MSCOLUMN2D':
         case 'MSCOLUMN3D':
         case 'MSLINE':
         case 'MSAREA2D':
         case 'MSCOMBIDY2D':
         case 'MULTIAXISLINE':
             //case 'PIE2D':
             //case 'PIE3D':
         //case 'PIE2D':
         //case 'PIE3D':
         case 'STACKEDAREA2D':
         case 'STACKEDBAR2D':
         case 'STACKEDCOLUMN2D':
         case 'STACKEDCOLUMN3D':
         case 'SCROLLAREA2D':
         case 'SCROLLCOLUMN2D':
         case 'SCROLLLINE2D':
         case 'SCROLLSTACKEDCOLUMN2D':
             /*$chd = implode('|', $gdata);
             		if (!empty($chds_override)) {
             			$chds = $chds_override;
             		}
             		else if ($c > 1 && !$calcfound) {
             			$minmax = $this->_getMinMax($gsums);
             			$chds = $minmax['min'] . ',' . $minmax['max'];
             		}
             		else {
             			$chds = $min.','.$max;
             		}
             		if ($calcfound) {
             			$glabels = array(implode('|', $calculationLabels));
             		}
             		// $$$ hugh - we have to reverse the labels for horizontal bar charts
             		$glabels[0] = implode('|',array_reverse(explode('|',$glabels[0])));
             		if (empty($chxl_override)) {
             			$chxl = '0:|'.$min.'|'.$max.$measurement_unit.'|'.'1:|'.$glabels[0];
             		}
             		else {
             			$chxl = '0:|'.$chxl_override.'|'.'1:|'.$glabels[0];
             		}
             		break;
             		*/
             if ($c > 1) {
                 if ($chartType == 'SCROLLAREA2D' || $chartType == 'SCROLLCOLUMN2D' || $chartType == 'SCROLLLINE2D') {
                     $strParam .= ';numVisiblePlot=' . $params->get('fusionchart_scroll_numvisible', 0);
                 }
                 // $$$ hugh - Dual-Y types
                 if ($chartType == 'MSCOMBIDY2D' || $chartType == 'MULTIAXISLINE') {
                     //var_dump($axisLabels);
                     /*
                     					    $strParam .= ';PYAxisName='.$axisLabels[0];
                     					    $strParam .= ';SYAxisName='.$axisLabels[1];
                     */
                     $p_parents = array();
                     $s_parents = array();
                     foreach ($dual_y_parents as $dual_y_key => $dual_y_parent) {
                         if ($dual_y_parent == "P") {
                             $p_parents[] = $axisLabels[$dual_y_key];
                         } else {
                             $s_parents[] = $axisLabels[$dual_y_key];
                         }
                     }
                     $strParam .= ';PYAxisName=' . implode(' ', $p_parents);
                     $strParam .= ';SYaxisName=' . implode(' ', $s_parents);
                 }
                 //$$$tom: This is a first attempt at integrating Trendlines but it's not actually working... :s
                 $eltype = $params->get('fusionchart_element_type', 'dataset');
                 for ($nbe = 0; $nbe < $c; $nbe++) {
                     if ($eltype[$nbe] != 'dataset') {
                         // Trendline Start & End values
                         $trendstart = $params->get('fusionchart_trendstartvalue', '');
                         $trendend = $params->get('fusionchart_trendendvalue', '');
                         if ($trendstart) {
                             $startval = $trendstart;
                             $endval = $trendend;
                         } else {
                             if ($eltype[$nbe] == 'trendline') {
                                 // If Start & End values are not specifically defined, use the element's min & max values
                                 $startval = $min[$nbe];
                                 $endval = $max[$nbe];
                             }
                         }
                         $strAddTrend = "startValue={$startval};endValue={$endval}";
                         // Label
                         $displayval = $params->get('fusionchart_trendlabel', '');
                         $showontop = $params->get('fusionchart_trendshowontop', '1');
                         $iszone = $params->get('fusionchart_trendiszone', '0');
                         $elcolour = $params->get('fusionchart_elcolour', '');
                         $elalpha = $params->get('fusionchart_elalpha', '');
                         //$strAddTrend .= ";displayvalue=".$displayval;
                         $strAddTrend .= ";displayvalue=" . $axisLabels[$nbe];
                         $strAddTrend .= ";showOnTop=" . $showontop;
                         if ($startval < $endval) {
                             $strAddTrend .= ";isTrendZone=" . $iszone;
                         }
                         $strAddTrend .= ";color=" . $elcolour[$nbe];
                         $strAddTrend .= ";alpha=" . $elalpha[$nbe];
                         $strAddTrend .= ";thickness=3";
                         //var_dump($strAddTrend);
                         $FC->addTrendLine("{$strAddTrend}");
                         unset($axisLabels[$nbe]);
                         unset($gdata[$nbe]);
                     }
                 }
                 // end for loop
                 /*------------------------------------------
                 * $$$tom: I'm trying something else, as per http://www.fusioncharts.com/free/docs/Contents/PHPClassAPI/MultiSeriesChart.html
                 * A MS Chart should use for example 2 elements from the same table and have Categories
                 * (the colored legend below the chart, e.g. "This month", "Previous month").
                 * Then different Datasets must be defined (e.g. one by row in the table: "Week 1", "Week 2", ...)
                 * And finally some Data for each Dataset (e.g. Sales: "40200", "38350", ...)
                 * Of course I kept what you made Hugh, I commented out between this comment and what I've added.
                 ------------------------------------------*/
                 /*if ($calcfound) {
                 							$glabels = array(implode('|', $calculationLabels));
                 						}
                 						$arrCatNames = array();
                 						foreach ($axisLabels as $alkey => $al) {
                 							$arrCatNames[] = $al;
                 						}
                 
                 						$arrData = array();
                 						$i = 0;
                 						foreach ($gdata as $gdkey => $gd) {
                 							$arrData[$i][0] = $glabels[$i];
                 							$arrData[$i][1] = '';
                 							$arrData[$i] = array_merge($arrData[$i], explode(',', $gd));
                 							$i++;
                 						}
                 
                 						$FC->addChartDataFromArray($arrData, $arrCatNames);*/
                 $label_step_ratio = (int) JArrayHelper::getValue($label_step_ratios, 0, 1);
                 if ($label_step_ratio > 1) {
                     $labelStep = (int) (count(explode(',', $gdata[0])) / $label_step_ratio);
                     $strParam .= ";labelStep={$labelStep}";
                 }
                 // Start tom's changes
                 $labels = explode('|', $glabels[0]);
                 $data_count = 0;
                 foreach ($labels as $catLabel) {
                     $data_count++;
                     $catParams = '';
                     if ($labelStep) {
                         if ($data_count == 1 || $data_count % $labelStep == 0) {
                             $catParams = "ShowLabel=1";
                         } else {
                             $catParams = "ShowLabel=0";
                             $catLabel = '';
                         }
                     }
                     $FC->addCategory($catLabel, $catParams);
                 }
                 foreach ($gdata as $key => $chartdata) {
                     $cdata = explode(',', $chartdata);
                     $dataset = $axisLabels[$key];
                     $extras = "parentYAxis=" . $dual_y_parents[$key];
                     //var_dump($dual_y_parents, $dataset, $extras);
                     $FC->addDataset("{$dataset}", $extras);
                     $data_count = 0;
                     foreach ($cdata as $key => $value) {
                         $data_count++;
                         if ($value == '-1') {
                             $value = null;
                         }
                         $FC->addChartData("{$value}");
                     }
                 }
                 // End tom's changes
             } else {
                 //$foo = $foo;
             }
             /*
             	default:
             		$chd = implode('|', $gdata);
             		$chxl = '0:|'.$glabels[0].'|'.'1:|'.$min.'|'.$max;
             		if ($c > 1 && !$calcfound) {
             			$minmax = $this->_getMinMax($gsums);
             			$chds = $minmax['min'] . ',' . $minmax['max'];
             		}
             		else {
             			$chds = $min.','.$max;
             		}
             		break;
             */
     }
     $colours = implode($calcfound ? '|' : ',', $gcolours);
     /*$return = '<img src="' . $this->_url . '?';
     		$qs =  'chs='.$w.'x'.$h;
     		$qs .= '&amp;chd=t:'.$chd;
     		$qs .= '&amp;cht='.$graph;
     		$qs .= '&amp;chco='.$colours;
     		$qs .= '&amp;chxt=x,y';
     		$qs .= '&amp;chxl='.$chxl;
     		$qs .= '&amp;chds='.$chds;
     		if ($fillGraphs) {
     			$qs .=  '&amp;chm=' . implode('|', $gfills);
     		}
     		if ($legends) {
     			$qs .= '&amp;chdl=' . implode('|', $axisLabels);
     		}
     		if (!empty($chg_override)) {
     			$qs .= '&amp;chg=' . $chg_override;
     		}
     		if (!empty($chm_override)) {
     			$qs .= '&amp;chm=' . $chm_override;
     		}
     		else if ($fillGraphs) {
     			$qs .=  '&amp;chm=' . implode('|', $gfills);
     		}
     		$return .= $qs . '" alt="'.$this->_row->label.'" />';
     		$this->image =  $return;*/
     # Set chart attributes
     if ($params->get('fusionchart_custom_attributes', '')) {
         $strParam .= ';' . trim($params->get('fusionchart_custom_attributes'));
     }
     $strParam = "{$strParam}";
     $FC->setChartParams($strParam);
     # Render Chart
     if ($chartType == 'MULTIAXISLINE') {
         // Nasty, nasty hack for MULTIAXIS, as the FC class doesn't support it.  So need to get the chart XML,
         // split out the <dataset>...</dataset> and wrap them in <axis>...</axis>
         $axis_attrs = (array) $params->get('fusionchart_mx_attributes');
         $dataXML = $FC->getXML();
         $matches = array();
         if (preg_match_all('#(<\\s*dataset[^>]*>.*?<\\s*/dataset\\s*>)#', $dataXML, $matches)) {
             $index = 0;
             foreach ($gdata as $key => $chartdata) {
                 $axis = "<axis " . $axis_attrs[$index] . ">" . $matches[0][$index] . "</axis>";
                 $dataXML = str_replace($matches[0][$index], $axis, $dataXML);
                 $index++;
             }
         }
         return $FC->renderChartFromExtXML($dataXML);
     } else {
         return $FC->renderChart(false, false);
     }
 }
Example #6
0
	function getChart()
	{
		// Include PHP Class
		include(JPATH_SITE.DS.'components'.DS.'com_fabrik'.DS.'plugins'.DS.'visualization'.DS.'fusion_gantt_chart'.DS.'lib'.DS.'FCclass'.DS.'FusionCharts_Gen.php');
		// Add JS to page header
		$document = JFactory::getDocument();
		$document->addScript($this->srcBase."fusion_gantt_chart/lib/FCCharts/FusionCharts.js");

		$params = $this->getParams();
		$w = $params->get('fusion_gantt_chart_width');
		$h = $params->get('fusion_gantt_chart_height');

		// Create new chart
		$FC = new FusionCharts("GANTT","$w","$h");

		// Define path to FC's SWF
		$FC->setSWFPath($this->srcBase."fusion_gantt_chart/lib/FCCharts/");


		$FC->setChartParam('dateFormat', 'yyyy-mm-dd');
		$FC->setChartParam('showTaskNames', 1);

		$FC->setChartParams('ganttWidthPercent=70;gridBorderAlpha=100;canvasBorderColor=333333;canvasBorderThickness=0;hoverCapBgColor=FFFFFF;hoverCapBorderColor=333333;extendcategoryBg=0;ganttLineColor=99cc00;ganttLineAlpha=20;baseFontColor=333333;gridBorderColor=99cc00');
		// ------------------- Setting Param string


		$listid = $params->get('fusion_gantt_chart_table');
		$listModel = JModel::getInstance('list', 'FabrikFEModel');
		$listModel->setId($listid);
		$db = $listModel->getDB();
		$table = $listModel->getTable()->db_table_name;
		$process = $params->get('fusion_gantt_chart_process');
		$processraw = $process.'_raw';
		$start = $params->get('fusion_gantt_chart_startdate');
		$startraw = $start .'_raw';
		$end = $params->get('fusion_gantt_chart_enddate');
		$endraw = $end . '_raw';
		$label = $params->get('fusion_gantt_chart_label');
		$hover = $params->get('fusion_gantt_chart_hover');
		$milestone = $params->get('fusion_gantt_chart_milestone');
		$milestoneraw = $milestone."_raw";
		$connector = $params->get('fusion_gantt_chart_connector');
		$connectorraw = $connector."_raw";
		$fields = array();

		$fields[] = FabrikString::safeColName($process)." AS " . $db->nameQuote($process);
		$fields[] = FabrikString::safeColName($start)." AS " . $db->nameQuote($start);
		$fields[] = FabrikString::safeColName($end)." AS " . $db->nameQuote($end);
		$fields[] = FabrikString::safeColName($label)." AS " . $db->nameQuote($label);
		if ($hover !== '') {
			$fields[] = FabrikString::safeColName($hover)." AS " . $db->nameQuote($hover);
		}
		if ($milestone !== '') {
			$fields[] = FabrikString::safeColName($milestone)." AS " . $db->nameQuote($milestone);
		}
		if ($connector !== '') {
			$fields[] = FabrikString::safeColName($connector)." AS " . $db->nameQuote($connector);
		}

		$listModel->asfields = $fields;
		$nav = $listModel->getPagination(0, 0, 0);
		$data = $listModel->getData();
		$data = $data[0];

		$mindate = null;
		$maxdate = null;
		$usedProcesses = array();
		$milestones = array();
		$connectors = array();
		$processLabel = $params->get('fusion_gantt_chart_process_label');
		$FC->setGanttProcessesParams("positionInGrid=right;align=center;headerText=$processLabel;fontColor=333333;fontSize=11;isBold=1;isAnimated=1;bgColor=99cc00;headerbgColor=333333;headerFontColor=99cc00;headerFontSize=16;bgAlpha=40");

		foreach ($data as $d) {
			$hovertext = $hover == '' ? '' : $d->$hover;
			$processid = $d->$processraw;
			$startdate = JFactory::getDate($d->$startraw);
			$enddate = JFactory::getDate($d->$endraw);
			$strParam = "start=".$startdate->toFormat('%Y/%m/%d').";end=".$enddate->toFormat('%Y/%m/%d').";processId={$processid};id={$d->__pk_val};color=99cc00;alpha=60;topPadding=19;hoverText={$hovertext};";
			$strParam .="link={$d->fabrik_view_url};";
			$FC->addGanttTask($FC->encodeSpecialChars($d->$label), $strParam);

			if ($milestone !== '' && $d->$milestoneraw == 1) {
				$FC->addGanttMilestone($d->__pk_val, "date=".$enddate->toFormat('%Y/%m/%d').";radius=10;color=333333;shape=Star;numSides=5;borderThickness=1");
			}

			if ($connector !== '' && $d->$connectorraw !== '') {
				$FC->addGanttConnector($d->$connectorraw, $d->__pk_val, "color=99cc00;thickness=2;");
			}
			#apply processes
			if (!in_array($processid, $usedProcesses)) {
				$usedProcesses[] = $processid;
				$FC->addGanttProcess($FC->encodeSpecialChars($d->$process), "id={$processid};");
			}
			#increaes max/min date range
			if (is_null($mindate)) {
				$mindate = $startdate;
				$maxdate = $enddate;
			} else {
				if (JFactory::getDate($d->$startraw)->toUnix() < $mindate->toUnix()) {
					$mindate = JFactory::getDate($d->$startraw);
				}

				if (JFactory::getDate($d->$endraw)->toUnix() > $maxdate->toUnix()) {
					$maxdate = JFactory::getDate($d->$endraw);
				}
			}
		}

		$startyear = $mindate ? $mindate->toFormat('%Y') : date('Y');
		$endyear = $maxdate ? $maxdate->toFormat('%Y') : 0;

		$monthdisplay = $params->get('fusion_gannt_chart_monthdisplay');
		$FC->addGanttCategorySet("bgColor=333333;fontColor=99cc00;isBold=1;fontSize=14");
		for ($y = $startyear; $y <= $endyear; $y++) {
			$firstmonth = ($y == $startyear) ? (int)$mindate->toFormat('%m') : 1;
			$lastmonth = ($y == $endyear) ? $maxdate->toFormat('%m')+1 : 13;

			$start = date('Y/m/d', mktime(0, 0, 0, $firstmonth, 1, $y));
			$end = date('Y/m/d', mktime(0, 0, 0, $lastmonth, 0, $y));

			$strParam = "start=". $start.";end=".$end.";";
			$FC->addGanttCategory($y, $strParam);
		}
		$FC->addGanttCategorySet("bgColor=99cc00;fontColor=333333;isBold=1;fontSize=10;bgAlpha=40;align=center");
		for ($y = $startyear; $y <= $endyear; $y++) {
			$lastmonth = ($y == $endyear) ? $maxdate->toFormat('%m')+1 : 13;
			$firstmonth = ($y == $startyear) ? (int)$mindate->toFormat('%m') : 1;
			for ($m = $firstmonth; $m < $lastmonth; $m++) {
				$starttime = mktime(0, 0, 0, $m, 1, $y);
				$start = date('Y/m/d', $starttime);
				$end = date('Y/m/d', mktime(0, 0, 0, $m+1, 0, $y));//use day = 0 to load last day of next month
				$m2 = $monthdisplay == 'str' ? JText::_(date('M', $starttime)) : $m;
				$FC->addGanttCategory($m2, "start=".$start.";end=".$end.";");
			}
		}

		# Render Chart
		return $FC->renderChart(false, false);
	}
 public function sendStatusAction()
 {
     $oPermission = new Config_Permission();
     $oApp = new Config_App();
     $oServer = new Config_Server();
     $oPartnerApp = new Config_Partner_App();
     $oPartner = new Config_Partner();
     $oArea = new Config_Area();
     //获取用户可以查看的游戏列表
     $permitted_app = $oPermission->getApp($this->manager->data_groups, 'AppId,name');
     //预处理地区信息
     $AreaList = $oArea->getAll();
     //检查当前页面权限
     $sign = '?ctl=config/socket.queue&ac=send.status';
     $this->manager->checkMenuPermission($sign, Widget_Manager::MENU_PURVIEW_SELECT);
     $SocketType = $this->oSocketType->getAll();
     //页面输入变量
     $AppId = intval($this->request->AppId);
     $PartnerId = intval($this->request->PartnerId);
     $ServerId = intval($this->request->ServerId);
     $AreaId = intval($this->request->AreaId) ? intval($this->request->AreaId) : 0;
     $app_type = intval($this->request->app_type);
     $partner_type = intval($this->request->partner_type);
     $is_abroad = intval($this->request->is_abroad) ? intval($this->request->is_abroad) : 0;
     $uType = intval($this->request->uType) ? intval($this->request->uType) : 0;
     //时间范围初始化
     $Date = $this->request->Date ? $this->request->Date : date("Y-m-d", time());
     //初始化图表配置
     $divideV = 23;
     $Step = 60;
     //初始化合作商列表
     $permitted_partner = array();
     //初始化服务器列表
     $permitted_server = array();
     //获取当前地区列表
     $AreaList = $oArea->getAbroad($is_abroad, $AreaList);
     //生成允许的地区id数组
     if ($app_type > 0) {
         //筛选是否平台产品
         $permitted_app = $oApp->getApp($app_type, $permitted_app);
     }
     if ($AppId > 0) {
         //获取可查看的权限总表
         $permitted_partner = $oPermission->getPartner($this->manager->data_groups, $AppId, 'PartnerId,name,AreaId');
         //根据合作方式筛选
         $permitted_partner = $oPartnerApp->getPermittedPartnerByPartnerType($partner_type, $permitted_partner);
         //根据所在地区筛选
         $permitted_partner = $oPartnerApp->getPermittedPartnerByPartnerArea($AreaList, $permitted_partner);
         if ($PartnerId > 0) {
             //获取服务器列表
             $permitted_server = $oPermission->getServer($this->manager->data_groups, $AppId, $PartnerId, 'ServerId,name');
         }
     }
     //获取用于查询的权限sql语句
     $SendStatusArr = $this->oSocketQueue->getSendStatus($Date, $ServerId, $uType);
     for ($i = 0; $i < 24 * 60; $i++) {
         $H = intval($i / 60);
         $m = $i - $H * 60;
         if (!isset($SendStatusArr[$i])) {
             $SendStatusArr[$i] = array('Time' => sprintf("%02d", $H) . ":" . sprintf("%02d", $m), 'SendCount' => 0);
         } else {
             $SendStatusArr[$i]['Time'] = sprintf('%02d', $H) . ":" . sprintf('%02d', $m);
         }
     }
     ksort($SendStatusArr);
     # Include FusionCharts PHP Class
     include 'Third/fusion/Includes/FusionCharts_Gen.php';
     # Create Multiseries ColumnD chart object using FusionCharts PHP Class
     $FC = new FusionCharts("MsLine", '100%', '500');
     # Set the relative path of the swf file
     $FC->setSWFPath("../Charts/");
     # Store chart attributes in a variable
     $strParam = "caption='Socket队列发送情况';animation=0;xAxisName='时间';baseFontSize=12;numberPrefix=;decimalPrecision=0;showValues=0;formatNumberScale=0;labelStep={$Step};numvdivlines={$divideV};rotateNames=1;yAxisMinValue=0;yAxisMaxValue=10;numDivLines=9;showAlternateHGridColor=1;alternateHGridAlpha=5;alternateHGridColor='CC3300'";
     # Set chart attributes
     $FC->setChartParams($strParam);
     foreach ($SendStatusArr as $key => $data) {
         $FC->addCategory($data['Time']);
     }
     $FC->addDataset("发送数量");
     foreach ($SendStatusArr as $key => $data) {
         $FC->addChartData($data['SendCount']);
     }
     $page_title = "Socket队列发送情况";
     $page_form_action = $sign;
     //调取模板
     include $this->tpl('Config_SocketQueue_SendStatus');
 }
Example #8
0
	function getFusionchart()
	{
		// Include PHP Class
		require_once($this->pathBase.'fusionchart'.DS.'lib'.DS.'FCclass'.DS.'FusionCharts_Gen.php');
		// Add JS to page header
		$document = JFactory::getDocument();
		$document->addScript($this->srcBase."fusionchart/lib/FCcharts/FusionCharts.js");

		$params = $this->getParams();
		$calc_prefixes = array('sum___', 'avg___', 'med___', 'cnt___');
		$calc_prefixmap = array('sum___' => 'sums', 'avg___' => 'avgs', 'med___' => 'medians', 'cnt___' => 'count');
		$w = $params->get('fusionchart_width');
		$h = $params->get('fusionchart_height');

		$chartType =$params->get('fusionchart_type');

		// Create new chart
		$FC = new FusionCharts("$chartType","$w","$h");
		//$FC->JSC["debugmode"]=true;
		// Define path to FC's SWF
		$FC->setSWFPath($this->srcBase."fusionchart/lib/FCcharts/");

		$this->setChartMessages($FC);

		// ------------------- Setting Param string
		$strParam = $this->getChartParams();

		$x_axis_label 	= $params->get('fusion_x_axis_label', array(), '_default', 'array');
		$chartElements 	= $params->get('fusionchart_elementList', array(), '_default', 'array');

		$chartColours 	= $params->get('fusionchart_colours', array(), '_default', 'array');
		$listid 				= $params->get('fusionchart_table', array(), '_default', 'array');
		$axisLabels 		= $params->get('fusionchart_axis_labels', array(), '_default', 'array');
		$measurement_units = $params->get('fusion_x_axis_measurement_unit', array(), '_default', 'array');
		$legends  			= $params->get('fusiongraph_show_legend', '');
		$c = 0;
		$gdata = array();
		$glabels = array();
		$gcolours = array();
		$gfills = array();
		$max = 0;
		$min = 0;

		$calculationLabels = array();
		$calculationData = array();
		$calcfound = false;

		$tmodels = array();

		foreach ($listid as $tid) {
		  if (!array_key_exists($tid, $tmodels)) {
				$listModel = null;
				$listModel = JModel::getInstance('list', 'FabrikFEModel');
				$listModel->setId($tid);
				$tmodels[$tid] = $listModel;
		  } else {
		    $listModel = $tmodels[$tid];
		  }

			$table = $listModel->getTable();
			$form = $listModel->getForm();
			//remove filters?
			// $$$ hugh - remove pagination BEFORE calling render().  Otherwise render() applies
			// session state/defaults when it calls getPagination, which is then returned as a cached
			// object if we call getPagination after render().  So call it first, then render() will
			// get our cached pagination, rather than vice versa.
			$nav			=& $listModel->getPagination(0, 0, 0);
			$listModel->render();
			//$listModel->doCalculations();
			$alldata = $listModel->getData();
			$cals = $listModel->getCalculations();
			$column = $chartElements[$c];
			//$measurement_unit = $measurement_units[$c];
			$measurement_unit = JArrayHelper::getValue($measurement_units, $c, '');
			$pref =substr($column, 0, 6);

			$label = JArrayHelper::getValue($x_axis_label, $c, '');

			$tmpgdata = array();
			$tmpglabels = array();
			//$colour = str_replace("#", '', $chartColours[$c]);
			$colour = array_key_exists($c , $chartColours) ? str_replace("#", '', $chartColours[$c]) : '';

		/*	if ($fillGraphs) {
				$c2 = $c + 1;
				$gfills[] ='b,'. $colour . "," . $c  . ",". $c2 .",0";
			}
*/
			$gcolours[] = $colour;

			if (in_array($pref, $calc_prefixes)) {

				// you shouldnt mix calculation elements with normal elements when creating the chart
				// so if ONE calculation element is found we use the calculation data rather than normal element data
				// this is because a calculation element only generates one value, if want to compare two averages then
				//they get rendered as tow groups of data and on bar charts this overlays one average over the other, rather than next to it
				$calcfound = true;

				$column = substr($column, 6);
				$calckey = $calc_prefixmap[$pref];
				$caldata = JArrayHelper::getValue($cals[$calckey], $column.'_obj');
				if (is_array($caldata)) {
					foreach ($caldata as $k=>$o) {
						$calculationData[] = (float)$o->value;
						$calculationLabels[] = trim(strip_tags($o->label));
					}
				}
			if (!empty($calculationData) && max($calculationData) > $max) {
					$max = max($calculationData);
				}
				if(!empty($calculationData) && min($calculationData) < $min) {
					$min = min($calculationData);
				}

				$gdata[$c] = implode(',', $tmpgdata);
				$glabels[$c] = implode('|', $tmpglabels);
				// $$$ hugh - playing around with pie charts
				//$gsums[$c] = array_sum($tmpgdata);
				$gsums[$c] = array_sum($calculationData);
			} else {
				$origColumn = $column;
				$column = $column. "_raw"; //_raw fields are most likely to contain the value
				foreach ($alldata as $group) {
					foreach ($group as $row) {
						if (!array_key_exists($column, $row)) {
							//didnt find a _raw column - revent to orig
							$column = $origColumn;

							if (!array_key_exists($column, $row)) {
								JError::raiseWarning(E_NOTICE, $column . ': NOT FOUND - PLEASE CHECK IT IS PUBLISHED');
								continue;
							}
						}
						if (trim($row->$column) == '') {
							$tmpgdata[] = - 1;
						} else {
							$tmpgdata[] = (float)$row->$column;
						}
						$tmpglabels[] = !empty($label) ? strip_tags($row->$label) : '';
					}
					if (!empty($tmpgdata) && max($tmpgdata) > $max) {
						$max = max($tmpgdata);
					}
					if(!empty($tmpgdata) && min($tmpgdata) < $min) {
						$min = min($tmpgdata);
					}
					$gdata[$c] = implode(',', $tmpgdata);
					$glabels[$c] = implode('|', $tmpglabels);
					// $$$ hugh - playing around with pie charts
					$gsums[$c] = array_sum($tmpgdata);
				}
			}
			$c ++;
		}
		if ($calcfound) {
			$calculationLabels = array_reverse($calculationLabels);

			// $$$ rob implode with | and not ',' as :
			//$labels = explode('|',$glabels[0]); is used below
			//$glabels = array(implode(',', array_reverse($calculationLabels)));
			$glabels = array(implode('|', array_reverse($calculationLabels)));
 			// $$$ rob end
			$gdata =  array(implode(',', $calculationData));
		}

		// $$$ hugh - pie chart data has to be summed - the API only takes a
		// single dataset for pie charts.  And it doesn't make sense trying to
		// chart individual row data for multiple elements in a pie chart.
		// Also, labels need to be axisLabels, not $glabels
		switch ($chartType) {
			// Single Series Charts
			case 'AREA2D':
			case 'BAR2D':
			case 'COLUMN2D':
			case 'COLUMN3D':
			case 'DOUGHNUT2D':
			case 'DOUGHNUT3D':
			case 'LINE':
			// $$$ tom - for now I'm enabling Pie charts here so that it displays
			// something until we do it properly as you said hugh
			// Well maybe there's something I don't get but in fact FC already draw
			// the pies by "percenting" the values of each data... if you know what I mean Hugh;)
			case 'PIE2D':
			case 'PIE3D':
			case 'SCATTER':

				// Adding specific params for Pie charts
				if ($chartType == 'PIE2D' || $chartType == 'PIE3D') {
					$strParam .= ';pieBorderThickness='.$params->get('fusionchart_borderthick', '');
					$strParam .= ';pieBorderAlpha='.$params->get('fusionchart_cnvalpha', '');
					$strParam .= ';pieFillAlpha='.$params->get('fusionchart_elalpha', '');
				}

				if ($c > 1) {
					/*
					// mutiple table/elements, so use the sums
					// need to scale our data into percentages
					$tot_sum = array_sum($gsums);
					$arrData = array();
					foreach ($gsums as $sum) {
						$arrData[0] = sprintf('%01.2f', ($sum / $tot_sum) * 100);
					}

					//$chd = implode(',',$percs);
					//$chxl = '0:|' . implode('|', $axisLabels);

					if ($legends) {
						$arrData[1] = $gsums;
					}
					else {
						$arrData[1] = $axisLabels;
					}
					$fillGraphs = false;
					*/
					$arrCatNames = array();
					foreach ($axisLabels as $alkey => $al) {
						$arrCatNames[] = $al;
					}
					$arrData = array();
					$i = 0;
					foreach ($gdata as $gdkey => $gd) {
						$arrData[$i][0] = $glabels[$i];
						$arrData[$i][1] = '';
						$arrData[$i] = array_merge($arrData[$i], explode(',', $gd));
						$i++;
					}
					$FC->addChartDataFromArray($arrData, $arrCatNames);
				}
				else {
					// single table/elements, so use the row data

					$labels = explode('|', $glabels[0]);
					$gsums = explode(',', $gdata[0]);
					// scale to percentages
					$tot_sum = array_sum($gsums);
					$arrData = array();
					/*foreach ($gsums as $sum) {
						$arrData[0] = sprintf('%01.2f', ($sum / $tot_sum) * 100);
					}*/



					//$$$tom: inversing array_combine as identical values in gsums will be
					// dropped otherwise. Should I do that differently?
					$arrComb = array_combine($labels, $gsums);
					foreach ($arrComb as $key => $value) {
						if ($value == '-1') {
							$value = null;
						}
						$FC->addChartData("$value","name=$key");
					}

				}
				break;
			case 'MSBAR2D':
			case 'MSCOLUMN2D':
			case 'MSCOLUMN3D':
			case 'MSLINE':
			case 'MSAREA2D':

			//case 'PIE2D':
			//case 'PIE3D':
			case 'STACKEDAREA2D':
			case 'STACKEDBAR2D':
			case 'STACKEDCOLUMN2D':
			case 'STACKEDCOLUMN3D':

			case 'SCROLLAREA2D':
			case 'SCROLLCOLUMN2D':
			case 'SCROLLLINE2D':
			case 'SCROLLSTACKEDCOLUMN2D':


				/*$chd = implode('|', $gdata);
				if (!empty($chds_override)) {
					$chds = $chds_override;
				}
				else if ($c > 1 && !$calcfound) {
					$minmax = $this->_getMinMax($gsums);
					$chds = $minmax['min'] . ',' . $minmax['max'];
				}
				else {
					$chds = $min.','.$max;
				}
				if ($calcfound) {
					$glabels = array(implode('|', $calculationLabels));
				}
				// $$$ hugh - we have to reverse the labels for horizontal bar charts
				$glabels[0] = implode('|',array_reverse(explode('|',$glabels[0])));
				if (empty($chxl_override)) {
					$chxl = '0:|'.$min.'|'.$max.$measurement_unit.'|'.'1:|'.$glabels[0];
				}
				else {
					$chxl = '0:|'.$chxl_override.'|'.'1:|'.$glabels[0];
				}
				break;
				*/
				if ($c > 1) {

					if ($chartType == 'SCROLLAREA2D' || $chartType == 'SCROLLCOLUMN2D' || $chartType == 'SCROLLLINE2D') {
						$strParam .= ';numVisiblePlot='.$params->get('fusionchart_scroll_numvisible', 0);
					}

					//$$$tom: This is a first attempt at integrating Trendlines but it's not actually working... :s
					$eltype = $params->get('fusionchart_element_type', 'dataset');
					for ($nbe = 0; $nbe < $c; $nbe++) {
						if ($eltype[$nbe] != 'dataset') {
							// Trendline Start & End values
							$trendstart = $params->get('fusionchart_trendstartvalue', '');
							$trendend = $params->get('fusionchart_trendendvalue', '');
								if ($trendstart[$nbe]) {
									$startval = $trendstart[$nbe];
									$endval = $trendend[$nbe];
								} else if ($eltype[$nbe] == 'trendline') {
									// If Start & End values are not specifically defined, use the element's min & max values
									$startval = $min;
									$endval = $max;
								}
								$strAddTrend = "startValue=$startval;endValue=$endval";
								// Label
								$displayval = $params->get('fusionchart_trendlabel', '');
								$showontop = $params->get('fusionchart_trendshowontop', '1');
								$iszone = $params->get('fusionchart_trendiszone', '0');
								$elcolour = $params->get('fusionchart_elcolour', '');
								$elalpha = $params->get('fusionchart_elalpha', '');
								$strAddTrend .= ";displayvalue=".$displayval[$nbe];
								$strAddTrend .= ";showOnTop=".$showontop[$nbe];
								if ($startval < $endval) {
									$strAddTrend .= ";isTrendZone=".$iszone[$nbe];
								}
								$strAddTrend .= ";color=".$elcolour[$nbe];
								$strAddTrend .= ";alpha=".$elalpha[$nbe];
								$FC->addTrendLine("$strAddTrend");
								unset($axisLabels[$nbe]);
								unset($gdata[$nbe]);

						}
					} // end for loop

/*------------------------------------------
* $$$tom: I'm trying something else, as per http://www.fusioncharts.com/free/docs/Contents/PHPClassAPI/MultiSeriesChart.html
* A MS Chart should use for example 2 elements from the same table and have Categories
* (the colored legend below the chart, e.g. "This month", "Previous month").
* Then different Datasets must be defined (e.g. one by row in the table: "Week 1", "Week 2", ...)
* And finally some Data for each Dataset (e.g. Sales: "40200", "38350", ...)
* Of course I kept what you made Hugh, I commented out between this comment and what I've added.
------------------------------------------*/
					/*if ($calcfound) {
							$glabels = array(implode('|', $calculationLabels));
						}
						$arrCatNames = array();
						foreach ($axisLabels as $alkey => $al) {
							$arrCatNames[] = $al;
						}

						$arrData = array();
						$i = 0;
						foreach ($gdata as $gdkey => $gd) {
							$arrData[$i][0] = $glabels[$i];
							$arrData[$i][1] = '';
							$arrData[$i] = array_merge($arrData[$i], explode(',', $gd));
							$i++;
						}

						$FC->addChartDataFromArray($arrData, $arrCatNames);*/

						// Start tom's changes
						$labels = explode('|',$glabels[0]);
						foreach ($labels as $catLabel) {
							$FC->addCategory("$catLabel");
						}
						foreach ($gdata as $key => $chartdata) {
							$cdata = explode(',',$chartdata);
							$dataset = $axisLabels[$key];
							$FC->addDataset("$dataset");
							foreach ($cdata as $key => $value) {
								if ($value == '-1') {
									$value = null;
								}
								$FC->addChartData("$value");
							}
						}
						// End tom's changes
					} else {
						//$foo = $foo;
					}
				/*
			default:
				$chd = implode('|', $gdata);
				$chxl = '0:|'.$glabels[0].'|'.'1:|'.$min.'|'.$max;
				if ($c > 1 && !$calcfound) {
					$minmax = $this->_getMinMax($gsums);
					$chds = $minmax['min'] . ',' . $minmax['max'];
				}
				else {
					$chds = $min.','.$max;
				}
				break;
		*/}
		$colours = implode(($calcfound ? '|': ','), $gcolours);

		/*$return = '<img src="' . $this->_url . '?';
		$qs =  'chs='.$w.'x'.$h;
		$qs .= '&amp;chd=t:'.$chd;
		$qs .= '&amp;cht='.$graph;
		$qs .= '&amp;chco='.$colours;
		$qs .= '&amp;chxt=x,y';
		$qs .= '&amp;chxl='.$chxl;
		$qs .= '&amp;chds='.$chds;
		if ($fillGraphs) {
			$qs .=  '&amp;chm=' . implode('|', $gfills);
		}
		if ($legends) {
			$qs .= '&amp;chdl=' . implode('|', $axisLabels);
		}
		if (!empty($chg_override)) {
			$qs .= '&amp;chg=' . $chg_override;
		}
		if (!empty($chm_override)) {
			$qs .= '&amp;chm=' . $chm_override;
		}
		else if ($fillGraphs) {
			$qs .=  '&amp;chm=' . implode('|', $gfills);
		}
		$return .= $qs . '" alt="'.$this->_row->label.'" />';
		$this->image =  $return;*/

		# Set chart attributes
		if ($params->get('fusionchart_custom_attributes', '')) {
			$strParam = trim($params->get('fusionchart_custom_attributes'));
		}
		$strParam="$strParam";
		$FC->setChartParams($strParam);


		# Render Chart
		return $FC->renderChart(false, false);
	}
    $resforcharts = mysql_fetch_array($checkappforcharts);
    $linkidforcharts = $resforcharts['id'];
    $chart_traffic = mysql_query("select COUNT(DISTINCT ip) from idevaff_iptracking where acct_id = '{$linkidforcharts}'");
    $chart_traffic = mysql_fetch_row($chart_traffic);
    $chart_traffic = $chart_traffic[0];
    $chart_approved = mysql_query("select COUNT(*) from idevaff_sales where approved = '1' and bonus = '0' and id = '{$linkidforcharts}'");
    $chart_approved = mysql_fetch_row($chart_approved);
    $chart_approved = $chart_approved[0];
    $chart_paid = mysql_query("select COUNT(*) from idevaff_archive where bonus = '0' and id = '{$linkidforcharts}'");
    $chart_paid = mysql_fetch_row($chart_paid);
    $chart_paid = $chart_paid[0];
    $chart_commissions = $chart_approved + $chart_paid;
    $chart_traffic_tag = "Unique Hits";
    $chart_commissions_tag = "Total Sales";
    $FC = new FusionCharts("Column2D", "280", "180");
    $FC->setSWFPath("templates/fusion/FusionCharts/");
    $strParam = "showDivLineValue=0;canvasBorderColor=FFFFFF;formatNumberScale=0;formatNumber=1;animation=1;decimalPrecision=0;canvasBorderThickness=0;canvasBgColor=FFFFFF;canvasBaseColor=5c5c5c;canvasBaseDepth=1;baseFont=arial;baseFontSize=11;outCnvBaseFont=arial;outCnvBaseFontSze=11;showLegend=1";
    $FC->setChartParams($strParam);
    $FC->addChartData($chart_traffic, "name={$chart_traffic_tag}");
    $FC->addChartData($chart_commissions, "name={$chart_commissions_tag}");
    $FC->renderChart();
}
?>
</td>
</tr>
<tr>
<td width="30%" bgcolor="<?php 
echo $this->_tpl_vars['white_back'];
?>
">&nbsp;<?php 
echo $this->_tpl_vars['general_transactions'];
function fs_gantt_chart($title, $from, $to, $tasks, $milestones, $width, $height)
{
    // Generate the XML
    $chart = new FusionCharts("Gantt", $width, $height, "1", "0");
    $chart->setSWFPath("include/graphs/FusionCharts/");
    $chart->setChartParams('dateFormat=dd/mm/yyyy;hoverCapBorderColor=2222ff;hoverCapBgColor=e1f5ff;ganttLineAlpha=80;canvasBorderColor=024455;canvasBorderThickness=0;gridBorderColor=2179b1;gridBorderAlpha=20;ganttWidthPercent=80');
    $chart->setGanttProcessesParams('headerText=' . __('Task') . ';fontColor=ffffff;fontSize=9;isBold=1;isAnimated=1;bgColor=2179b1;headerbgColor=2179b1;headerFontColor=ffffff;headerFontSize=12;align=left');
    $chart->setGanttTasksParams('');
    $start_date = explode('/', $from);
    $start_day = $start_date[0];
    $start_month = $start_date[1];
    $start_year = $start_date[2];
    $end_date = explode('/', $to);
    $end_day = $end_date[0];
    $end_month = $end_date[1];
    $end_year = $end_date[2];
    $time_span = date_to_epoch($to) - date_to_epoch($from);
    // Years
    $chart->addGanttCategorySet('bgColor=2179b1;fontColor=ff0000');
    for ($i = $start_year; $i <= $end_year; $i++) {
        if ($i == $start_year) {
            $start = sprintf('%02d/%02d/%04d', $start_day, $start_month, $start_year);
        } else {
            $start = sprintf('%02d/%02d/%04d', 1, 1, $i);
        }
        if ($i == $end_year) {
            $end = sprintf('%02d/%02d/%04d', $end_day, $end_month, $end_year);
        } else {
            $end = sprintf('%02d/%02d/%04d', cal_days_in_month(CAL_GREGORIAN, 12, $i), 12, $i);
        }
        $chart->addGanttCategory($i, ';start=' . $start . ';end=' . $end . ';align=center;fontColor=ffffff;isBold=1;fontSize=16');
    }
    // Months
    $chart->addGanttCategorySet('bgColor=ffffff;fontColor=1288dd;fontSize=10');
    for ($i = $start_year; $i <= $end_year; $i++) {
        for ($j = 1; $j <= 12; $j++) {
            if ($i == $start_year && $j < $start_month) {
                continue;
            } else {
                if ($i == $end_year && $j > $end_month) {
                    break;
                }
            }
            if ($i == $start_year && $j == $start_month) {
                $start = sprintf('%02d/%02d/%04d', $start_day, $start_month, $start_year);
            } else {
                $start = sprintf('%02d/%02d/%04d', 1, $j, $i);
            }
            if ($i == $end_year && $j == $end_month) {
                $end = sprintf('%02d/%02d/%04d', $end_day, $end_month, $end_year);
            } else {
                $end = sprintf('%02d/%02d/%04d', cal_days_in_month(CAL_GREGORIAN, $j, $i), $j, $i);
            }
            $chart->addGanttCategory(date('F', mktime(0, 0, 0, $j, 1)), ';start=' . $start . ';end=' . $end . ';align=center;isBold=1');
        }
    }
    // Days
    if ($time_span < 2592000) {
        $chart->addGanttCategorySet();
        for ($i = $start_year; $i <= $end_year; $i++) {
            for ($j = 1; $j <= 12; $j++) {
                if ($i == $start_year && $j < $start_month) {
                    continue;
                } else {
                    if ($i == $end_year && $j > $end_month) {
                        break;
                    }
                }
                $num_days = cal_days_in_month(CAL_GREGORIAN, $j, $i);
                for ($k = 1; $k <= $num_days; $k++) {
                    if ($i == $start_year && $j == $start_month && $k < $start_day) {
                        continue;
                    } else {
                        if ($i == $end_year && $j == $end_month && $k > $end_day) {
                            break;
                        }
                    }
                    $start = sprintf('%02d/%02d/%04d', $k, $j, $i);
                    $end = sprintf('%02d/%02d/%04d', $k, $j, $i);
                    $chart->addGanttCategory($k, ';start=' . $start . ';end=' . $end . ';fontSize=8;isBold=0');
                }
            }
        }
    } else {
        if ($time_span < 10368000) {
            $chart->addGanttCategorySet();
            for ($i = $start_year; $i <= $end_year; $i++) {
                for ($j = 1; $j <= 12; $j++) {
                    if ($i == $start_year && $j < $start_month) {
                        continue;
                    } else {
                        if ($i == $end_year && $j > $end_month) {
                            break;
                        }
                    }
                    $num_days = cal_days_in_month(CAL_GREGORIAN, $j, $i);
                    for ($k = 1, $l = 1; $k <= $num_days; $k += 8, $l++) {
                        if ($i == $start_year && $j == $start_month && $k + 7 < $start_day) {
                            continue;
                        }
                        if ($i == $end_year && $j == $end_month && $k > $end_day) {
                            break;
                        }
                        if ($i == $start_year && $j == $start_month && $k < $start_day) {
                            $start = sprintf('%02d/%02d/%04d', $start_day, $j, $i);
                        } else {
                            $start = sprintf('%02d/%02d/%04d', $k, $j, $i);
                        }
                        if ($i == $end_year && $j == $end_month && $k + 7 > $end_day) {
                            $end = sprintf('%02d/%02d/%04d', $end_day, $j, $i);
                        } else {
                            if ($k + 7 > $num_days) {
                                $end = sprintf('%02d/%02d/%04d', $num_days, $j, $i);
                            } else {
                                $end = sprintf('%02d/%02d/%04d', $k + 7, $j, $i);
                            }
                        }
                        $chart->addGanttCategory(__('Week') . " {$l}", ';start=' . $start . ';end=' . $end . ';fontSize=8;isBold=0');
                    }
                }
            }
        }
    }
    // Tasks
    foreach ($tasks as $task) {
        $chart->addGanttProcess(clean_flash_string($task['name']), 'id=' . $task['id'] . ';link=' . urlencode($task['link']));
        $chart->addGanttTask(__('Planned'), 'start=' . $task['start'] . ';end=' . $task['end'] . ';id=' . $task['id'] . ';processId=' . $task['id'] . ';color=4b3cff;height=5;topPadding=10;animation=0');
        if ($task['real_start'] !== false && $task['real_end']) {
            $chart->addGanttTask(__('Actual'), 'start=' . $task['real_start'] . ';end=' . $task['real_end'] . ';processId=' . $task['id'] . ';color=ff3c4b;alpha=100;topPadding=15;height=5');
        }
        if ($task['completion'] != 0) {
            $task_span = date_to_epoch($task['end']) - date_to_epoch($task['start']);
            $end = date('d/m/Y', date_to_epoch($task['start']) + $task_span * $task['completion'] / 100.0);
            $chart->addGanttTask(__('Completion') . " (" . $task['completion'] . ")", 'start=' . $task['start'] . ';end=' . $end . ';processId=' . $task['id'] . ';color=32cd32;alpha=100;topPadding=20;height=5');
        }
        if ($task['parent'] != 0) {
            $chart->addGanttConnector($task['parent'], $task['id'], 'color=2179b1;thickness=2;fromTaskConnectStart=1');
        }
    }
    // Milestones
    if ($milestones !== '') {
        $chart->addGanttProcess(__('Milestones'), 'id=0');
        foreach ($milestones as $milestone) {
            $chart->addGanttTask(clean_flash_string($milestone['name']), 'start=' . $milestone['date'] . ';end=' . $milestone['date'] . ';id=ms-' . $milestone['id'] . ';processId=0;color=ffffff;alpha=0;height=60;topPadding=0;animation=0');
            $chart->addGanttMilestone('ms-' . $milestone['id'], 'date=' . $milestone['date'] . ';radius=8;color=efbb07;shape=star;numSides=3;borderThickness=1');
        }
    }
    // Today
    $chart->addTrendLine('start=' . date('d/m/Y') . ';displayValue=' . __('Today') . ';color=666666;isTrendZone=1;alpha=20');
    // Return the code
    return get_chart_code($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Gantt.swf');
}
Example #11
0
<?php

/**
 * Created by PhpStorm.
 * User: Allan Wiz
 * Date: 4/15/15
 * Time: 5:03 PM
 */
require '../classes/aardb_conn.php';
//header('Content-Type: Text/xml');
include "../Charts/JSClass/FusionCharts.php";
include "../Charts/JSClass/FC_Colors.php";
include "../Charts/JSClass/FusionCharts_Gen.php";
global $session, $database;
global $conn;
$FC = new FusionCharts("MSLine", "300", "300");
$FC->setDataBaseType("oracle");
$FC->setSWFPath("../Charts/");
$strParam = "caption=INTEREST VIEW REPORT (for the last 14 days);subCaption=BY APPLICABLE DATE ; showNames='1';pieSliceDepth=30;showBorder=1;numberSuffix= %; formatNumberScale='0'; xAxisName=Date; pYAxisName=Net Asset Value;sYAxisName=BalancedFund";
$FC->setChartParams($strParam);
$start = date("d/M/Y", strtotime('-40 days'));
$today = date("d/M/Y");
$sql = "SELECT I_RATES.RATE_ID, I_RATES.RATE_DATE AS DATEY, I_RATES.RATE AS RATE, SECURITIES.DESCRIPT AS DESCRIPTION FROM I_RATES INNER JOIN\r        SECURITIES ON I_RATES.SECURITY_CODE = SECURITIES.SECURITY_CODE WHERE I_RATES.CONFIRMD = 1 AND I_RATES.RATE_DATE  BETWEEN '{$start}' AND '{$today}' ORDER BY I_RATES.RATE_DATE";
$result = oci_parse($conn, $sql) or die("");
oci_execute($result);
if ($result) {
    //    $FC->addCategoryFromDatabase($result,"DESCRIPTION");
    //    $FC->addDatasetsFromDatabase($result,"DESCRIPTION","RATE");
    $FC->addDataFromDatabase($result, "RATE", "DATEY");
}
?>
Example #12
0
 function onrevokeComplainData()
 {
     //只查询转为投诉的问题
     $ConditionList['transformed'] = 1;
     $action = "index.php?admin_complain/revokeComplainData";
     $hasIntoComplainViewPrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "intoRevokeComplainData");
     $hasIntoComplainViewPrivilege['url'] = "?admin_main";
     !$hasIntoComplainViewPrivilege['return'] && __msg($hasIntoComplainViewPrivilege);
     $ConditionList['ComplainStartDate'] = isset($this->post['ComplainStartDate']) ? $this->post['ComplainStartDate'] : (isset($this->get[2]) ? $this->get[2] : date("Y-m-d", time() - 7 * 86400));
     $ConditionList['ComplainEndDate'] = isset($this->post['ComplainEndDate']) ? $this->post['ComplainEndDate'] : (isset($this->get[3]) ? $this->get[3] : date("Y-m-d", time()));
     $ConditionList['author'] = isset($this->post['author']) ? urldecode(trim($this->post['author'])) : (isset($this->get[4]) ? urldecode(trim($this->get[4])) : "");
     $ConditionList['author_id'] = isset($this->post['author_id']) ? trim($this->post['author_id']) : (isset($this->get[5]) ? trim($this->get[5]) : "");
     $ConditionList['operator_loginId'] = isset($this->post['operator_loginId']) ? trim($this->post['operator_loginId']) : (isset($this->get[6]) ? trim($this->get[6]) : "");
     $ConditionList['jid'] = isset($this->post['jid']) ? intval($this->post['jid']) : (isset($this->get[7]) ? intval($this->get[7]) : 0);
     $SellerTypeList = $this->ask_config->getSellerType();
     $ConditionList['sid'] = isset($this->post['sid']) ? intval($this->post['sid']) : (isset($this->get[8]) ? intval($this->get[8]) : -1);
     $J = $this->cache->get("Jlist_" . $ConditionList['sid']);
     if (false !== $J) {
         $Jlist = json_decode($J, true);
     } else {
         $Jlist = $_ENV['complain']->getJList($ConditionList['sid']);
         $this->cache->set("Jlist_" . $ConditionList['sid'], json_encode($Jlist), 1800);
     }
     $ConditionList['status'] = 2;
     $ConditionList['Assess'] = -1;
     $ConditionList['reason'] = isset($this->post['reason']) ? urldecode(trim($this->post['reason'])) : (isset($this->get[9]) ? urldecode(trim($this->get[9])) : "");
     $export = trim($this->get[10]) == "export" ? 1 : 0;
     $pagesize = $this->setting['list_default'];
     $pagesize = 20;
     $complainData = $_ENV['complain']->getRevokeComplainData($ConditionList);
     $downloadstr = page_url("<下载EXCEL表格>", "admin_complain/revokeComplainData/" . $ConditionList['ComplainStartDate'] . "/" . $ConditionList['ComplainEndDate'] . "/" . urlencode($ConditionList['author']) . "/" . $ConditionList['author_id'] . "/" . $ConditionList['operator_loginId'] . "/" . $ConditionList['jid'] . "/" . $ConditionList['sid'] . "/" . $ConditionList['reason'] . "/export");
     if (!$export) {
         $msg && ($message = $msg);
         $ty && ($type = $ty);
         # Include FusionCharts PHP Class
         include TIPASK_ROOT . '/lib/fusion/Includes/FusionCharts_Gen.php';
         $FC2 = new FusionCharts("Pie2d", '100%', '400');
         $FC2->setSWFPath('../Charts/');
         $strParam = "caption='撤销理由统计';xAxisName='理由';baseFontSize=12;numberPrefix=;numberSuffix=次;decimalPrecision=0;showValues=1;formatNumberScale=0;rotateNames=0;numDivLines=9;showAlternateHGridColor=1;alternateHGridAlpha=5;alternateHGridColor='CC3300';hoverCapSepChar=,";
         $FC2->setChartParams($strParam);
         $FC2->addDataset("撤销理由");
         foreach ($complainData['RevokeReasonList'] as $r => $data) {
             $complainData['RevokeReasonList'][$r]['rate'] = $complainData['totalData']['complainCount'] > 0 ? $data['revokeCount'] / $complainData['totalData']['complainCount'] : 0;
             $FC2->addChartData($data['revokeCount'], 'name="' . $data['content'] . '"');
         }
         $FC3 = new FusionCharts("Pie2d", '100%', '400');
         $FC3->setSWFPath('../Charts/');
         $strParam = "caption='交易类型统计';xAxisName='交易类型';baseFontSize=12;numberPrefix=;numberSuffix=次;decimalPrecision=0;showValues=1;formatNumberScale=0;rotateNames=0;numDivLines=9;showAlternateHGridColor=1;alternateHGridAlpha=5;alternateHGridColor='CC3300';hoverCapSepChar=,";
         $FC3->setChartParams($strParam);
         $FC3->addDataset("交易类型");
         $jlist = $_ENV['complain']->getJList(0);
         unset($jlist[0]);
         foreach ($complainData['jList'] as $j => $data) {
             $complainData['jList'][$j]['jName'] = isset($jlist[$j]) ? $jlist[$j] : "未定义交易类型" . $j;
             $complainData['jList'][$j]['rate'] = $complainData['totalData']['complainCount'] > 0 ? $data['revokeCount'] / $complainData['totalData']['complainCount'] : 0;
             $FC3->addChartData($data['revokeCount'], "name=" . $complainData['jList'][$j]['jName']);
         }
         $FC4 = new FusionCharts("Pie2d", '100%', '400');
         $FC4->setSWFPath('../Charts/');
         $strParam = "caption='用户身份类型统计';xAxisName='身份类型';baseFontSize=12;numberPrefix=;numberSuffix=次;decimalPrecision=0;showValues=1;formatNumberScale=0;rotateNames=0;numDivLines=9;showAlternateHGridColor=1;alternateHGridAlpha=5;alternateHGridColor='CC3300';hoverCapSepChar=,";
         $FC4->setChartParams($strParam);
         $FC4->addDataset("身份类型");
         $SellerTypeList = $this->ask_config->getSellerType();
         unset($slist[0]);
         foreach ($complainData['sList'] as $s => $data) {
             $complainData['sList'][$s]['sName'] = isset($SellerTypeList[$s]) ? $SellerTypeList[$s] : "未定义身份类型" . $s;
             $complainData['sList'][$s]['rate'] = $complainData['totalData']['complainCount'] > 0 ? $data['revokeCount'] / $complainData['totalData']['complainCount'] : 0;
             $FC4->addChartData($data['revokeCount'], "name=" . $complainData['sList'][$s]['sName']);
         }
     } else {
         set_time_limit(0);
         require TIPASK_ROOT . '/lib/Excel.php';
         $oExcel = new Excel();
         $FileName = '已撤销投诉统计下载';
         $oExcel->download($FileName);
         $oExcel->addSheet('撤销理由统计');
         //标题栏
         $title = array("撤销理由", "撤销次数", "问题占比");
         $oExcel->addRows(array($title));
         foreach ($complainData['RevokeReasonList'] as $r => $data) {
             $excelArr = array();
             $excelArr = array("reason" => $data['content'], "revokeCount" => $data['revokeCount'], "rate" => $complainData['totalData']['complainCount'] > 0 ? $data['revokeCount'] / $complainData['totalData']['complainCount'] : 0);
             $oExcel->addRows(array($excelArr));
         }
         $oExcel->closeSheet();
         $oExcel->addSheet('交易类型统计');
         //标题栏
         $title = array("交易类型", "撤销次数", "问题占比");
         $oExcel->addRows(array($title));
         $jlist = $_ENV['complain']->getJList(0);
         unset($jlist[0]);
         foreach ($complainData['jList'] as $j => $data) {
             $excelArr = array();
             $excelArr = array("jname" => isset($jlist[$j]) ? $jlist[$j] : "未定义交易类型" . $j, "revokeCount" => $data['revokeCount'], "rate" => $complainData['totalData']['complainCount'] > 0 ? $data['revokeCount'] / $complainData['totalData']['complainCount'] : 0);
             $oExcel->addRows(array($excelArr));
         }
         $oExcel->closeSheet();
         $oExcel->addSheet('身份类型统计');
         //标题栏
         $title = array("身份类型", "撤销次数", "问题占比");
         $oExcel->addRows(array($title));
         $SellerTypeList = $this->ask_config->getSellerType();
         unset($slist[0]);
         foreach ($complainData['sList'] as $s => $data) {
             $excelArr = array();
             $excelArr = array("sname" => isset($SellerTypeList[$s]) ? $SellerTypeList[$s] : "未定义身份类型" . $s, "revokeCount" => $data['revokeCount'], "rate" => $complainData['totalData']['complainCount'] > 0 ? $data['revokeCount'] / $complainData['totalData']['complainCount'] : 0);
             $oExcel->addRows(array($excelArr));
         }
         $oExcel->closeSheet();
         $oExcel->close();
     }
     include template('revokecomplaindata', 'admin');
 }
Example #13
0
 function onresponseDayDataStacked($msg = '', $ty = '')
 {
     //只查询转为投诉的问题
     $action = "index.php?admin_data/responseDayDataStacked";
     $hasIntoResponseDayStackedDataPrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "intoResponseDayStackedData");
     $hasIntoResponseDayStackedDataPrivilege['url'] = "?admin_main";
     !$hasIntoResponseDayStackedDataPrivilege['return'] && __msg($hasIntoResponseDayStackedDataPrivilege);
     $ConditionList['StartDate'] = isset($this->post['StartDate']) ? $this->post['StartDate'] : (isset($this->get[2]) ? $this->get[2] : date("Y-m-d", time() - 86400));
     $ConditionList['EndDate'] = isset($this->post['EndDate']) ? $this->post['EndDate'] : (isset($this->get[3]) ? $this->get[3] : date("Y-m-d", time() - 86400));
     $DepartmentList = $_ENV['department']->get_list();
     $ConditionList['DepartmentId'] = isset($this->post['DepartmentId']) ? intval($this->post['DepartmentId']) : (isset($this->get[4]) ? intval($this->get[4]) : 0);
     $QtypeList = $_ENV['qtype']->GetAllQType(0, '', 0);
     $ConditionList['QtypeId'] = 0;
     $export = trim($this->get[6]) == "export" ? 1 : 0;
     if (!$export) {
         $ResponseDayArr = $_ENV['question']->getResponseDay($ConditionList);
         foreach ($QtypeList as $Key => $QtypeInfo) {
             foreach ($ResponseDayArr as $Hour => $data) {
                 if (!isset($data['QtypeDetail'][$QtypeInfo['id']])) {
                     $ResponseDayArr[$Hour]['QtypeDetail'][$QtypeInfo['id']]['ReceiveCount'] = 0;
                 }
                 ksort($ResponseDayArr[$Hour]['QtypeDetail']);
             }
         }
         include TIPASK_ROOT . '/lib/fusion/Includes/FusionCharts_Gen.php';
         # Create Multiseries ColumnD chart object using FusionCharts PHP Class
         $FC = new FusionCharts("StackedColumn2D", '1200', '400');
         # Set the relative path of the swf file
         $FC->setSWFPath('../Charts/');
         # Store chart attributes in a variable
         $strParam = "caption='客服响应数据';xAxisName='时间段';baseFontSize=12;decimalPrecision=0;showValues=0;formatNumberScale=0;labelStep=1;numvdivlines={$divideV};rotateNames=0;yAxisMinValue=0;yAxisMaxValue=10;numDivLines=9;showAlternateHGridColor=1;alternateHGridAlpha=5;alternateHGridColor='CC3300';pYAxisName=客服;sYAxisName=客服响应数据;hoverCapSepChar=,";
         # Set chart attributes
         $FC->setChartParams($strParam);
         foreach ($ResponseDayArr as $Hour => $data) {
             $FC->addCategory($Hour . ":00");
         }
         foreach ($QtypeList as $Key => $QtypeInfo) {
             $FC->addDataset($QtypeInfo['name']);
             foreach ($ResponseDayArr as $Hour => $data) {
                 $FC->addChartData($data['QtypeDetail'][$QtypeInfo['id']]['ReceiveCount']);
             }
         }
         $downloadstr = page_url("<下载EXCEL表格>", "admin_data/responseDayDataStacked/" . $ConditionList['StartDate'] . "/" . $ConditionList['EndDate'] . "/" . $ConditionList['DepartmentId'] . "/" . $ConditionList['QtypeId'] . "/export");
         $msg && ($message = $msg);
         $ty && ($type = $ty);
     } else {
         set_time_limit(0);
         require TIPASK_ROOT . '/lib/Excel.php';
         $oExcel = new Excel();
         $FileName = $ConditionList['Date'] . '客服响应数据';
         $oExcel->download($FileName)->addSheet('客服响应数据');
         //标题栏
         $title = array("时间段");
         ksort($QtypeList);
         foreach ($QtypeList as $Key => $QtypeInfo) {
             $title[] = $QtypeInfo['name'];
         }
         $oExcel->addRows(array($title));
         $ResponseDayArr = $_ENV['question']->getResponseDay($ConditionList);
         foreach ($ResponseDayArr as $Hour => $HourInfo) {
             $excelArr = array("Hour" => $Hour . ":00");
             ksort($HourInfo['QtypeDetail']);
             foreach ($QtypeList as $Key => $QtypeInfo) {
                 $excelArr[$Key] = intval($HourInfo['QtypeDetail'][$Key]['ReceiveCount']);
             }
             $oExcel->addRows(array($excelArr));
         }
         $oExcel->closeSheet()->close();
     }
     include template('responseDayStacked', 'admin');
 }