示例#1
1
文件: chart.php 项目: horrabin/opendb
function build_and_send_graph($data_rs, $chartType, $title)
{
    $gdImage = new GDImage(get_opendb_image_type());
    $imgType = $gdImage->getImageType();
    unset($gdImage);
    $graphCfg = _theme_graph_config();
    $chart = new StatsChartImpl($chartType, $graphCfg);
    $chart->setTitle($title);
    if (is_array($data_rs)) {
        usort($data_rs, "sort_data_element");
        // only show first 12 items - otherwise graph will not render correctly.
        if ($chartType == 'piechart' && count($data_rs) > 12) {
            $data_rs = array_slice($data_rs, 0, 11);
        }
        reset($data_rs);
        while (list(, $data_r) = each($data_rs)) {
            if ($chartType == 'piechart') {
                $chart->addData($data_r['display'] . " ({$data_r['value']})", $data_r['value']);
            } else {
                $chart->addData($data_r['display'], $data_r['value']);
            }
        }
    }
    $chart->render($imgType);
}
示例#2
0
文件: stats.php 项目: horrabin/opendb
 echo _theme_header(get_opendb_lang_var('statistics'));
 echo "<h2>" . get_opendb_lang_var('statistics') . "</h2>";
 build_review_stats();
 build_borrower_stats();
 build_item_stats();
 $item_type_rs = get_item_type_totals_rs();
 if (count($item_type_rs) > 0) {
     echo "<div class=\"tabContainer\">";
     echo "<ul class=\"tabMenu\" id=\"tab-menu\">";
     echo "<li id=\"menu-breakdown\" class=\"first activeTab\" onclick=\"return activateTab('breakdown', 'tab-menu', 'tab-content', 'activeTab', 'tabContent')\">" . get_opendb_lang_var('overview') . "</li>";
     reset($item_type_rs);
     while (list(, $item_type_r) = each($item_type_rs)) {
         echo "<li id=\"menu-{$item_type_r['s_item_type']}\" onclick=\"return activateTab('{$item_type_r['s_item_type']}', 'tab-menu', 'tab-content', 'activeTab', 'tabContent')\">{$item_type_r['s_item_type']}</li>";
     }
     echo "</ul>";
     $graphCfg = _theme_graph_config();
     $chartLib = get_opendb_config_var('stats', 'chart_lib');
     if ($chartLib != 'legacy') {
         $widthHeightAttribs = "width=\"{$graphCfg['width']}\" height=\"{$graphCfg['height']}\"";
     }
     echo "<div id=\"tab-content\">";
     echo "\n<div class=\"tabContent\" id=\"breakdown\">";
     echo "<ul class=\"graph\">";
     echo "<li>" . render_chart_image('item_ownership') . "</li>";
     echo "<li>" . render_chart_image('item_types') . "</li>";
     echo "<li>" . render_chart_image('categories') . "</li>";
     echo "</ul>";
     echo "</div>";
     reset($item_type_rs);
     while (list(, $item_type_r) = each($item_type_rs)) {
         echo "\n<div class=\"tabContentHidden\" id=\"{$item_type_r['s_item_type']}\">";
示例#3
0
function render_chart_image($graphType, $itemType = NULL)
{
    $graphCfg = _theme_graph_config();
    $chartLib = get_opendb_config_var('stats', 'chart_lib');
    if ($chartLib != 'legacy') {
        $widthHeightAttribs = "width=\"{$graphCfg['width']}\" height=\"{$graphCfg['height']}\"";
    }
    $altText = get_chart_alt_text($graphType, $itemType);
    return "<img src=\"stats.php?op=graph&graphtype={$graphType}" . (strlen($itemType) > 0 ? "&s_item_type=" . urlencode($itemType) : "") . "\" {$widthHeightAttribs} alt=\"{$altText}\">";
}