Ejemplo n.º 1
0
 /**
  * assign the chartdata object for open flash chart library
  * @param $config
  * @return unknown_type
  */
 function _setChartdata($config)
 {
     $model = $this->getModel();
     $rounds = $this->get('Rounds');
     $round_labels = array();
     foreach ($rounds as $r) {
         $round_labels[] = $r->name;
     }
     $division = $this->get('division');
     $data = $model->getDataByDivision($division->id);
     //create a line
     $length = count($rounds) - 0.5;
     $linewidth = $config['color_legend_line_width'];
     $lines = array();
     //$title = $division->name;
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     //colors defined for ranking table lines
     //todo: add support for more than 2 lines
     foreach ($this->colors as $color) {
         foreach ($rounds as $r) {
             for ($n = $color['from']; $n <= $color['to']; $n++) {
                 $lines[$color['color']][$n][] = $n;
             }
         }
     }
     //set lines on the graph
     foreach ($lines as $key => $value) {
         foreach ($value as $line => $key2) {
             $chart->add_element(hline($key, $length, $line, $linewidth));
         }
     }
     //load team1, first team in the dropdown
     $team = $this->team1;
     $d = new $config['dotstyle_1']();
     $d->size((int) $config['line1_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line1']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($team->rankings);
     $line->set_width((int) $config['line1_strength']);
     $line->set_key($team->name, 12);
     $line->set_colour($config['line1']);
     $line->on_show(new line_on_show($config['l_animation_1'], $config['l_cascade_1'], $config['l_delay_1']));
     $chart->add_element($line);
     //load team2, second team in the dropdown
     $team = $this->team2;
     $d = new $config['dotstyle_2']();
     $d->size((int) $config['line2_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line2']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($team->rankings);
     $line->set_width((int) $config['line2_strength']);
     $line->set_key($team->name, 12);
     $line->set_colour($config['line2']);
     $line->on_show(new line_on_show($config['l_animation_2'], $config['l_cascade_2'], $config['l_delay_2']));
     $chart->add_element($line);
     $x = new x_axis();
     if ($config['x_axis_label'] == 1) {
         $xlabels = new x_axis_labels();
         $xlabels->set_labels($round_labels);
         $xlabels->set_vertical();
     }
     $x->set_labels($xlabels);
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_CURVE_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(count($data), 1, -1);
     $y->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_CURVE_RANK'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     ob_clean();
     echo $chart->toString();
 }
Ejemplo n.º 2
0
}
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($hbar);
$step_count = $max_value > 0 ? $max_value / 10 : 1;
$x = new x_axis();
$x->set_offset(false);
$x->set_steps($max_value / 10);
$chart->set_x_axis($x);
$y = new y_axis();
$y->set_offset(true);
$y->set_labels($y_labels);
$chart->add_y_axis($y);
if (isset($yaxis_label)) {
    $y_legend = new y_legend($yaxis_label);
    $y_legend->set_style('{font-size: 20px; color: #000000}');
    $chart->set_y_legend($y_legend);
}
if (isset($xaxis_label)) {
    $x_legend = new x_legend($xaxis_label);
    $x_legend->set_style('{font-size: 20px; color: #000000}');
    $chart->set_x_legend($x_legend);
}
$chart->set_bg_colour("#f3f3f3");
$tooltip = new tooltip();
$tooltip->set_hover();
$tooltip->set_stroke(1);
$tooltip->set_colour("#000000");
$tooltip->set_background_colour("#ffffff");
$chart->set_tooltip($tooltip);
echo $chart->toPrettyString();
Ejemplo n.º 3
0
 function set_x_legend($title, $dimension, $color)
 {
     $legend = new x_legend($title);
     $legend->set_style('{font-size: ' . $dimension . 'px; color: ' . $color . '}');
     $this->x_legend = $legend;
 }
Ejemplo n.º 4
0
 /**
  * Build The 3-D Bar Gharph.
  *
  * @param  array  $params  assoc array of name/value pairs          
  *
  * @return object $chart   object of open flash chart.
  * @static
  */
 static function &bar_3dChart(&$params)
 {
     $chart = null;
     if (empty($params)) {
         return $chart;
     }
     // $params['values'] should contains the values for each
     // criteria defined in $params['criteria']
     $values = CRM_Utils_Array::value('values', $params);
     $criterias = CRM_Utils_Array::value('criteria', $params);
     if (!is_array($values) || empty($values) || !is_array($criterias) || empty($criterias)) {
         return $chart;
     }
     // get the required data.
     $xReferences = $xValueLabels = $xValues = $yValues = array();
     foreach ($values as $xVal => $yVal) {
         if (!is_array($yVal) || empty($yVal)) {
             continue;
         }
         $xValueLabels[] = (string) $xVal;
         foreach ($criterias as $criteria) {
             $xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
             $yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
         }
     }
     if (empty($xReferences)) {
         return $chart;
     }
     // get the currency.
     require_once 'CRM/Utils/Money.php';
     $config = CRM_Core_Config::singleton();
     $symbol = $config->defaultCurrencySymbol;
     // set the tooltip.
     $tooltip = CRM_Utils_Array::value('tip', $params, "{$symbol} #val#");
     $count = 0;
     foreach ($xReferences as $criteria => $values) {
         $toolTipVal = $tooltip;
         // for seperate tooltip for each criteria
         if (is_array($tooltip)) {
             $toolTipVal = CRM_Utils_Array::value($criteria, $tooltip, "{$symbol} #val#");
         }
         // create bar_3d object
         $xValues[$count] = new bar_3d();
         // set colour pattel
         $xValues[$count]->set_colour(self::$_colours[$count]);
         // define colur pattel with bar criterias
         $xValues[$count]->key((string) $criteria, 12);
         // define bar chart values
         $xValues[$count]->set_values(array_values($values));
         // set tooltip
         $xValues[$count]->set_tooltip($toolTipVal);
         $count++;
     }
     $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
     //set y axis parameters.
     $yMin = 0;
     // calculate max scale for graph.
     $yMax = ceil(max($yValues));
     if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
         $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
     }
     // if max value of y-axis <= 0, then set default values
     if ($yMax <= 0) {
         $ySteps = 1;
         $yMax = 5;
     } else {
         $ySteps = $yMax / 5;
     }
     // create x axis label obj.
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($xValueLabels);
     // set angle for labels.
     if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
         $xLabels->rotate($xLabelAngle);
     }
     // create x axis obj.
     $xAxis = new x_axis();
     $xAxis->set_labels($xLabels);
     //create y axis and set range.
     $yAxis = new y_axis();
     $yAxis->set_range($yMin, $yMax, $ySteps);
     // create chart title obj.
     $title = new title($chartTitle);
     // create chart.
     $chart = new open_flash_chart();
     // add x axis w/ labels to chart.
     $chart->set_x_axis($xAxis);
     // add y axis values to chart.
     $chart->add_y_axis($yAxis);
     // set title to chart.
     $chart->set_title($title);
     foreach ($xValues as $bar) {
         // add bar element to chart.
         $chart->add_element($bar);
     }
     // add x axis legend.
     if ($xName = CRM_Utils_Array::value('xname', $params)) {
         $xLegend = new x_legend($xName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($yName = CRM_Utils_Array::value('yname', $params)) {
         $yLegend = new y_legend($yName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_y_legend($yLegend);
     }
     return $chart;
 }
Ejemplo n.º 5
0
 function _setChartdata($config)
 {
     require_once JLG_PATH_SITE . '/assets/classes/open-flash-chart/open-flash-chart.php';
     $data = $this->get('ChartData');
     // Calculate Values for Chart Object
     $forSum = array();
     $againstSum = array();
     $matchDayGoalsCount = array();
     $round_labels = array();
     foreach ($data as $rw) {
         if (!$rw->homegoalspd) {
             $rw->homegoalspd = 0;
         }
         if (!$rw->guestgoalspd) {
             $rw->guestgoalspd = 0;
         }
         $homeSum[] = (int) $rw->homegoalspd;
         $awaySum[] = (int) $rw->guestgoalspd;
         // check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
         if (!$rw->homegoalspd && !$rw->guestgoalspd) {
             $matchDayGoalsCount[] = null;
         } else {
             $matchDayGoalsCount[] = (int) $rw->homegoalspd + $rw->guestgoalspd;
         }
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     if (!empty($homeSum) && !empty($awaySum)) {
         if ($config['home_away_stats']) {
             $bar1 = new $config['bartype_1']();
             $bar1->set_values($homeSum);
             $bar1->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_HOME') . ": #val#");
             $bar1->set_colour($config['bar1']);
             $bar1->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
             $bar1->set_key(JText::_('COM_JOOMLEAGUE_STATS_HOME'), 12);
             $bar2 = new $config['bartype_2']();
             $bar2->set_values($awaySum);
             $bar2->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_AWAY') . ": #val#");
             $bar2->set_colour($config['bar2']);
             $bar2->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
             $bar2->set_key(JText::_('COM_JOOMLEAGUE_STATS_AWAY'), 12);
             $chart->add_element($bar1);
             $chart->add_element($bar2);
         }
     }
     // total
     $d = new $config['dotstyle_3']();
     $d->size((int) $config['line3_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line3']);
     $d->tooltip(JText::_('COM_JOOMLEAGUE_STATS_TOTAL2') . ' #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($matchDayGoalsCount);
     $line->set_width((int) $config['line3_strength']);
     $line->set_key(JText::_('COM_JOOMLEAGUE_STATS_TOTAL'), 12);
     $line->set_colour($config['line3']);
     $line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
     $chart->add_element($line);
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_STATS_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(0, @max($matchDayGoalsCount) + 2, 1);
     $y->set_steps(round(@max($matchDayGoalsCount) / 8));
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_STATS_GOALS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->chartdata = $chart;
 }
 /**
  * build x & y axis
  */
 function buildxyAxis()
 {
     // add x axis legend.
     if ($this->xAxisName) {
         $xLegend = new x_legend($this->xAxisName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: left;}");
         $this->chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($this->yAxisName) {
         $yLegend = new y_legend($this->yAxisName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $this->chart->set_y_legend($yLegend);
     }
     // create x axis obj.
     $this->xAxis = new x_axis();
     $xLabels = $this->setXLabels();
     $this->xAxis->set_labels($xLabels);
     //create y axis and set range.
     $this->yAxis = new y_axis();
     $this->yAxis->set_range($this->yMin, $this->yMax, $this->ySteps);
 }
 function _setRankingChartdata($config)
 {
     require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
     //$data = $this->get('RankChartData');
     //some example data....fixme!!!
     $data_1 = array();
     $data_2 = array();
     for ($i = 0; $i < 6.2; $i += 0.2) {
         $data_1[] = sin($i) * 1.9 + 10;
     }
     for ($i = 0; $i < 6.2; $i += 0.2) {
         $data_2[] = sin($i) * 1.3 + 10;
     }
     $chart = new open_flash_chart();
     //***********
     //line 1
     $d = new $config['dotstyle_1']();
     $d->size((int) $config['line1_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line1']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($data_1);
     $line->set_width((int) $config['line1_strength']);
     ///$line->set_key($team->name, 12);
     $line->set_colour($config['line1']);
     $line->on_show(new line_on_show($config['l_animation_1'], $config['l_cascade_1'], $config['l_delay_1']));
     $chart->add_element($line);
     //Line 2
     $d = new $config['dotstyle_2']();
     $d->size((int) $config['line2_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line2']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($data_2);
     $line->set_width((int) $config['line2_strength']);
     //$line->set_key($team->name, 12);
     $line->set_colour($config['line2']);
     $line->on_show(new line_on_show($config['l_animation_2'], $config['l_cascade_2'], $config['l_delay_2']));
     $chart->add_element($line);
     //X-axis
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     //$x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     //Y-axis
     $y = new y_axis();
     $y->set_range(0, @max($data_1) + 2, 1);
     $y->set_steps(round(@max($data_1) / 8));
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_POINTS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->assignRef('rankingchartdata', $chart);
 }
Ejemplo n.º 8
0
                $date_stride = 5;
                $x_legend = new x_legend('Date (mm/dd)');
                $x_legend->set_style('{font-size:18px; font-family:Calibri; color:#121212}');
                $chart->set_x_legend($x_legend);
            } else {
                if ($num_data_points <= 100) {
                    $amt_stride = 2;
                    $date_stride = 10;
                    $x_legend = new x_legend('Date (mm/dd)');
                    $x_legend->set_style('{font-size:18px; font-family:Calibri; color:#121212}');
                    $chart->set_x_legend($x_legend);
                } else {
                    if ($num_data_points <= 250) {
                        $amt_stride = 5;
                        $date_stride = 15;
                        $x_legend = new x_legend('Date (mm/yy)');
                        $x_legend->set_style('{font-size:18px; font-family:Calibri; color:#121212}');
                        $chart->set_x_legend($x_legend);
                    }
                }
            }
        }
    }
}
$line = new line();
$returns = array();
$x_labels = array();
$amt_max = $total_data[0]->amount;
$amt_min = $total_data[0]->amount;
$amt_count = 0;
$date_count = 0;
Ejemplo n.º 9
0
 function netio()
 {
     function bit_to_kb($n)
     {
         return round($n / 1000, 2);
     }
     function bit_to_mb($n)
     {
         return round($n / 1000000, 2);
     }
     function get_data()
     {
         $recv_l = trim(shell_exec("cat /sys/class/net/eth0/statistics/rx_bytes")) / 8;
         sleep(1);
         $recv_n = trim(shell_exec("cat /sys/class/net/eth0/statistics/rx_bytes")) / 8;
         return $recv_n - $recv_l;
     }
     if (array_key_exists('netio', $_SESSION) && array_key_exists('recv_l', $_SESSION)) {
         if (count($_SESSION['netio']) == 10) {
             array_shift($_SESSION['netio']);
             $_SESSION['netio'][] = get_data();
         } else {
             $_SESSION['netio'][] = get_data();
             $_SESSION['recv_l'] = end($_SESSION['netio']);
         }
     } else {
         $_SESSION['netio'] = array(0, 0, 0, 0, 0, 0, 0, 0, 0);
         $_SESSION['netio'][] = get_data();
         $_SESSION['recv_l'] = end($_SESSION['netio']);
     }
     $data = $_SESSION['netio'];
     /*
       $data = array();
     
       for($i=0;$i<40;$i++){
       $data[] = rand(1000000,10000000);
       }
     */
     foreach (range(1, 10) as $i) {
         settype($i, 'string');
         $second[] = $i;
     }
     if (max($data) <= 1000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 1;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 10000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 10;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 100000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 100;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 1000000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 1000;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 10000000) {
         $data = array_map("bit_to_mb", $data);
         $y_axis_max = 10;
         $y_axis_key_text = " MB/s";
     } else {
         $data = array_map("bit_to_mb", $data);
         $y_axis_max = 100;
         $y_axis_key_text = " MB/s";
     }
     $y_axis_step = $y_axis_max / 5;
     $chart = new open_flash_chart();
     $title = new title("实时流量显示");
     $title->set_style("{font-size: 12px; color: #A2ACBA; text-align: center;}");
     $chart->set_title($title);
     #点是指曲线图上的顶点
     #		$d = new dot();
     #		$d->colour('#9C0E57')->size(3);
     $area = new area();
     #width是指曲线的宽度
     #		$area->set_width(3);
     #		$area->set_default_dot_style($d);
     $area->set_colour('#5B56B6');
     #value即曲线顶的值
     $area->set_values($data);
     #左上角的文字
     $area->set_key($y_axis_key_text, 10);
     $area->set_fill_colour('#CCCAAA');
     #设透明度
     $area->set_fill_alpha(0.3);
     #area设置结束,使用add_element方法把area加进来
     $chart->add_element($area);
     $chart->set_bg_colour('#FFFFFF');
     #设置label
     $x_labels = new x_axis_labels();
     $x_labels->set_steps(1);
     $x_labels->set_colour('#A2ACBA');
     $x_labels->set_labels($second);
     #设置X轴
     $x_axis = new x_axis();
     $x_axis->set_colour('#A2ACBA');
     $x_axis->set_grid_colour('#D7E4A3');
     $x_axis->set_offset(false);
     $x_axis->set_steps(1);
     $x_axis->set_labels($x_labels);
     $chart->set_x_axis($x_axis);
     #设置X轴的文件说明,即x_legend
     $legend_text = "当前网络流量 " . end($data) . $y_axis_key_text;
     $x_legend = new x_legend($legend_text);
     $x_legend->set_style('{font-size: 12px; color: #778877}');
     $chart->set_x_legend($x_legend);
     #设置轴
     $y_axis = new y_axis();
     $y_axis->set_range(0, $y_axis_max, $y_axis_step);
     $y_axis->labels = null;
     $y_axis->set_offset(false);
     $chart->add_y_axis($y_axis);
     header("Cache-Control: cache, must-revalidate");
     header("Pragma: public");
     echo $chart->toPrettyString();
 }
$chart->add_element($area);
$chart->add_element($area2);
$chart->add_element($area3);
$chart->add_element($candle);
$x_labels = new x_axis_labels();
$x_labels->set_steps(1);
$x_labels->rotate(30);
//ROTATE GRAPH LABELS
//$x_labels->set_vertical();
$x_labels->set_labels($period_label);
$x = new x_axis();
$x->set_grid_colour('#D7E4A3');
$x->set_offset($period_offset);
$x->set_steps(1);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
//
// LOOK:
//
$x_legend = new x_legend("{$period_start} to {$period_end}");
$x_legend->set_style('{font-size: 20px; }');
$chart->set_x_legend($x_legend);
//
// remove this when the Y Axis is smarter
//
$y = new y_axis();
$y->set_range($range_min_value, $range_max_value, $range_step);
$chart->add_y_axis($y);
echo $chart->toPrettyString();
require_once 'confy_close.php';
Ejemplo n.º 11
0
 function clientstatAction()
 {
     if (!$this->clientdashboardfilter()) {
         return;
     }
     $this->view->activeTab = 'clientstat';
     // process data for chart
     include 'open-flash-chart.php';
     $request = $this->getRequest();
     $this->view->campaign_id = $request->getParam('id');
     $campaignModel = new Campaign();
     $campaign = $campaignModel->fetchRow('id = ' . $this->view->campaign_id);
     $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign->id));
     //if session not exist, get data from webservice
     $reportMap = array();
     $array_data = $this->getReportCountbyCampaign($campaign, 0, $reportMap);
     $sum = 0;
     foreach ($array_data as $date) {
         $sum += $date;
     }
     $i = 0;
     $maxY = 0;
     foreach ($array_data as $date) {
         $array_data[$i] = round($date * 100 / $sum, 1);
         if ($array_data[$i] > $maxY) {
             $maxY = $array_data[$i];
         }
         $i++;
     }
     // create chart
     $array_create_date = array('0', '1', '2', '3', '4', '5', '6', '7');
     $title = new title("Kraft Spraks Comments");
     $title->set_style('{font-size: 14px; color: #FFFFFF; }');
     $max_y = floor($maxY / 10) * 10 + 10;
     $y = new y_axis();
     $y->set_range(0, $max_y, 10);
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($array_create_date);
     $x_labels->set_size(11);
     $x->set_labels($x_labels);
     $x->set_range(0, 7, 1);
     //There is a bug on the tooltip of bar: can not show #x_label#. So use bar_stack instead of bar here.
     $bar = new bar_filled();
     $array_bar_data[0] = new bar_value($array_data[0]);
     $array_bar_data[0]->set_colour('#606060');
     $array_bar_data[1] = new bar_value($array_data[1]);
     $array_bar_data[1]->set_colour('#BE3304');
     $array_bar_data[2] = new bar_value($array_data[2]);
     $array_bar_data[2]->set_colour('#F2B538');
     $array_bar_data[3] = new bar_value($array_data[3]);
     $array_bar_data[3]->set_colour('#EE7904');
     $array_bar_data[4] = new bar_value($array_data[4]);
     $array_bar_data[4]->set_colour('#D4FD32');
     $array_bar_data[5] = new bar_value($array_data[5]);
     $array_bar_data[5]->set_colour('#B4EB35');
     $array_bar_data[6] = new bar_value($array_data[6]);
     $array_bar_data[6]->set_colour('#B1D764');
     $array_bar_data[7] = new bar_value($array_data[7]);
     $array_bar_data[7]->set_colour('#A1C463');
     $bar->set_values($array_bar_data);
     //		$bar->set_tooltip('#x_label#: #val#');
     //		$bar = new bar_stack();
     //		$bar->set_colours(array( '#E2D66A', '#A0C361' ));
     //		foreach ($array_data as $date):
     //		$bar->append_stack(array((int)$date));
     //		endforeach;
     $bar->set_tooltip('#val#%');
     $x_legend = new x_legend('Positive');
     $x_legend->set_style('{font-size: 30px; color: #FFFFFF; }');
     $y_legend = new y_legend($this->view->translate('(%)'));
     $y_legend->set_style('{font-size: 30px; color: #FFFFFF;}');
     $tags = new ofc_tags();
     $tags->font("Verdana", 14)->align_x_right();
     $tag_y_value = -($max_y * 0.3);
     $t = new ofc_tag(6.6, $tag_y_value);
     $t->text($this->view->translate('Client_Report Positive'))->colour("#177A16");
     $tags->append_tag($t);
     $t2 = new ofc_tag(0.5, $tag_y_value);
     $t2->text($this->view->translate('Client_Report Negative'))->colour("#D88569");
     $tags->append_tag($t2);
     $t3 = new ofc_tag(-1, $max_y);
     $t3->text($this->view->translate('(%)'))->colour("#000000");
     $tags->append_tag($t3);
     $t4 = new ofc_tag(-0.7, $tag_y_value);
     $t4->text($this->view->translate('Client_Report No opinion'))->colour("#5D5D5D");
     $tags->append_tag($t4);
     $this->view->chart3 = new open_flash_chart();
     $this->view->chart3->set_title($title);
     $this->view->chart3->add_element($bar);
     $this->view->chart3->set_bg_colour('#FFFFFF');
     $this->view->chart3->set_x_axis($x);
     $this->view->chart3->set_y_axis($y);
     $this->view->chart3->set_x_legend($x_legend);
     $this->view->chart3->set_y_legend($y_legend);
     $this->view->chart3->add_element($tags);
 }
 /**
  * assign the chartdata object for open flash chart library
  * @param $config
  * @return unknown_type
  */
 function _setChartdata($config)
 {
     require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
     $data = $this->get('ChartData');
     // Calculate Values for Chart Object
     $forSum = array();
     $againstSum = array();
     $matchDayGoalsCount = array();
     $matchDayGoalsCount[] = 0;
     $round_labels = array();
     $matchDayGoalsCountMax = 0;
     foreach ($data as $rw) {
         if (!$rw->goalsfor) {
             $rw->goalsfor = 0;
         }
         if (!$rw->goalsagainst) {
             $rw->goalsagainst = 0;
         }
         $forSum[] = intval($rw->goalsfor);
         $againstSum[] = intval($rw->goalsagainst);
         // check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
         if (!$rw->goalsfor && !$rw->goalsagainst) {
             $matchDayGoalsCount[] = 0;
         } else {
             $matchDayGoalsCount[] = intval($rw->goalsfor + $rw->goalsagainst);
         }
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     $barfor = new $config['bartype_1']();
     $barfor->set_values($forSum);
     $barfor->set_tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_FOR') . ": #val#");
     $barfor->set_colour($config['bar1']);
     $barfor->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
     $barfor->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_FOR'), 12);
     $baragainst = new $config['bartype_2']();
     $baragainst->set_values($againstSum);
     $baragainst->set_tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_AGAINST') . ": #val#");
     $baragainst->set_colour($config['bar2']);
     $baragainst->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
     $baragainst->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_AGAINST'), 12);
     $chart->add_element($barfor);
     $chart->add_element($baragainst);
     // total
     $d = new $config['dotstyle_3']();
     $d->size((int) $config['line3_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line3']);
     $d->tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_TOTAL2') . ' #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values(array_slice($matchDayGoalsCount, 1));
     $line->set_width((int) $config['line3_strength']);
     $line->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_TOTAL'), 12);
     $line->set_colour($config['line3']);
     $line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
     $chart->add_element($line);
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_TEAMSTATS_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(0, max($matchDayGoalsCount) + 2, $config['y_axis_steps']);
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->assignRef('chartdata', $chart);
 }
Ejemplo n.º 13
0
 /**
  * Build The Bar Gharph.
  *
  * @param  array  $params  assoc array of name/value pairs          
  *
  * @return object $chart   object of open flash chart.
  * @static
  */
 static function &barChart(&$params)
 {
     $chart = null;
     if (empty($params)) {
         return $chart;
     }
     $values = CRM_Utils_Array::value('values', $params);
     if (!is_array($values) || empty($values)) {
         return $chart;
     }
     // get the required data.
     $xValues = $yValues = array();
     foreach ($values as $xVal => $yVal) {
         $yValues[] = (double) $yVal;
         // we has to have x values as string.
         $xValues[] = (string) $xVal;
     }
     $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
     //set y axis parameters.
     $yMin = 0;
     // calculate max scale for graph.
     $yMax = max($yValues);
     if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
         $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
     }
     $ySteps = $yMax / 5;
     // $bar = new bar( );
     // glass seem to be more cool
     $bar = new bar_glass();
     //set values.
     $bar->set_values($yValues);
     // call user define function to handle on click event.
     if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) {
         $bar->set_on_click($onClickFunName);
     }
     // get the currency.
     require_once 'CRM/Utils/Money.php';
     $config =& CRM_Core_Config::singleton();
     $symbol = $config->defaultCurrencySymbol;
     // set the tooltip.
     $bar->set_tooltip("{$symbol} #val#");
     // create x axis label obj.
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($xValues);
     // set angle for labels.
     if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
         $xLabels->rotate($xLabelAngle);
     }
     // create x axis obj.
     $xAxis = new x_axis();
     $xAxis->set_labels($xLabels);
     //create y axis and set range.
     $yAxis = new y_axis();
     $yAxis->set_range($yMin, $yMax, $ySteps);
     // create chart title obj.
     $title = new title($chartTitle);
     // create chart.
     $chart = new open_flash_chart();
     // add x axis w/ labels to chart.
     $chart->set_x_axis($xAxis);
     // add y axis values to chart.
     $chart->add_y_axis($yAxis);
     // set title to chart.
     $chart->set_title($title);
     // add bar element to chart.
     $chart->add_element($bar);
     // add x axis legend.
     if ($xName = CRM_Utils_Array::value('xname', $params)) {
         $xLegend = new x_legend($xName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($yName = CRM_Utils_Array::value('yname', $params)) {
         $yLegend = new y_legend($yName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_y_legend($yLegend);
     }
     return $chart;
 }