Пример #1
0
/**
 * reports_quick_graph() - Show a quick graph of data.
 *
 * @param		string	Graph title
 * @param		int		First query resource ID
 * @param		int		Second query resource ID
 * @param		string	The bar colors
 */
function reports_quick_graph($title, $sql1, $sql2, $bar_colors)
{
    $result1 = db_query($sql1);
    $result2 = db_query($sql2);
    if ($result1 && $result2 && db_numrows($result2) > 0) {
        $assoc_open = util_result_columns_to_assoc($result1);
        $assoc_all = util_result_columns_to_assoc($result2);
        while (list($key, $val) = each($assoc_all)) {
            $titles[] = $key;
            $all[] = $val;
            if ($assoc_open[$key]) {
                $open[] = $assoc_open[$key];
            } else {
                $open[] = 0;
            }
        }
        /*	       	for ($i=0; $i<db_numrows($result1); $i++) {
        			echo "$titles[$i]=>$opened[$i]/$all[$i]<br />";
        		}
        */
        $scale = graph_calculate_scale(array($opened, $all), 400);
        $props["scale"] = $scale;
        $props["cellspacing"] = 5;
        $props = hv_graph_defaults($props);
        start_graph($props, $titles);
        horizontal_multisection_graph($titles, array($open, $all), $bar_colors, $props);
        end_graph();
        print '<p /><br />';
        print '<table cellspacing="0" border="0"><tr align="center"><td width="15%">' . _('Key') . ':</td><td width="5%">(</td><td width="35%" style="background-color:' . $bar_colors[0] . '">' . _('Open') . '</td>' . '<td width="5%">/</td><td width="35%" style="background-color:' . $bar_colors[1] . '">' . _('All') . ' </td><td width="5%">)</td></tr></table>';
        print '<p />';
        //      		GraphResult($result,$title);
    } else {
        echo "<h2>" . _('No data found to report') . "</h2>";
    }
}
Пример #2
0
function html_graph($names, $values, $bars, $vals, $dvalues = 0, $dbars = 0)
{
    // set the error level on entry and exit so as not to interfear with anyone elses error checking.
    $er = error_reporting(1);
    // set the values that the user didn't
    $vals = hv_graph_defaults($vals);
    $html_graph_string = start_graph($vals, $names);
    if ($vals['type'] == 0) {
        $html_graph_string .= horizontal_graph($names, $values, $bars, $vals);
    } elseif ($vals['type'] == 1) {
        $html_graph_string .= vertical_graph($names, $values, $bars, $vals);
    } elseif ($vals['type'] == 2) {
        $html_graph_string .= double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars);
    } elseif ($vals['type'] == 3) {
        $html_graph_string .= double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars);
    }
    $html_graph_string .= end_graph();
    // Set the error level back to where it was.
    error_reporting($er);
    return $html_graph_string;
}