示例#1
0
function GraphIt($names, $values, $title)
{
    $counter = count($names);
    /*
    Can choose any color you wish
    */
    for ($i = 0; $i < $counter; $i++) {
        $bars[$i] = "#DEDEEE";
    }
    $counter = count($values);
    /*
     Figure the max_value passed in, so scale can be determined
    */
    $max_value = 0.0;
    for ($i = 0; $i < $counter; $i++) {
        if ($values[$i] > $max_value) {
            $max_value = $values[$i];
        }
    }
    if ($max_value < 1) {
        $max_value = 1;
    }
    /*
     I want my graphs all to be 800 pixels wide, so that is my divisor
    */
    //$scale = (int) (600/$max_value);
    $scale = 200 / $max_value;
    /*
    I create a wrapper table around the graph that holds the title
    */
    echo "<TABLE BGCOLOR=\"NAVY\" CELLSPACING=2 CELLPADDING=3>";
    echo "<TR><TD BGCOLOR=\"NAVY\"><FONT COLOR=WHITE><B>{$title}</TD></TR><TR><TD>";
    /*
    Create an associatve array to pass in. I leave most of it blank
    */
    $vals = array("vlabel" => "", "hlabel" => "", "type" => "0", "cellpadding" => "", "cellspacing" => "", "border" => "", "width" => "", "background" => "", "vfcolor" => "", "hfcolor" => "", "vbgcolor" => "", "hbgcolor" => "", "vfstyle" => "", "hfstyle" => "", "noshowvals" => "", "scale" => "{$scale}", "namebgcolor" => "", "valuebgcolor" => "", "namefcolor" => "", "valuefcolor" => "", "namefstyle" => "", "valuefstyle" => "", "doublefcolor" => "");
    /*
    This is the actual call to the HTML_Graphs class
    */
    html_graph($names, $values, $bars, $vals);
    echo "</TD></TR></TABLE>";
}
示例#2
0
function zen_banner_graph_daily($banner_id)
{
    global $db, $banner, $_GET;
    $year = isset($_GET['year']) ? $_GET['year'] : date('Y');
    $month = isset($_GET['month']) ? $_GET['month'] : date('n');
    $days = date('t', mktime(0, 0, 0, $month)) + 1;
    $stats = array();
    for ($i = 1; $i < $days; $i++) {
        $names[] = $i;
        $values[] = '0';
        $dvalues[] = '0';
    }
    $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as banner_day,\n\t                                     banners_shown as value, banners_clicked as dvalue\n\t\t\t\t\t\t\t\t\t\t from " . TABLE_BANNERS_HISTORY . "\n\t\t\t\t\t\t\t\t\t\t where banners_id = '" . (int) $banner_id . "'\n\t\t\t\t\t\t\t\t\t\t and month(banners_history_date) = '" . zen_db_input($month) . "'\n\t\t\t\t\t\t\t\t\t\t and year(banners_history_date) = '" . zen_db_input($year) . "'");
    while (!$banner_stats->EOF) {
        $names[$banner_stats->fields['banner_day'] - 1] = $banner_stats->fields['banner_day'];
        $values[$banner_stats->fields['banner_day'] - 1] = $banner_stats->fields['value'] ? $banner_stats->fields['value'] : '0';
        $dvalues[$banner_stats->fields['banner_day'] - 1] = $banner_stats->fields['dvalue'] ? $banner_stats->fields['dvalue'] : '0';
        $banner_stats->MoveNext();
    }
    $largest = @max($values);
    $bars = array();
    $dbars = array();
    for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
        $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
        $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
    }
    $graph_vals = @array('vlabel' => TEXT_BANNERS_DATA, 'hlabel' => sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner->fields['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year), 'type' => '3', 'cellpadding' => '', 'cellspacing' => '1', 'border' => '', 'width' => '', 'vfcolor' => '#ffffff', 'hfcolor' => '#ffffff', 'vbgcolor' => '#81a2b6', 'hbgcolor' => '#81a2b6', 'vfstyle' => 'Verdana, Arial, Helvetica', 'hfstyle' => 'Verdana, Arial, Helvetica', 'scale' => 100 / $largest, 'namebgcolor' => '#f3f5fe', 'valuebgcolor' => '#f3f5fe', 'namefcolor' => '', 'valuefcolor' => '#0000d0', 'namefstyle' => 'Verdana, Arial, Helvetica', 'valuefstyle' => '', 'doublefcolor' => '#ff7339');
    return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}
/**
 * draws a double vertical bar graph for the banner views vs clicks statistics
 *
 * @param $banner_id
 * @return string
 */
function oosBannerGraphDaily($banner_id)
{
    global $banner;
    $year = $_GET['year'] ? $_GET['year'] : date('Y');
    $month = $_GET['month'] ? $_GET['month'] : date('n');
    $days = date('t', mktime(0, 0, 0, $month)) + 1;
    $stats = array();
    for ($i = 1; $i < $days; $i++) {
        $names[] = $i;
        $values[] = '0';
        $dvalues[] = '0';
    }
    // Get database information
    $dbconn =& oosDBGetConn();
    $oostable =& oosDBGetTables();
    $query = "SELECT dayofmonth(banners_history_date) as banner_day,\n                     banners_shown as value, banners_clicked as dvalue\n              FROM " . $oostable['banners_history'] . " \n              WHERE banners_id = '" . $banner_id . "'\n                AND month(banners_history_date) = '" . $month . "'\n                AND year(banners_history_date) = '" . $year . "'";
    $result =& $dbconn->Execute($query);
    while ($banner_stats = $result->fields) {
        $names[$banner_stats['banner_day'] - 1] = $banner_stats['banner_day'];
        $values[$banner_stats['banner_day'] - 1] = $banner_stats['value'] ? $banner_stats['value'] : '0';
        $dvalues[$banner_stats['banner_day'] - 1] = $banner_stats['dvalue'] ? $banner_stats['dvalue'] : '0';
        // Move that ADOdb pointer!
        $result->MoveNext();
    }
    // Close result set
    $result->Close();
    $largest = @max($values);
    $bars = array();
    $dbars = array();
    for ($i = 0, $n = count($values); $i < $n; $i++) {
        $bars[$i] = OOS_IMAGES . 'graph_hbar_blue.gif';
        $dbars[$i] = OOS_IMAGES . 'graph_hbar_red.gif';
    }
    $graph_vals = @array('vlabel' => TEXT_BANNERS_DATA, 'hlabel' => sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year), 'type' => '3', 'cellpadding' => '', 'cellspacing' => '1', 'border' => '', 'width' => '', 'vfcolor' => '#ffffff', 'hfcolor' => '#ffffff', 'vbgcolor' => '#81a2b6', 'hbgcolor' => '#81a2b6', 'vfstyle' => 'Verdana, Arial, Helvetica', 'hfstyle' => 'Verdana, Arial, Helvetica', 'scale' => 100 / $largest, 'namebgcolor' => '#f3f5fe', 'valuebgcolor' => '#f3f5fe', 'namefcolor' => '', 'valuefcolor' => '#0000d0', 'namefstyle' => 'Verdana, Arial, Helvetica', 'valuefstyle' => '', 'doublefcolor' => '#ff7339');
    return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}
