From 470728fcc8f44fbe676c3fc424afdd42a46910c6 Mon Sep 17 00:00:00 2001
From: Kirill Krasnov <krasnovforum@gmail.com>
Date: Sun, 14 Jun 2009 08:54:20 +0300
Subject: [PATCH] JpGraph modify

---
 config_defaults_inc.php                  |   29 +++++++++++-
 core/graph_api.php                       |   73 ++++++++++++++++++++----------
 docbook/adminguide/en/configuration.sgml |    2 +-
 3 files changed, 77 insertions(+), 27 deletions(-)

diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index d8ad7d6..99cefd8 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -1024,7 +1024,7 @@
 	 * path to jpgraph installation - dont forget the ending slash!
 	 * @global string $g_jpgraph_path
 	 */
-	$g_jpgraph_path			= '.' . DIRECTORY_SEPARATOR . 'jpgraph' . DIRECTORY_SEPARATOR;
+	$g_jpgraph_path			= '.' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'jpgraph' . DIRECTORY_SEPARATOR;
 
 	/**
 	 * use antialiasing - Enabling anti-aliasing will greatly improve the visual apperance of certain graphs.
@@ -1035,13 +1035,38 @@
 
 	/**
 	 * what truetype font will the graphs use. Allowed values are 'arial', 'verdana', 'courier', 'book', 'comic', 'times',
-	 * 'georgia', 'trebuche', 'vera', 'veramono', or 'veraserif'. Refer to the jpgraph manual for details.
+	 * 'georgia', 'trebuche', 'vera', 'veramono', 'veraserif', 'dv_sansserif', 'dv_serif', 'dv_sansserif', 'dv_serifcond', 
+	 * or 'dv_sansserifcond'. Refer to the jpgraph manual for details.
 	 * NOTE: these fonts need to be installed in the TTF_DIR as specified to jpgraph
 	 * @global string $g_graph_font
 	 */
 	$g_graph_font = '';
 
 	/**
+	 * font size for graph title
+	 * @global int $g_title_fontsize
+	 */
+	$g_title_fontsize = 10;
+
+	/**
+	 * font size for graph subtitle
+	 * @global int $g_subtitle_fontsize
+	 */
+	$g_subtitle_fontsize = 9;
+
+	/**
+	 * font size for graph axis
+	 * @global int $g_axis_fontsize
+	 */
+	$g_axis_fontsize = 8;
+
+	/**
+	 * font size for graph legend
+	 * @global int $g_legend_fontsize
+	 */
+	$g_legend_fontsize = 8;
+
+	/**
 	 * what width is used to scale the graphs.
 	 * @global int $g_graph_window_width
 	 */
diff --git a/core/graph_api.php b/core/graph_api.php
index cd1e23b..b5b1c28 100644
--- a/core/graph_api.php
+++ b/core/graph_api.php
@@ -45,6 +45,11 @@ function graph_get_font() {
 		'vera' => FF_VERA,
 		'veramono' => FF_VERAMONO,
 		'veraserif' => FF_VERASERIF,
+		'dv_sansserif' => FF_DV_SANSSERIF,
+		'dv_serif' => FF_DV_SERIF,
+		'dv_sansserif' => FF_DV_SANSSERIFMONO,
+		'dv_serifcond' => FF_DV_SERIFCOND,
+		'dv_sansserifcond' => FF_DV_SANSSERIFCOND,
 	);
 
 	$t_font = config_get( 'graph_font', '' );
