/** * undocumented function * * @param string $options * @return void * @access public */ function yAxis($options) { $y = null; if (isset($options['y_axis'])) { $y = new y_axis(); $yOptions = $options['y_axis']; if (isset($yOptions['peaks'])) { $min = $yOptions['peaks'][0]; $max = $yOptions['peaks'][1]; $y->set_range(0, $max); if (isset($yOptions['num_steps'])) { $step = $this->ySteps($max, $yOptions['num_steps'], true); $y->set_steps($step); } } if (isset($yOptions['colors'])) { $col = $yOptions['colors'][0]; $gridCol = $yOptions['colors'][1]; $y->set_colours($col, $gridCol); } } return $y; }
//-----/end get ranges ----------------- // Prepare the x-axis $x = new x_axis(); $x->set_range($lowest, $highest); // Calculate the steps and visible steps $step = ($highest - $lowest) / 60; $step_vis = 2; // do not allow steps to be less than 30 minutes if ($step < 26400) { # 86400 $step = 26400; $step_vis = 1; } $x->set_steps($step); $labels = new x_axis_labels(); $labels->text('#date:Y-m-d#'); $labels->set_steps($step); $labels->visible_steps($step_vis); $labels->rotate(90); $x->set_labels($labels); // Prepare the y-axis $y = new y_axis(); // $maximum is already set above // set the range and y-step $y->set_range(0, $maximum + getIdealYSteps($maximum)); $y->set_steps(getIdealYSteps($maximum)); # $chart->add_element( $s ); $chart->set_x_axis($x); $chart->add_y_axis($y); // echo a pretty ofc-string anyway echo $chart->toPrettyString();
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; }
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); }
function result_screen($mode = 'reg') { global $month_names; $page_title = "Statistic Center Results"; $page_detail = " "; // ----------------------------------------- if (!checkdate($_POST['to_month'], $_POST['to_day'], $_POST['to_year'])) { die("The 'Date To:' time is incorrect, please check the input and try again"); } if (!checkdate($_POST['from_month'], $_POST['from_day'], $_POST['from_year'])) { die("The 'Date From:' time is incorrect, please check the input and try again"); } // ----------------------------------------- $to_time = mktime(12, 0, 0, $_POST['to_month'], $_POST['to_day'], $_POST['to_year']); $from_time = mktime(12, 0, 0, $_POST['from_month'], $_POST['from_day'], $_POST['from_year']); // $sql_date_to = date("Y-m-d",$to_time); // $sql_date_from = date("Y-m-d",$from_time); $human_to_date = getdate($to_time); $human_from_date = getdate($from_time); // ----------------------------------------- if ($mode == 'reg') { $table = 'Registration Statistics'; $sql_table = 'users'; $sql_field = 'added'; $page_detail = "Showing the number of users registered. (Note: All times based on GMT)"; } else { if ($mode == 'rate') { $table = 'Rating Statistics'; $sql_table = 'ratings'; $sql_field = 'added'; $page_detail = "Showing the number of ratings. (Note: All times based on GMT)"; } else { if ($mode == 'post') { $table = 'Post Statistics'; $sql_table = 'posts'; $sql_field = 'added'; $page_detail = "Showing the number of posts. (Note: All times based on GMT)"; } else { if ($mode == 'msg') { $table = 'PM Sent Statistics'; $sql_table = 'messages'; $sql_field = 'added'; $page_detail = "Showing the number of sent messages. (Note: All times based on GMT)"; } else { if ($mode == 'torr') { $table = 'Torrent Statistics'; $sql_table = 'torrents'; $sql_field = 'added'; $page_detail = "Showing the number of Torrents. (Note: All times based on GMT)"; } else { if ($mode == 'bans') { $table = 'Ban Statistics'; $sql_table = 'bans'; $sql_field = 'added'; $page_detail = "Showing the number of Bans. (Note: All times based on GMT)"; } else { if ($mode == 'comm') { $table = 'Comment Statistics'; $sql_table = 'comments'; $sql_field = 'added'; $page_detail = "Showing the number of torrent Comments. (Note: All times based on GMT)"; } else { if ($mode == 'new') { $table = 'News Statistics'; $sql_table = 'news'; $sql_field = 'added'; $page_detail = "Showing the number of News Items added. (Note: All times based on GMT)"; } else { if ($mode == 'poll') { $table = 'Poll Statistics'; $sql_table = 'polls'; $sql_field = 'added'; $page_detail = "Showing the number of Polls added. (Note: All times based on GMT)"; } else { if ($mode == 'rqst') { $table = 'Request Statistics'; $sql_table = 'requests'; $sql_field = 'added'; $page_detail = "Showing the number of Requests made. (Note: All times based on GMT)"; } } } } } } } } } } switch ($_POST['timescale']) { case 'daily': $sql_date = "%w %U %m %Y"; $php_date = "F jS - Y"; // $sql_scale = "DAY"; break; case 'monthly': $sql_date = "%m %Y"; $php_date = "F Y"; // $sql_scale = "MONTH"; break; default: // weekly $sql_date = "%U %Y"; $php_date = " [F Y]"; // $sql_scale = "WEEK"; break; } $sortby = isset($_POST['sortby']) ? mysql_real_escape_string($_POST['sortby']) : ""; // $sortby = sqlesc($sortby); $sqlq = "SELECT UNIX_TIMESTAMP(MAX({$sql_field})) as result_maxdate,\n\t\t\t\t COUNT(*) as result_count,\n\t\t\t\t DATE_FORMAT({$sql_field},'{$sql_date}') AS result_time\n\t\t\t\t FROM {$sql_table}\n\t\t\t\t WHERE UNIX_TIMESTAMP({$sql_field}) > '{$from_time}'\n\t\t\t\t AND UNIX_TIMESTAMP({$sql_field}) < '{$to_time}'\n\t\t\t\t GROUP BY result_time\n\t\t\t\t ORDER BY {$sql_field} {$sortby}"; $res = @mysql_query($sqlq); $running_total = 0; $max_result = 0; $results = array(); if (mysql_num_rows($res)) { while ($row = mysql_fetch_assoc($res)) { if ($row['result_count'] > $max_result) { $max_result = $row['result_count']; } $running_total += $row['result_count']; $results[] = array('result_maxdate' => $row['result_maxdate'], 'result_count' => $row['result_count'], 'result_time' => $row['result_time']); } include 'chart/php-ofc-library/open-flash-chart.php'; foreach ($results as $pOOp => $data) { $counts[] = (int) $data['result_count']; if ($_POST['timescale'] == 'weekly') { $labes[] = "Week #" . strftime("%W", $data['result_maxdate']) . "\n" . date($php_date, $data['result_maxdate']); } else { $labes[] = date($php_date, $data['result_maxdate']); } } $title = new title($page_title . "\n" . ucfirst($_POST['timescale']) . " " . $table . " " . $human_from_date['mday'] . " " . $month_names[$human_from_date['mon']] . " " . $human_from_date['year'] . " to " . $human_to_date['mday'] . " " . $month_names[$human_to_date['mon']] . " " . $human_to_date['year']); $chart = new open_flash_chart(); $chart->set_title($title); $line_1 = new line_hollow(); $line_1->set_values($counts); $line_1->set_key($table . " | Total: " . $running_total, 12); $line_1->set_halo_size(1); $line_1->set_width(2); $line_1->set_colour('#0099FF'); $line_1->set_dot_size(5); $chart->add_element($line_1); $x_labels = new x_axis_labels(); $x_labels->set_steps(2); $x_labels->set_vertical(); $x_labels->set_colour('#000000'); $x_labels->set_size(12); $x_labels->set_labels($labes); $x = new x_axis(); $x->set_colours('#A2ACBA', '#ECFFAF'); $x->set_steps(2); $x->set_labels($x_labels); $chart->set_x_axis($x); $y = new y_axis(); $y->set_steps(2); $y->set_colour('#A2ACBA'); $y->set_range(0, max($counts) + 5, 50); $chart->add_y_axis($y); $cont = $chart->toPrettyString(); // toFile($_SERVER["DOCUMENT_ROOT"]."/chart/","chart.json",$cont,false); // unset($cont); $html = "<script type=\"text/javascript\" src=\"chart/js/json/json2.js\"></script>"; $html .= "<script type=\"text/javascript\" src=\"chart/js/swfobject.js\"></script>"; $html .= "<script type=\"text/javascript\">\n\n\t\t\t\tfunction open_flash_chart_data()\n\t\t\t\t{\n\t\t\t\treturn JSON.stringify(data);\n\t\t\t\t}\n\n\t\t\t\tfunction findSWF(movieName) {\n\t\t\t\t if (navigator.appName.indexOf(\"Microsoft\")!= -1) {\n\t\t\t\t\treturn window[movieName];\n\t\t\t\t } else {\n\t\t\t\t\treturn document[movieName];\n\t\t\t\t }\n\t\t\t\t}\n\n\t\t\t\tvar data = " . $cont . ";\n\n\t\t\t\t\t swfobject.embedSWF(\"chart/open-flash-chart.swf\", \"my_chart\", \"800\", \"" . (max($counts) * 5 < 200 ? "250" : (max($counts) * 5 > 400 ? "400" : max($counts) * 5)) . "\", \"9.0.0\", \"expressInstall.swf\", {\"loading\":\"Please wait while the stats are loaded!\"} );\n\t\t\t\t\t </script>"; $html .= "<div id=\"my_chart\"></div>"; } else { $html .= "No results found\n"; } print $html . "<br />"; }
$bar->set_colour('#000000'); } else { if ($tmp[1] * -1 < 0) { $bar->set_colour('#900000'); } } } $datalist[] = $bar; } $title = new title("This month budget over/under"); $bar = new bar_3d(); $bar->set_values($datalist); $bar->set_tooltip('$#val#'); $y = new y_axis(); $y->set_range(round($min * 1.2), round($max * 1.2)); $y->set_steps(count($datalist) * 2); $y->set_label_text("\$#val#"); $x_labels = new x_axis_labels(); $x_labels->rotate(45); $x_labels->set_labels($labellist); $x = new x_axis(); $x->set_labels($x_labels); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($bar); $chart->set_x_axis($x); $chart->set_y_axis($y); $chart->set_bg_colour('#FFFFFF'); echo $chart->toPrettyString(); ?>