コード例 #1
0
 public function get_jx_json_bar($info, $type = '')
 {
     $year = array_keys($info);
     $price = array_values($info);
     $chart = new open_flash_chart();
     $chart->set_bg_colour('#FFFFFF');
     //flash背景颜色
     $x_labels = new x_axis_labels();
     $x_labels->set_steps(1);
     $x_labels->set_size(12);
     $x_labels->set_colour('#000000');
     if (count($year) > 0) {
         $x_labels->set_vertical();
     }
     $x_labels->set_labels($year);
     //		// 插入数据
     $x = new x_axis();
     $x->set_colour('#000000');
     $x->set_grid_colour('#dadada');
     $x->set_offset(true);
     $x->set_steps(1);
     // Add the X Axis Labels to the X Axis
     $x->set_labels($x_labels);
     $x->set_offset(true);
     $chart->set_x_axis($x);
     //		$bar = new bar_filled( '#74b1e0', '#9dc7e8' );
     //		$bar->set_values( $price );
     $price_array = array();
     foreach ($price as $k => $v) {
         $price_array[$k] = new bar_value($v);
         $price_array[$k]->set_colour('#74b1e0');
         if ($type == 'percent') {
             //$y->set_label_text("#val#%");
             $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v) . '%');
         } else {
             $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v));
         }
     }
     $bar = new bar_glass();
     $bar->set_values($price_array);
     $chart->add_element($bar);
     //
     // LOOK:
     //
     //$x_legend = new x_legend( '1983 to 2008' );
     //$x_legend->set_style( '{font-size: 20px; color: #778877}' );
     //$chart->set_x_legend( $x_legend );
     //
     // remove this when the Y Axis is smarter
     //
     $y = new y_axis();
     $max = $this->get_the_right_y(max($price));
     $max = $max > 0 ? $max : 1;
     $y->set_range(0, ($max / 5 + 1) * 5, $max / 5 + 1);
     //		if ($max > 20 && $max <= 100) {
     //
     //			$y->set_range(0, $max, 10);
     //		}elseif($max >= 10&&$max<=20){
     //			$y->set_range(0, $max, 5);
     //		}
     //		else {
     //			$y->set_range(0, $max);
     //		}
     $y->set_colour('#000000');
     $y->set_grid_colour('#dadada');
     if ($type == 'percent') {
         $y->set_label_text("       #val#%");
     } else {
         $y->set_label_text("       #val#");
     }
     $chart->add_y_axis($y);
     $info = $chart->toPrettyString();
     return $info;
 }
コード例 #2
0
function result_screen($mode = 'reg')
{
    global $month_names;
    $page_title = "Statistic Center Results";
    $page_detail = "&nbsp;";
    // -----------------------------------------
    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 />";
}
コード例 #3
0
ファイル: multibar.php プロジェクト: Niladri123456/Tutorial
}
$title = new title("Page Views using " . $br . " browser between date " . $dt);
$bar = new bar_glass(55, '#D54C78', '#C31812');
include_once 'db.php';
$q = mysql_query("select count(c_browser) as tot from tracker where c_id=1234 and c_browser='" . $br . "' and " . $dateRange);
$bar->set_values(array(1245, 1202, 455, 120, 3652, 454, 121, 452, 1023, 1054, 1500, 1245, 1278, 123, 6598, 6547, 6589, 6999, 7854, 7562, 5478, 1200, 1254, 1562, 5415, 2587, 4589));
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$x = new x_axis();
$x->set_range(0, 31, 1);
$chart->set_x_axis($x);
$chart->set_y_axis($x);
$y = new y_axis();
$y->set_stroke(3);
$y->set_colour('#000000');
$y->set_tick_length(7);
$y->set_grid_colour('#000000');
// grid steps:
$y->set_range(0, 10000, 1000);
//$y_labels = new y_axis_labels();
//$y_labels->set_labels( array('Zero','One','Two','Three','Four','Five','Six','Seven','Eight') );
// visible labels steps:
//$y_labels->set_steps(4);
//$y->set_labels($y_labels);
//
// Add the Y Axis object to the chart:
//
$chart->set_y_axis($y);
$chart->set_bg_colour('#FFFFCC');
//
コード例 #4
0
 $G_MesCouleurs = array('#D080C0', '#EF00FF', '#F04040', '#008080', '#104080', '#2F8080', '#30FF80', '#4080FF', '#5F80C0', '#6F0000', '#7080FF', '#800040', '#9F0080', '#A04000', '#BF8000', '#C08000', '#0A00FF', '#1A0040', '#2A0080', '#3A00FF', '#4A0000', '#5A4000', '#6A4000', '#7A4040', '#8A0080', '#9A0040', '#AA0080', '#BA0000', '#CA8000', '#DA8040', '#EA8080');
 $tab_libelles2 = array();
 $data_val2 = array();
 if (sizeof($listeJeux) > 3) {
     for ($j = 0; $j < sizeof($listeJoueurs); $j++) {
         $tab_libelles2[] = $listeJoueurs[$j]['nom'];
         for ($i = sizeof($listeJeux) - 3; $i < sizeof($listeJeux); $i++) {
             $data_val2[$i][] = $G_ListeResultatsMoyens[$i][$j];
         }
     }
 }
 // Ordonnées
 $y2 = new y_axis();
 $y2->set_range($valmin, $valmax, 5);
 $y2->set_stroke(2);
 $y2->set_colour("#d000d0");
 // ToolTip
 $t2 = new tooltip();
 $t2->set_shadow(true);
 $t2->set_stroke(2);
 $t2->set_colour("#6E604F");
 $t2->set_background_colour("#BDB396");
 $t2->set_title_style("{font-size: 14px; color: #CC2A43;}");
 $t2->set_body_style("{font-size: 10px; font-weight: bold; color: #000000;}");
 // titre des absisses
 //$x_labels = new x_axis_labels();
 //$x_labels->set_steps( 1 );
 //$x_labels->set_vertical();
 //$x_labels->set_labels( $tab_libelles );
 //$x_labels->set_vertical();
 // Nouveau grAphique