@@ -62,6 +67,10 @@ function graph_get_font() {
 function graph_bar( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_height = 400 ) {
 
 	$t_graph_font = graph_get_font();
+	$t_font_size_axis = config_get( 'axis_fontsize', 8 );
+	$t_font_size_legend = config_get( 'legend_fontsize', 8 );
+	$t_font_size_title = config_get( 'title_fontsize', 10 );
+	$t_font_size_subtitle = config_get( 'subtitle_fontsize', 9 );
 
 	error_check( is_array( $p_metrics ) ? array_sum( $p_metrics ) : 0, $p_title );
 
@@ -74,7 +83,7 @@ function graph_bar( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_he
 	$graph->SetMarginColor( 'white' );
 	$graph->SetFrame( false );
 	$graph->title->Set( $p_title );
-	$graph->title->SetFont( $t_graph_font, FS_BOLD );
+	$graph->title->SetFont( $t_graph_font, FS_BOLD, $t_font_size_title );
 	$graph->xaxis->SetTickLabels( array_keys( $p_metrics ) );
 	if( FF_FONT2 <= $t_graph_font ) {
 		$graph->xaxis->SetLabelAngle( 60 );
@@ -83,12 +92,12 @@ function graph_bar( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_he
 
 		# can't rotate non truetype fonts
 	}
-	$graph->xaxis->SetFont( $t_graph_font );
+	$graph->xaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 
-	$graph->legend->SetFont( $t_graph_font );
+	$graph->legend->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_legend );
 
 	$graph->yaxis->scale->ticks->SetDirection( -1 );
-	$graph->yaxis->SetFont( $t_graph_font );
+	$graph->yaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 
 	$p1 = new BarPlot( array_values( $p_metrics ) );
 	$p1->SetFillColor( 'yellow' );
@@ -96,7 +105,7 @@ function graph_bar( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_he
 	$graph->Add( $p1 );
 	if( helper_show_queries() ) {
 		$graph->subtitle->Set( db_count_queries() . ' queries (' . db_time_queries() . 'sec)' );
-		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
+		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_subtitle );
 	}
 
 	$graph->Stroke();
@@ -111,6 +120,10 @@ function graph_group( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_
 	#   $p_metrics['closed']
 
 	$t_graph_font = graph_get_font();
+	$t_font_size_axis = config_get( 'axis_fontsize', 8 );
+	$t_font_size_legend = config_get( 'legend_fontsize', 8 );
+	$t_font_size_title = config_get( 'title_fontsize', 10 );
+	$t_font_size_subtitle = config_get( 'subtitle_fontsize', 9 );
 
 	# count up array portions that are set
 	$t_count = 0;
@@ -134,7 +147,7 @@ function graph_group( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_
 	$graph->SetScale( 'textlin' );
 	$graph->SetMarginColor( 'white' );
 	$graph->SetFrame( false );
-	$graph->title->SetFont( $t_graph_font, FS_BOLD );
+	$graph->title->SetFont( $t_graph_font, FS_BOLD, $t_font_size_title );
 	$graph->title->Set( $p_title );
 	$graph->xaxis->SetTickLabels( array_keys( $p_metrics['open'] ) );
 	if( FF_FONT2 <= $t_graph_font ) {
@@ -144,12 +157,12 @@ function graph_group( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_
 
 		# can't rotate non truetype fonts
 	}
-	$graph->xaxis->SetFont( $t_graph_font );
+	$graph->xaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 	$graph->legend->Pos( 0.05, 0.08 );
-	$graph->legend->SetFont( $t_graph_font );
+	$graph->legend->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_legend );
 
 	$graph->yaxis->scale->ticks->SetDirection( -1 );
-	$graph->yaxis->SetFont( $t_graph_font );
+	$graph->yaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 	$graph->yscale->SetGrace( 10 );
 
 	# adds on the same graph
@@ -190,19 +203,23 @@ function graph_group( $p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_
 function graph_pie( $p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_height = 350, $p_center = 0.4, $p_poshorizontal = 0.10, $p_posvertical = 0.09 ) {
 
 	$t_graph_font = graph_get_font();
+	$t_font_size_axis = config_get( 'axis_fontsize', 8 );
+	$t_font_size_legend = config_get( 'legend_fontsize', 8 );
+	$t_font_size_title = config_get( 'title_fontsize', 10 );
+	$t_font_size_subtitle = config_get( 'subtitle_fontsize', 9 );
 
 	error_check( is_array( $p_metrics ) ? array_sum( $p_metrics ) : 0, $p_title );
 
 	$graph = new PieGraph( $p_graph_width, $p_graph_height );
 	$graph->img->SetMargin( 40, 40, 40, 100 );
 	$graph->title->Set( $p_title );
-	$graph->title->SetFont( $t_graph_font, FS_BOLD );
+	$graph->title->SetFont( $t_graph_font, FS_BOLD, $t_font_size_title );
 
 	$graph->SetMarginColor( 'white' );
 	$graph->SetFrame( false );
 
 	$graph->legend->Pos( $p_poshorizontal, $p_posvertical );
-	$graph->legend->SetFont( $t_graph_font );
+	$graph->legend->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_legend );
 
 	$p1 = new PiePlot3d( array_values( $p_metrics ) );
 
@@ -217,12 +234,12 @@ function graph_pie( $p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_he
 	# Label format
 	$p1->value->SetFormat( '%2.0f' );
 	$p1->value->Show();
-	$p1->value->SetFont( $t_graph_font );
+	$p1->value->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_legend );
 
 	$graph->Add( $p1 );
 	if( helper_show_queries() ) {
 		$graph->subtitle->Set( db_count_queries() . ' queries (' . db_time_queries() . 'sec)' );
-		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
+		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_subtitle );
 	}
 	$graph->Stroke();
 }
@@ -231,6 +248,10 @@ function graph_pie( $p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_he
 function graph_cumulative_bydate( $p_metrics, $p_graph_width = 300, $p_graph_height = 380 ) {
 
 	$t_graph_font = graph_get_font();
+	$t_font_size_axis = config_get( 'axis_fontsize', 8 );
+	$t_font_size_legend = config_get( 'legend_fontsize', 8 );
+	$t_font_size_title = config_get( 'title_fontsize', 10 );
+	$t_font_size_subtitle = config_get( 'subtitle_fontsize', 9 );
 	error_check( is_array( $p_metrics ) ? count( $p_metrics ) : 0, lang_get( 'cumulative' ) . ' ' . lang_get( 'by_date' ) );
 
 	foreach( $p_metrics as $i => $vals ) {
@@ -253,17 +274,17 @@ function graph_cumulative_bydate( $p_metrics, $p_graph_width = 300, $p_graph_hei
 	$graph->SetMarginColor( 'white' );
 	$graph->SetFrame( false );
 	$graph->title->Set( lang_get( 'cumulative' ) . ' ' . lang_get( 'by_date' ) );
-	$graph->title->SetFont( $t_graph_font, FS_BOLD );
+	$graph->title->SetFont( $t_graph_font, FS_BOLD, $t_font_size_title );
 
 	$graph->legend->Pos( 0.05, 0.9, 'right', 'bottom' );
 	$graph->legend->SetShadow( false );
 	$graph->legend->SetFillColor( 'white' );
 	$graph->legend->SetLayout( LEGEND_HOR );
-	$graph->legend->SetFont( $t_graph_font );
+	$graph->legend->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_legend );
 
 	$graph->yaxis->scale->ticks->SetDirection( -1 );
-	$graph->yaxis->SetFont( $t_graph_font );
-	$graph->y2axis->SetFont( $t_graph_font );
+	$graph->yaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
+	$graph->y2axis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 
 	if( FF_FONT2 <= $t_graph_font ) {
 		$graph->xaxis->SetLabelAngle( 60 );
@@ -273,7 +294,7 @@ function graph_cumulative_bydate( $p_metrics, $p_graph_width = 300, $p_graph_hei
 		# can't rotate non truetype fonts
 	}
 	$graph->xaxis->SetLabelFormatCallback( 'graph_date_format' );
-	$graph->xaxis->SetFont( $t_graph_font );
+	$graph->xaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 
 	$p1 = new LinePlot( $reported_plot, $plot_date );
 	$p1->SetColor( 'blue' );
@@ -295,7 +316,7 @@ function graph_cumulative_bydate( $p_metrics, $p_graph_width = 300, $p_graph_hei
 
 	if( helper_show_queries() ) {
 		$graph->subtitle->Set( db_count_queries() . ' queries (' . db_time_queries() . 'sec)' );
-		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
+		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_subtitle );
 	}
 	$graph->Stroke();
 }
@@ -304,6 +325,10 @@ function graph_cumulative_bydate( $p_metrics, $p_graph_width = 300, $p_graph_hei
 function graph_bydate( $p_metrics, $p_labels, $p_title, $p_graph_width = 300, $p_graph_height = 380 ) {
 
 	$t_graph_font = graph_get_font();
+	$t_font_size_axis = config_get( 'axis_fontsize', 8 );
+	$t_font_size_legend = config_get( 'legend_fontsize', 8 );
+	$t_font_size_title = config_get( 'title_fontsize', 10 );
+	$t_font_size_subtitle = config_get( 'subtitle_fontsize', 9 );
 	error_check( is_array( $p_metrics ) ? count( $p_metrics ) : 0, lang_get( 'by_date' ) );
 
 	$graph = new Graph( $p_graph_width, $p_graph_height );
@@ -315,16 +340,16 @@ function graph_bydate( $p_metrics, $p_labels, $p_title, $p_graph_width = 300, $p
 	$graph->SetMarginColor( 'white' );
 	$graph->SetFrame( false );
 	$graph->title->Set( $p_title . ' ' . lang_get( 'by_date' ) );
-	$graph->title->SetFont( $t_graph_font, FS_BOLD );
+	$graph->title->SetFont( $t_graph_font, FS_BOLD, $t_font_size_title );
 
 	$graph->legend->Pos( 0.01, 0.05, 'right', 'top' );
 	$graph->legend->SetShadow( false );
 	$graph->legend->SetFillColor( 'white' );
 	$graph->legend->SetLayout( LEGEND_VERT );
-	$graph->legend->SetFont( $t_graph_font );
+	$graph->legend->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_legend );
 
 	$graph->yaxis->scale->ticks->SetDirection( -1 );
-	$graph->yaxis->SetFont( $t_graph_font );
+	$graph->yaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 	$graph->yaxis->scale->SetAutoMin( 0 );
 
 	if( FF_FONT2 <= $t_graph_font ) {
@@ -335,7 +360,7 @@ function graph_bydate( $p_metrics, $p_labels, $p_title, $p_graph_width = 300, $p
 		# can't rotate non truetype fonts
 	}
 	$graph->xaxis->SetLabelFormatCallback( 'graph_date_format' );
-	$graph->xaxis->SetFont( $t_graph_font );
+	$graph->xaxis->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_axis );
 
 	$t_line_colours = config_get( 'graph_colors' );
 	$t_count_colours = count( $t_line_colours );
@@ -351,7 +376,7 @@ function graph_bydate( $p_metrics, $p_labels, $p_title, $p_graph_width = 300, $p
 
 	if( helper_show_queries() ) {
 		$graph->subtitle->Set( db_count_queries() . ' queries (' . db_time_queries() . 'sec)' );
-		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
+		$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, $t_font_size_subtitle );
 	}
 	$graph->Stroke();
 }
diff --git a/docbook/adminguide/en/configuration.sgml b/docbook/adminguide/en/configuration.sgml
index b974e14..5777281 100644
--- a/docbook/adminguide/en/configuration.sgml
+++ b/docbook/adminguide/en/configuration.sgml
@@ -954,7 +954,7 @@
                 <ulink url="http://www.aditus.nu/jpgraph/index.php">JpGraph</ulink>
                 package. You can place the package whereever you want, but you have
                 to set the var in jpgraph.php&nbsp;eg.
-                DEFINE("DIR_BASE","/www/mantisbt/jpgraph/");&nbsp;
+                DEFINE("DIR_BASE","/www/mantisbt/library/jpgraph/");&nbsp;
             </para>
         </note>
 
-- 
1.6.2.2.1669.g7eaf8

