# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package MantisBT
 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */
/**
 * MantisBT Core API's
 */
require_once 'core.php';
require_once 'graph_api.php';
access_ensure_project_level(config_get('view_summary_threshold'));
$f_width = gpc_get_int('width', 300);
$t_token = token_get_value(TOKEN_GRAPH);
if ($t_token == null) {
    $t_metrics = create_bug_enum_summary(lang_get('priority_enum_string'), 'priority');
} else {
    $t_metrics = graph_total_metrics(unserialize($t_token));
}
graph_pie($t_metrics, plugin_lang_get('by_priority_pct'), $f_width, $f_width);
Exemple #2
0
function graph_group($p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_height = 400, $p_baseline = 100)
{
    # $p_metrics is an array of three arrays
    #   $p_metrics['open'] = array( 'enum' => value, ...)
    #   $p_metrics['resolved']
    #   $p_metrics['closed']
    $t_graph_font = graph_get_font();
    # count up array portions that are set
    $t_count = 0;
    foreach (array('open', 'resolved', 'closed') as $t_label) {
        if (isset($p_metrics[$t_label]) && is_array($p_metrics[$t_label])) {
            $t_count += array_sum($p_metrics[$t_label]);
        }
    }
    error_check($t_count, $p_title);
    # calculate totals
    $total = graph_total_metrics($p_metrics);
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphBarChart();
        $graph->title = $p_title;
        $graph->background->color = '#FFFFFF';
        $graph->options->font = $t_graph_font;
        $graph->options->font->maxFontSize = 12;
        $graph->legend = false;
        foreach (array('open', 'resolved', 'closed') as $t_label) {
            $graph->data[$t_label] = new ezcGraphArrayDataSet($p_metrics[$t_label]);
        }
        $graph->data['total'] = new ezcGraphArrayDataSet($total);
        //$graph->data['total']->displayType = ezcGraph::LINE;
        //$graph->data['total']->barMargin = -20;
        $graph->options->fillLines = 210;
        $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
        $graph->xAxis->axisLabelRenderer->angle = 45;
        $graph->driver = new ezcGraphGdDriver();
        //$graph->driver->options->supersampling = 1;
        $graph->driver->options->jpegQuality = 100;
        $graph->driver->options->imageFormat = IMG_JPEG;
        $graph->renderer->options->syncAxisFonts = false;
        $graph->renderToOutput($p_graph_width, $p_graph_height);
    } else {
        # defines margin according to height
        $graph = new Graph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(45, 35, 35, $p_baseline);
        if (ON == plugin_config_get('jpgraph_antialias')) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetScale('textlin');
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->title->Set($p_title);
        $graph->xaxis->SetTickLabels(array_keys($p_metrics['open']));
        if (FF_FONT2 <= $t_graph_font) {
            $graph->xaxis->SetLabelAngle(60);
        } else {
            $graph->xaxis->SetLabelAngle(90);
            # can't rotate non truetype fonts
        }
        $graph->xaxis->SetFont($t_graph_font);
        $graph->legend->Pos(0.05, 0.08);
        $graph->legend->SetFont($t_graph_font);
        $graph->yaxis->scale->ticks->SetDirection(-1);
        $graph->yaxis->SetFont($t_graph_font);
        $graph->yscale->SetGrace(10);
        # adds on the same graph
        $tot = new BarPlot(array_values($total));
        $tot->SetFillColor('lightblue');
        $tot->SetWidth(0.7);
        $tot->SetLegend(plugin_lang_get('legend_total'));
        $graph->Add($tot);
        $p1 = new BarPlot(array_values($p_metrics['open']));
        $p1->SetFillColor('yellow');
        $p1->SetWidth(1);
        $p1->SetLegend(plugin_lang_get('legend_opened'));
        $p2 = new BarPlot(array_values($p_metrics['closed']));
        $p2->SetFillColor('blue');
        $p2->SetWidth(1);
        $p2->SetLegend(plugin_lang_get('legend_closed'));
        $p3 = new BarPlot(array_values($p_metrics['resolved']));
        $p3->SetFillColor('red');
        $p3->SetWidth(1);
        $p3->SetLegend(plugin_lang_get('legend_resolved'));
        $gbplot = new GroupBarPlot(array($p1, $p3, $p2));
        $graph->Add($gbplot);
        if (helper_show_query_count()) {
            $graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)');
            $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
        }
        $graph->Stroke();
    }
}
function graph_group($p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_height = 400, $p_baseline = 100)
{
    # $p_metrics is an array of three arrays
    #   $p_metrics['open'] = array( 'enum' => value, ...)
    #   $p_metrics['resolved']
    #   $p_metrics['closed']
    $t_graph_font = graph_get_font();
    # count up array portions that are set
    $t_count = 0;
    foreach (array('open', 'resolved', 'closed') as $t_label) {
        if (is_array($p_metrics[$t_label])) {
            $t_count += array_sum($p_metrics[$t_label]);
        }
    }
    error_check($t_count, $p_title);
    # calculate totals
    $total = graph_total_metrics($p_metrics);
    #defines margin according to height
    $graph = new Graph($p_graph_width, $p_graph_height);
    $graph->img->SetMargin(45, 35, 35, $p_baseline);
    if (ON == config_get_global('jpgraph_antialias')) {
        $graph->img->SetAntiAliasing();
    }
    $graph->SetScale('textlin');
    $graph->SetMarginColor('white');
    $graph->SetFrame(false);
    $graph->title->SetFont($t_graph_font, FS_BOLD);
    $graph->title->Set($p_title);
    $graph->xaxis->SetTickLabels(array_keys($p_metrics['open']));
    if (FF_FONT2 <= $t_graph_font) {
        $graph->xaxis->SetLabelAngle(60);
    } else {
        $graph->xaxis->SetLabelAngle(90);
        # can't rotate non truetype fonts
    }
    $graph->xaxis->SetFont($t_graph_font);
    $graph->legend->Pos(0.05, 0.08);
    $graph->legend->SetFont($t_graph_font);
    $graph->yaxis->scale->ticks->SetDirection(-1);
    $graph->yaxis->SetFont($t_graph_font);
    $graph->yscale->SetGrace(10);
    #adds on the same graph
    $tot = new BarPlot(array_values($total));
    $tot->SetFillColor('lightblue');
    $tot->SetWidth(0.7);
    $tot->SetLegend(lang_get('legend_total'));
    $graph->Add($tot);
    $p1 = new BarPlot(array_values($p_metrics['open']));
    $p1->SetFillColor('yellow');
    $p1->SetWidth(1);
    $p1->SetLegend(lang_get('legend_opened'));
    $p2 = new BarPlot(array_values($p_metrics['closed']));
    $p2->SetFillColor('blue');
    $p2->SetWidth(1);
    $p2->SetLegend(lang_get('legend_closed'));
    $p3 = new BarPlot(array_values($p_metrics['resolved']));
    $p3->SetFillColor('red');
    $p3->SetWidth(1);
    $p3->SetLegend(lang_get('legend_resolved'));
    $gbplot = new GroupBarPlot(array($p1, $p3, $p2));
    $graph->Add($gbplot);
    if (helper_show_queries()) {
        $graph->subtitle->Set(db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)');
        $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
    }
    $graph->Stroke();
}
<?php

# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: summary_graph_byseverity_pct.php,v 1.15 2005/02/12 20:01:08 jlatour Exp $
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'graph_api.php';
access_ensure_project_level(config_get('view_summary_threshold'));
$f_width = gpc_get_int('width', 300);
$f_token = gpc_get_int('token', 0);
if (0 == $f_token) {
    $t_metrics = create_bug_enum_summary(lang_get('severity_enum_string'), 'severity');
} else {
    $t_metrics = graph_total_metrics(unserialize(token_get_value($f_token)));
}
graph_pie($t_metrics, lang_get('by_severity_pct'), $f_width, $f_width);
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Graph by Severity
 *
 * @package MantisBT
 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */
require_once 'core.php';
plugin_require_api('core/graph_api.php');
access_ensure_project_level(config_get('view_summary_threshold'));
$f_width = gpc_get_int('width', 300);
$t_ar = plugin_config_get('bar_aspect');
$t_token = token_get_value(TOKEN_GRAPH);
if ($t_token == null) {
    $t_metrics = create_bug_enum_summary(lang_get('severity_enum_string'), 'severity');
} else {
    $t_metrics = graph_total_metrics(json_decode($t_token, true));
}
graph_bar($t_metrics, lang_get('by_severity'), $f_width, $f_width * $t_ar);