示例#4
0
/**
 * GraphIt() - Build a graph
 *
 * @author Tim Perdue tperdue@valinux.com
 * @param		array	An array of names
 * @param		array	An array of values
 * @param		string	The title of the graph
 *
 */
function GraphIt($name_string, $value_string, $title)
{
    global $HTML;
    $counter = count($name_string);
    /*
    	Can choose any color you wish
    */
    $bars = array();
    for ($i = 0; $i < $counter; $i++) {
        $bars[$i] = $HTML->COLOR_LTBACK1;
    }
    $counter = count($value_string);
    /*
    	Figure the max_value passed in, so scale can be determined
    */
    $max_value = 0;
    for ($i = 0; $i < $counter; $i++) {
        if ($value_string[$i] > $max_value) {
            $max_value = $value_string[$i];
        }
    }
    if ($max_value < 1) {
        $max_value = 1;
    }
    /*
    	I want my graphs all to be 800 pixels wide, so that is my divisor
    */
    $scale = 400 / $max_value;
    /*
    	I create a wrapper table around the graph that holds the title
    */
    $title_arr = array();
    $title_arr[] = $title;
    echo $GLOBALS['HTML']->listTableTop($title_arr);
    echo '<tr><td>';
    /*
    	Create an associate array to pass in. I leave most of it blank
    */
    $vals = array('vlabel' => '', 'hlabel' => '', 'type' => '', 'cellpadding' => '', 'cellspacing' => '0', 'border' => '', 'width' => '', 'background' => '', 'vfcolor' => '', 'hfcolor' => '', 'vbgcolor' => '', 'hbgcolor' => '', 'vfstyle' => '', 'hfstyle' => '', 'noshowvals' => '', 'scale' => $scale, 'namebgcolor' => '', 'valuebgcolor' => '', 'namefcolor' => '', 'valuefcolor' => '', 'namefstyle' => '', 'valuefstyle' => '', 'doublefcolor' => '');
    /*
    	This is the actual call to the HTML_Graphs class
    */
    html_graph($name_string, $value_string, $bars, $vals);
    echo '
		</td></tr>
		<!-- end outer graph table -->';
    echo $GLOBALS['HTML']->listTableBottom();
}
示例#5
0
function GraphIt($name_string, $value_string, $title)
{
    /*
    	GraphIt by Tim Perdue, PHPBuilder.com
    */
    $counter = count($name_string);
    /*
    	Can choose any color you wish
    */
    $bars = array();
    for ($i = 0; $i < $counter; $i++) {
        $bars[$i] = util_get_image_theme('bargraph.png');
    }
    $counter = count($value_string);
    /*
    	Figure the max_value passed in, so scale can be determined
    */
    $max_value = 0;
    for ($i = 0; $i < $counter; $i++) {
        if ($value_string[$i] > $max_value) {
            $max_value = $value_string[$i];
        }
    }
    if ($max_value < 1) {
        $max_value = 1;
    }
    /*
    	I want my graphs all to be 800 pixels wide, so that is my divisor
    */
    $scale = 400 / $max_value;
    /*
    	I create a wrapper table around the graph that holds the title
    */
    $title_arr = array();
    $title_arr[] = $title;
    echo html_build_list_table_top($title_arr);
    echo '<TR><TD>';
    /*
    	Create an associate array to pass in. I leave most of it blank
    */
    $vals = array('vlabel' => '', 'hlabel' => '', 'type' => '', 'cellpadding' => '', 'cellspacing' => '0', 'border' => '', 'width' => '', 'background' => '', 'vfcolor' => '', 'hfcolor' => '', 'vbgcolor' => '', 'hbgcolor' => '', 'vfstyle' => '', 'hfstyle' => '', 'noshowvals' => '', 'scale' => $scale, 'namebgcolor' => '', 'valuebgcolor' => '', 'namefcolor' => '', 'valuefcolor' => '', 'namefstyle' => '', 'valuefstyle' => '', 'doublefcolor' => '');
    /*
    	This is the actual call to the HTML_Graphs class
    */
    html_graph($name_string, $value_string, $bars, $vals);
    echo '
		</TD></TR></TABLE>
		<!-- end outer graph table -->';
}
function olc_banner_graph_daily($banner_id)
{
    global $banner;
    $year = $_GET['year'] ? $_GET['year'] : date('Y');
    $month = $_GET['month'] ? $_GET['month'] : date('n');
    $days = date('t', mktime(0, 0, 0, $month)) + 1;
    $stats = array();
    for ($i = 1; $i < $days; $i++) {
        $names[] = $i;
        $values[] = '0';
        $dvalues[] = '0';
    }
    $banner_stats_query = olc_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . APOS);
    while ($banner_stats = olc_db_fetch_array($banner_stats_query)) {
        $names[$banner_stats['banner_day'] - 1] = $banner_stats['banner_day'];
        $values[$banner_stats['banner_day'] - 1] = $banner_stats['value'] ? $banner_stats['value'] : '0';
        $dvalues[$banner_stats['banner_day'] - 1] = $banner_stats['dvalue'] ? $banner_stats['dvalue'] : '0';
    }
    $largest = @max($values);
    $bars = array();
    $dbars = array();
    for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
        $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
        $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
    }
    $graph_vals = @array('vlabel' => TEXT_BANNERS_DATA, 'hlabel' => sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year), 'type' => '3', 'cellpadding' => '', 'cellspacing' => '1', 'border' => '', 'width' => '', 'vfcolor' => '#ffffff', 'hfcolor' => '#ffffff', 'vbgcolor' => '#81a2b6', 'hbgcolor' => '#81a2b6', 'vfstyle' => 'Verdana, Arial, Helvetica', 'hfstyle' => 'Verdana, Arial, Helvetica', 'scale' => 100 / $largest, 'namebgcolor' => '#f3f5fe', 'valuebgcolor' => '#f3f5fe', 'namefcolor' => '', 'valuefcolor' => '#0000d0', 'namefstyle' => 'Verdana, Arial, Helvetica', 'valuefstyle' => '', 'doublefcolor' => '#ff7339');
    return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}