コード例 #5
0
ファイル: func.php プロジェクト: kipkaev55/asterisk
function get_linear_graph($dates, $vals, $keys = array())
{
    include 'php-ofc-library/open-flash-chart.php';
    $max_y = 0;
    $arr_filled = array();
    for ($i = 0; $i < count($dates); $i++) {
        $year[] = $dates[$i];
        for ($m = 0; $m < count($vals); $m++) {
            $price[$m][] = (int) $vals[$m][$i];
            if ($max_y < (int) $vals[$m][$i]) {
                $max_y = (int) $vals[$m][$i];
            }
            if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) {
                @($arr_filled[$m] = (int) $vals[$m][$i]);
            }
        }
    }
    while ($max_y % 10 != 0) {
        $max_y++;
    }
    $chart = new open_flash_chart();
    //$title = new title( 'UK Petrol price (pence) per Litre' );
    $d = new anchor();
    if (count($dates) > 60) {
        $d->size(2);
    } else {
        $d->size(3);
    }
    $d->halo_size(1);
    $d->colour('#3D5C56');
    $d->rotation(0);
    $d->sides(4);
    for ($i = 0; $i < count($price); $i++) {
        if ($arr_filled[$i] == 0) {
            continue;
        }
        if ($i == 0) {
            $color = '#5E0722';
        } elseif ($i == 1) {
            $color = '#00FF00';
        } else {
            $color = '#FF0000';
        }
        $area = new area();
        $area->set_colour($color);
        $area->set_default_dot_style($d);
        $area->set_values($price[$i]);
        if (isset($keys[$i])) {
            $area->set_key($keys[$i], 12);
        }
        // mb_convert_encoding($keys[$i], "UTF-8", "Windows-1251")
        $area->set_width(2);
        $chart->add_element($area);
    }
    $x_labels = new x_axis_labels();
    if (count($dates) > 40) {
        $x_labels->set_steps(7);
    } else {
        $x_labels->set_steps(1);
    }
    $x_labels->set_vertical();
    $x_labels->set_colour('#000000');
    $x_labels->set_labels($year);
    $x_labels->rotate(-55);
    $x_labels->set_size(12);
    $x = new x_axis();
    $x->set_colour('#000000');
    $x->set_grid_colour('#DDDDDD');
    //$x->set_offset( false );
    $x->set_steps(1);
    // Add the X Axis Labels to the X Axis
    $x->set_labels($x_labels);
    $chart->set_x_axis($x);
    $y = new y_axis();
    $y->set_range(0, $max_y);
    $y->set_colour('#000000');
    $y->set_grid_colour('#DDDDDD');
    $chart->add_y_axis($y);
    $chart->set_bg_colour("#FFFFFF");
    ?>


<script type="text/javascript" src="script/json/json2.js"></script>
<script type="text/javascript" src="script/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0");
</script>

<script type="text/javascript">

function ofc_ready()
{

}

function open_flash_chart_data()
{
	return JSON.stringify(data);
}

function findSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft")!= -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

var data = <?php 
    echo $chart->toPrettyString();
    ?>
;

</script>
<?php 
}