[Vtigercrm-commits] [vtiger-commits] r4896 - in /vtigercrm/trunk: ./ Image/ Image/Canvas/ Image/Canvas/Fonts/ Image/Canvas/GD/ Image/Graph/ Image/Graph/Axis/ Image/Graph/Axis/Marker/ Image/Graph/DataPreprocessor/ Image/Graph/DataSelector/ Image/Graph/Dataset/ Image/Graph/Figure/ Image/Graph/Fill/ Image/Graph/Grid/ Image/Graph/Images/ Image/Graph/Images/Icons/ Image/Graph/Images/Maps/ Image/Graph/Layout/ Image/Graph/Line/ Image/Graph/Marker/ Image/Graph/Marker/Pointing/ Image/Graph/Plot/ Image/Graph/Plot/Fit/ Image/Graph/Plot/Smoothed/ Image/Graph/Plotarea/ include/utils/ jpgraph/ modules/Dashboard/ modules/Potentials/

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Wed Apr 5 04:25:26 EDT 2006


Author: jacquemesm
Date: Wed Apr  5 02:24:29 2006
New Revision: 4896

Log:
Image Graph implementation : suppress JPGraph and replace by Image Graph, replace several chart modules

Added:
    vtigercrm/trunk/Image/
    vtigercrm/trunk/Image/Canvas/
    vtigercrm/trunk/Image/Canvas.php
    vtigercrm/trunk/Image/Canvas/Color.php
    vtigercrm/trunk/Image/Canvas/Fonts/
    vtigercrm/trunk/Image/Canvas/Fonts/README
    vtigercrm/trunk/Image/Canvas/Fonts/fontmap.txt
    vtigercrm/trunk/Image/Canvas/GD/
    vtigercrm/trunk/Image/Canvas/GD.php
    vtigercrm/trunk/Image/Canvas/GD/JPG.php
    vtigercrm/trunk/Image/Canvas/GD/PNG.php
    vtigercrm/trunk/Image/Canvas/ImageMap.php
    vtigercrm/trunk/Image/Canvas/PDF.php
    vtigercrm/trunk/Image/Canvas/SVG.php
    vtigercrm/trunk/Image/Canvas/Tool.php
    vtigercrm/trunk/Image/Canvas/WithMap.php
    vtigercrm/trunk/Image/Color.php
    vtigercrm/trunk/Image/Graph/
    vtigercrm/trunk/Image/Graph.php
    vtigercrm/trunk/Image/Graph/Axis/
    vtigercrm/trunk/Image/Graph/Axis.php
    vtigercrm/trunk/Image/Graph/Axis/Category.php
    vtigercrm/trunk/Image/Graph/Axis/Logarithmic.php
    vtigercrm/trunk/Image/Graph/Axis/Marker/
    vtigercrm/trunk/Image/Graph/Axis/Marker/Area.php
    vtigercrm/trunk/Image/Graph/Axis/Marker/Line.php
    vtigercrm/trunk/Image/Graph/Axis/Radar.php
    vtigercrm/trunk/Image/Graph/Common.php
    vtigercrm/trunk/Image/Graph/Config.php
    vtigercrm/trunk/Image/Graph/Constants.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/
    vtigercrm/trunk/Image/Graph/DataPreprocessor.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/Array.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/Currency.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/Date.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/Formatted.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/Function.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/NumberText.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/RomanNumerals.php
    vtigercrm/trunk/Image/Graph/DataPreprocessor/Sequential.php
    vtigercrm/trunk/Image/Graph/DataSelector/
    vtigercrm/trunk/Image/Graph/DataSelector.php
    vtigercrm/trunk/Image/Graph/DataSelector/EveryNthPoint.php
    vtigercrm/trunk/Image/Graph/DataSelector/NoZeros.php
    vtigercrm/trunk/Image/Graph/DataSelector/Values.php
    vtigercrm/trunk/Image/Graph/Dataset/
    vtigercrm/trunk/Image/Graph/Dataset.php
    vtigercrm/trunk/Image/Graph/Dataset/Function.php
    vtigercrm/trunk/Image/Graph/Dataset/Random.php
    vtigercrm/trunk/Image/Graph/Dataset/Sequential.php
    vtigercrm/trunk/Image/Graph/Dataset/Trivial.php
    vtigercrm/trunk/Image/Graph/Dataset/VectorFunction.php
    vtigercrm/trunk/Image/Graph/Element.php
    vtigercrm/trunk/Image/Graph/Figure/
    vtigercrm/trunk/Image/Graph/Figure/Circle.php
    vtigercrm/trunk/Image/Graph/Figure/Ellipse.php
    vtigercrm/trunk/Image/Graph/Figure/Polygon.php
    vtigercrm/trunk/Image/Graph/Figure/Rectangle.php
    vtigercrm/trunk/Image/Graph/Fill/
    vtigercrm/trunk/Image/Graph/Fill.php
    vtigercrm/trunk/Image/Graph/Fill/Array.php
    vtigercrm/trunk/Image/Graph/Fill/Gradient.php
    vtigercrm/trunk/Image/Graph/Fill/Image.php
    vtigercrm/trunk/Image/Graph/Font.php
    vtigercrm/trunk/Image/Graph/Grid/
    vtigercrm/trunk/Image/Graph/Grid.php
    vtigercrm/trunk/Image/Graph/Grid/Bars.php
    vtigercrm/trunk/Image/Graph/Grid/Lines.php
    vtigercrm/trunk/Image/Graph/Grid/Polar.php
    vtigercrm/trunk/Image/Graph/Images/
    vtigercrm/trunk/Image/Graph/Images/Icons/
    vtigercrm/trunk/Image/Graph/Images/Icons/pinpoint.png   (with props)
    vtigercrm/trunk/Image/Graph/Images/Icons/pinpointr.png   (with props)
    vtigercrm/trunk/Image/Graph/Images/Maps/
    vtigercrm/trunk/Image/Graph/Images/Maps/README
    vtigercrm/trunk/Image/Graph/Layout/
    vtigercrm/trunk/Image/Graph/Layout.php
    vtigercrm/trunk/Image/Graph/Layout/Horizontal.php
    vtigercrm/trunk/Image/Graph/Layout/Matrix.php
    vtigercrm/trunk/Image/Graph/Layout/Vertical.php
    vtigercrm/trunk/Image/Graph/Legend.php
    vtigercrm/trunk/Image/Graph/Line/
    vtigercrm/trunk/Image/Graph/Line/Array.php
    vtigercrm/trunk/Image/Graph/Line/Dashed.php
    vtigercrm/trunk/Image/Graph/Line/Dotted.php
    vtigercrm/trunk/Image/Graph/Line/Formatted.php
    vtigercrm/trunk/Image/Graph/Line/Solid.php
    vtigercrm/trunk/Image/Graph/Logo.php
    vtigercrm/trunk/Image/Graph/Marker/
    vtigercrm/trunk/Image/Graph/Marker.php
    vtigercrm/trunk/Image/Graph/Marker/Array.php
    vtigercrm/trunk/Image/Graph/Marker/Asterisk.php
    vtigercrm/trunk/Image/Graph/Marker/Average.php
    vtigercrm/trunk/Image/Graph/Marker/Box.php
    vtigercrm/trunk/Image/Graph/Marker/Bubble.php
    vtigercrm/trunk/Image/Graph/Marker/Circle.php
    vtigercrm/trunk/Image/Graph/Marker/Cross.php
    vtigercrm/trunk/Image/Graph/Marker/Diamond.php
    vtigercrm/trunk/Image/Graph/Marker/Icon.php
    vtigercrm/trunk/Image/Graph/Marker/Pinpoint.php
    vtigercrm/trunk/Image/Graph/Marker/Plus.php
    vtigercrm/trunk/Image/Graph/Marker/Pointing/
    vtigercrm/trunk/Image/Graph/Marker/Pointing.php
    vtigercrm/trunk/Image/Graph/Marker/Pointing/Angular.php
    vtigercrm/trunk/Image/Graph/Marker/Pointing/Radial.php
    vtigercrm/trunk/Image/Graph/Marker/ReversePinpoint.php
    vtigercrm/trunk/Image/Graph/Marker/Star.php
    vtigercrm/trunk/Image/Graph/Marker/Triangle.php
    vtigercrm/trunk/Image/Graph/Marker/Value.php
    vtigercrm/trunk/Image/Graph/Plot/
    vtigercrm/trunk/Image/Graph/Plot.php
    vtigercrm/trunk/Image/Graph/Plot/Area.php
    vtigercrm/trunk/Image/Graph/Plot/Band.php
    vtigercrm/trunk/Image/Graph/Plot/Bar.php
    vtigercrm/trunk/Image/Graph/Plot/BoxWhisker.php
    vtigercrm/trunk/Image/Graph/Plot/CandleStick.php
    vtigercrm/trunk/Image/Graph/Plot/Dot.php
    vtigercrm/trunk/Image/Graph/Plot/Fit/
    vtigercrm/trunk/Image/Graph/Plot/Fit/Line.php
    vtigercrm/trunk/Image/Graph/Plot/Impulse.php
    vtigercrm/trunk/Image/Graph/Plot/Line.php
    vtigercrm/trunk/Image/Graph/Plot/Odo.php
    vtigercrm/trunk/Image/Graph/Plot/Pie.php
    vtigercrm/trunk/Image/Graph/Plot/Radar.php
    vtigercrm/trunk/Image/Graph/Plot/Smoothed/
    vtigercrm/trunk/Image/Graph/Plot/Smoothed/Area.php
    vtigercrm/trunk/Image/Graph/Plot/Smoothed/Bezier.php
    vtigercrm/trunk/Image/Graph/Plot/Smoothed/Line.php
    vtigercrm/trunk/Image/Graph/Plot/Smoothed/Radar.php
    vtigercrm/trunk/Image/Graph/Plot/Step.php
    vtigercrm/trunk/Image/Graph/Plotarea/
    vtigercrm/trunk/Image/Graph/Plotarea.php
    vtigercrm/trunk/Image/Graph/Plotarea/Element.php
    vtigercrm/trunk/Image/Graph/Plotarea/Map.php
    vtigercrm/trunk/Image/Graph/Plotarea/Radar.php
    vtigercrm/trunk/Image/Graph/Simple.php
    vtigercrm/trunk/Image/Graph/Title.php
    vtigercrm/trunk/Image/Graph/Tool.php
    vtigercrm/trunk/PEAR.php
    vtigercrm/trunk/include/utils/GraphUtils.php
Removed:
    vtigercrm/trunk/jpgraph/
Modified:
    vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php
    vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php
    vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php
    vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php
    vtigercrm/trunk/modules/Dashboard/display_charts.php
    vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php
    vtigercrm/trunk/modules/Dashboard/pie_graph.php
    vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php
    vtigercrm/trunk/modules/Potentials/Charts.php

Modified: vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php Wed Apr  5 02:24:29 2006
@@ -101,10 +101,6 @@
 $cache_file_name = $id_hash."_lead_source_by_outcome_".$current_language."_".crc32(implode('',$datax)).".png";
 $log->debug("cache file name is: $cache_file_name");
 
-if (substr(phpversion(), 0, 1) == "5") { // php5 }
-	echo "<em>Charts not supported in PHP 5.</em>";
-}
-else {
 if(isPermitted('Potentials','index')=="yes")
 {
 $draw_this = new jpgraph();
@@ -147,4 +143,4 @@
 {
         echo $mod_strings['LBL_NO_PERMISSION'];
 }
-}?>
+?>

Modified: vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php Wed Apr  5 02:24:29 2006
@@ -102,10 +102,6 @@
 $cache_file_name = $id_hash."_outcome_by_month_".$current_language."_".crc32($date_start.$date_end).".png";
 $log->debug("cache file name is: $cache_file_name");
 
-if (substr(phpversion(), 0, 1) == "5") { // php5 }
-	echo "<em>Charts not supported in PHP 5.</em>";
-}
-else {
 if(isPermitted('Potentials','index')=="yes")
 {
 $draw_this = new jpgraph();
@@ -170,4 +166,4 @@
 	echo $mod_strings['LBL_NO_PERMISSION'];	
 }
 echo get_validate_chart_js();
-}?>
+?>

Modified: vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php Wed Apr  5 02:24:29 2006
@@ -101,10 +101,6 @@
 $cache_file_name = $id_hash."_pipeline_by_lead_source_".$current_language."_".crc32(implode('',$datax)).".png";
 $log->debug("cache file name is: $cache_file_name");
 
-if (substr(phpversion(), 0, 1) == "5") { // php5 }
-	echo "<em>Charts not supported in PHP 5.</em>";
-}
-else {
 if(isPermitted('Potentials','index')=="yes")
 {
 $draw_this = new jpgraph();
@@ -147,4 +143,4 @@
 {
         echo $mod_strings['LBL_NO_PERMISSION'];
 }
-}?>
+?>

Modified: vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php Wed Apr  5 02:24:29 2006
@@ -136,10 +136,6 @@
 $cache_file_name = $id_hash."_pipeline_".$current_language."_".crc32(implode('',$datax)).$date_start.$date_end.".png";
 $log->debug("cache file name is: $cache_file_name");
 
-if (substr(phpversion(), 0, 1) == "5") { // php5 }
-	echo "<em>Charts not supported in PHP 5.</em>";
-}
-else {
 if(isPermitted('Potentials','index')=="yes")
 {
 $draw_this = new jpgraph();
@@ -210,4 +206,4 @@
 	echo $mod_strings['LBL_NO_PERMISSION'];
 } 
 //echo get_validate_chart_js();
-}?>
+?>

Modified: vtigercrm/trunk/modules/Dashboard/display_charts.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/display_charts.php (original)
+++ vtigercrm/trunk/modules/Dashboard/display_charts.php Wed Apr  5 02:24:29 2006
@@ -110,7 +110,7 @@
 	       	$test_target_val=$graph_details[7];
 
 
-                $width=350;
+                $width=600;
                 $height=400;
                 $top=30;
                 $left=140;
@@ -205,7 +205,7 @@
 	<tr>
 	   <td height=200>"; 
 
-	   $sHTML .= render_graph($tmp_dir."pie_".$cache_file_name,$html_imagename."_pie",$cnt_val,$name_val,450,300,40,$right,$top,$bottom,$title,$target_val,"pie");
+	   $sHTML .= render_graph($tmp_dir."pie_".$cache_file_name,$html_imagename."_pie",$cnt_val,$name_val,$width,$height,40,$right,$top,$bottom,$title,$target_val,"pie");
 
 $sHTML .= "</td>
 	</tr>

Modified: vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php (original)
+++ vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php Wed Apr  5 02:24:29 2006
@@ -10,9 +10,10 @@
 *
  ********************************************************************************/
 
-include ("jpgraph/src/jpgraph.php");
-include ("jpgraph/src/jpgraph_bar.php");
 require_once('config.php');
+require_once('include/utils/GraphUtils.php');
+include_once ('Image/Graph.php');
+include_once ('Image/Canvas.php');
 
 $tmp_dir=$root_directory."cache/images/";
 
@@ -24,7 +25,7 @@
 function horizontal_graph($referdata,$refer_code,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$cache_file_name,$html_image_name)
 {
 
-	global $log,$root_directory;
+	global $log,$root_directory,$lang_crm,$theme;
 //We'll be getting the values in the form of a string separated by commas
 	$datay=explode(",",$referdata); // The datay values  
 	$datax=explode(",",$refer_code); // The datax values  
@@ -71,110 +72,152 @@
 	//datax is the status
 
 	// Set the basic parameters of the graph
-	$graph = new Graph($width,$height,'auto');
-	$graph->SetScale("textlin");
-
-	// To get a horizontal Graph	
-	$graph->Set90AndMargin($left,$right,$top,$bottom);
-
-	$graph->xaxis->SetPos('min');
-
-	// Nice shadow
-	$graph->SetShadow();
-
+	$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+	$imagemap = $canvas->getImageMap();
+	$graph =& Image_Graph::factory('graph', $canvas);
+	$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+	// set the font size to 12
+	$font->setSize(8);
+
+	if($theme == "blue")
+	{
+		$font_color = "#212473";
+	}
+	else
+	{
+		$font_color = "#000000";
+	}
+	$font->setColor($font_color);
+		
+	$graph->setFont($font);
+	$titlestr =& Image_Graph::factory('title', array($title,10));
+   	$plotarea =& Image_Graph::factory('plotarea',array(
+				'axis',
+				'axis',
+				'horizontal'
+                ));
+	$graph->add(
+	    Image_Graph::vertical($titlestr,
+			$plotarea,
+    	5
+	 	)
+	);   
+
+
+	// Now create a bar plot
+	$max=0;
+	$xlabels = array();
+	$dataset = & Image_Graph::factory('dataset');
+	$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white'));
+	for($i=0;$i<count($datay); $i++)
+	{
+		$x=1+2*$i;
+		if($datay[$i]>=$max) $max=$datay[$i];
+		$dataset->addPoint(
+			        $x,
+			        $datay[$i],
+			        array(
+			            'url' => $target[$i],
+			            'alt' => $alts[$i]
+			        )
+	    );
+	    // build the xaxis label array to allow intermediate ticks
+	    $xlabels[$x] = $datax[$i];
+	    $xlabels[$x+1] = '';
+	}
+
+
+	$bplot = & $plotarea->addNew('bar', $dataset);
+	$bplot->setFillStyle($fill);
+
+	//You can change the width of the bars if you like
+	$bplot->setBarWidth(50/count($datax),"%");
+	$bplot->setPadding(array('top'=>20));
+
+	// We want to display the value of each bar at the top
+	//$bplot->value->Show();
+	//$bplot->value->SetFont(FF_FONT2,FS_BOLD,12);
+	//$bplot->value->SetAlign('left','center');
+	//$bplot->value->SetColor("black","gray4");
+	//$bplot->value->SetFormat('%d');
+
+	//$graph->SetBackgroundGradient('#E5E5E5','white',GRAD_VER,BGRAD_PLOT);
+	$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
+	//$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER);
+
+	//$graph->SetFrame(false);
+	//$graph->SetMarginColor('cadetblue2');
+	//$graph->ygrid->SetFill(true,'azure1','azure2');
+	//$graph->xgrid->Show();
+
+	// Add the bar to the graph
+	//$graph->Add($bplot);
+	
 	// Setup title
-	$graph->title->Set($title);
-	$graph->title->SetFont(FF_FONT2,FS_BOLD,14);
+	//$titlestr->setText($title);
 
 	// Setup X-axis
-	$graph->xaxis->SetTickLabels($datax);
-	$graph->xaxis->SetFont(FF_FONT2,FS_NORMAL,12);
-
-	// Some extra margin looks nicer
-	$graph->xaxis->SetLabelMargin(5);
-
-	// Label align for X-axis
-	$graph->xaxis->SetLabelAlign('right','center');
-
-	if($max>=5)
-	{
-		$graph->xaxis->SetLabelFormat('%d');
-	}
+	$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
+	$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+	$yaxis->setFontSize(10);
+	
+	// Invert X-axis and put Y-axis at bottom
+	$xaxis->setInverted(true);
+	$yaxis->setAxisIntersection('max');
+			
+	// set grid
+	$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
+	$gridY->setLineColor('#E5E5E5 at 0.5');
+	$gridY2 =& $plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); 
+	$gridY2->setFillColor('#66CDAA at 0.2'); 
+
 
 	// Add some grace to y-axis so the bars doesn't go
 	// all the way to the end of the plot area
-	$graph->yaxis->scale->SetGrace(20);
-
-	// Setup the Y-axis to be displayed in the bottom of the
-	// graph. We also finetune the exact layout of the title,
-	// ticks and labels to make them look nice.
-	$graph->yaxis->SetPos('max');
+	$yaxis->forceMaximum(round(($max * 1.1) + 0.5));
 
 	// First make the labels look right
-	$graph->yaxis->SetLabelAlign('center','top');
-	$graph->yaxis->SetLabelFormat('%d');
-	$graph->yaxis->SetLabelSide(SIDE_RIGHT);
+	$yaxis->setLabelInterval(1);
+	$yaxis->setTickOptions(-5,0);
+	$yaxis->setLabelInterval(0.5,2);
+	$yaxis->setTickOptions(-2,0,2);
+	
+	// Create the xaxis labels
+	$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
+	    array($xlabels) 
+	); 
 
 	// The fix the tick marks
-	//$graph->yaxis->SetTickSide(SIDE_LEFT);
-
-	// Finally setup the title
-	$graph->yaxis->SetTitleSide(SIDE_RIGHT);
-	$graph->yaxis->SetTitleMargin(35);
-
-	$graph->yaxis->title->SetFont(FF_FONT2,FS_BOLD,12);
-	$graph->yaxis->title->SetAngle(0);
-
-	$graph->yaxis->SetFont(FF_FONT2,FS_NORMAL);
-
-	// Now create a bar pot
-	$max=0;
-	for($i=0;$i<count($datay); $i++)
-	{
-		$x=$datay[$i];
-		if($x>=$max)
-			$max=$x;
-		else
-			$max=$max;
-	}
-
-
-	$bplot = new BarPlot($datay);
-	$bplot->SetFillColor("aquamarine3");
-
-	//You can change the width of the bars if you like
-	$bplot->SetWidth(0.2);
-
-	// We want to display the value of each bar at the top
-	$bplot->value->Show();
-	$bplot->value->SetFont(FF_FONT2,FS_BOLD,12);
-	$bplot->value->SetAlign('left','center');
-	$bplot->value->SetColor("black","gray4");
-	$bplot->value->SetFormat('%d');
-
-	//Adding this top get usemap	
-	$bplot->SetCSIMTargets($target,$alts);
-
-	$graph->SetBackgroundGradient('#E5E5E5','white',GRAD_VER,BGRAD_PLOT);
-	$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER);
-
-	$graph->SetFrame(false);
-	$graph->SetMarginColor('cadetblue2');
-	$graph->ygrid->SetFill(true,'azure1','azure2');
-	$graph->xgrid->Show();
-
-	// Add the bar to the graph
-	$graph->Add($bplot);
+	$xaxis->setDataPreprocessor($array_data);
+	$xaxis->forceMinimum(0);
+	$xaxis->forceMaximum(2*count($datay));
+	$xaxis->setLabelInterval(1);
+	$xaxis->setTickOptions(0,0);
+	$xaxis->setLabelInterval(2,2);
+	$xaxis->setTickOptions(5,0,2);
+			
+	// set markers
+	$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+	$marker->setFillColor('000000 at 0.0');
+	$marker->setBorderColor('000000 at 0.0');
+	$marker->setFontSize(10);
+	// shift markers 10 pix right
+	$marker_pointing =& $graph->addNew('Image_Graph_Marker_Pointing', array(10,0,& $marker));
+	$marker_pointing->setLineColor('000000 at 0.0');
+	$bplot->setMarker($marker_pointing);
 
 
 	//Getting the graph in the form of html page	
-	$graph-> Stroke( $cache_file_name );
-	$imgMap = $graph ->GetHTMLImageMap ($html_image_name);
-	save_image_map($cache_file_name.'.map', $imgMap);
-	$base_name_cache_file=basename($cache_file_name);
-	$ccc="cache/images/".$base_name_cache_file;
-	$img = "<img src=$ccc ismap usemap='#$html_image_name' border=0>" ;
-	$img.=$imgMap;
+	$img = $graph->done(
+						    array(
+							        'tohtml' => true,
+							        'border' => 0,
+							        'filename' => $cache_file_name,
+							        'filepath' => '',
+							        'urlpath' => ''
+							    ));
+	save_image_map($cache_file_name.'.map', $img);
+
 	return $img;
 }
 

Modified: vtigercrm/trunk/modules/Dashboard/pie_graph.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/pie_graph.php (original)
+++ vtigercrm/trunk/modules/Dashboard/pie_graph.php Wed Apr  5 02:24:29 2006
@@ -11,8 +11,9 @@
  ********************************************************************************/
 
 
-include ("jpgraph/src/jpgraph_pie.php");
-include ("jpgraph/src/jpgraph_pie3d.php");
+require_once('include/utils/GraphUtils.php');
+include_once ('Image/Graph.php');
+include_once ('Image/Canvas.php');
 
 
 /** Function to render the Horizontal Graph
@@ -24,7 +25,7 @@
 {
 
 
-	global $log,$root_directory;
+	global $log,$root_directory,$lang_crm,$theme;
 	//We'll be getting the values in the form of a string separated by commas
 	$datay=explode(",",$referdata); // The datay values
 	$datax=explode(",",$refer_code); // The datax values
@@ -40,37 +41,99 @@
 		$alts[]=$name."=%d";
 	}
 
-	$graph = new PieGraph($width,$height,"auto");
+	if($theme == "blue")
+	{
+		$font_color = "#212473";
+	}
+	else
+	{
+		$font_color = "#000000";
+	}
+	
+	$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+	$imagemap = $canvas->getImageMap();
+	$graph =& Image_Graph::factory('graph', $canvas);
+	$font =& $graph->addNew('font', calculate_font_name('en_en'));
+	// set the font size to 11 pixels
+	$font->setSize(8);
+	$font->setColor($font_color);
+		
+	$graph->setFont($font);
+	// create the plotarea layout
+    $title =& Image_Graph::factory('title', array($title,10));
+   	$plotarea =& Image_Graph::factory('plotarea',array(
+                  'category',
+                  'axis'
+              ));
+   	$footer =& Image_Graph::factory('title', array('Footer',8));
+   	$legend_box =& Image_Graph::factory('legend');
+	$graph->add(
+		    Image_Graph::vertical($title,
+			$plotarea,
+        	5
+	    	)
+	);   
 
+	// Generate colours
+	$colors = color_generator(count($datay),'#33CCFF','#3322FF');
+	$dataset = & Image_Graph::factory('dataset');
+	$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
+	$sum = 0;
+	for($i=0;$i<count($datay); $i++)
+	{
+		$dataset->addPoint(
+			        $datax[$i],
+			        $datay[$i],
+			        array(
+			            'url' => $target[$i],
+			            'alt' => $alts[$i]
+			        )
+	    );
+	    $sum += $datay[$i];
+		$fills->addColor($colors[$i]);
+	}
 
-	$graph->SetShadow();
+	// create an array with % values
+	$pcvalues = array();
+	for($i=0;$i<count($datay); $i++)
+	{
+		$pcvalues[$datay[$i]] = sprintf('%0.1f%%',100*$datay[$i]/$sum);
+	}
 
-	$graph->title->Set($title);
-	$graph->title->SetFont(FF_FONT1,FS_BOLD);
+	// create the pie chart and associate the filling colours			
+	$gbplot = & $plotarea->addNew('pie', $dataset);
+	$plotarea->hideAxis();
+	$gbplot->setFillStyle($fills);
 
-	$p1 = new PiePlot3D($datay);
-	$p1->SetTheme("sand");
-	$p1->ExplodeSlice(1);
-	$p1->SetCenter(0.45);
-	$p1->SetLegends($datax);
+	// format the data values
+	$marker_array =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', array($pcvalues));
+			
+	// set markers
+	$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+	$marker->setDataPreprocessor($marker_array);
+	$marker->setFillColor('#FFFFFF');
+	$marker->setBorderColor($font_color);
+	$marker->setFontColor($font_color);
+	$marker->setFontSize(8);
+	$pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker));
+	$gbplot->setMarker($pointingMarker);
+			
+	// set legend
+	$legend_box =& $plotarea->addNew('legend');
+	$legend_box->setPadding(array('top'=>20,'bottom'=>0,'left'=>0,'right'=>0));
+	$legend_box->setFillColor('#F5F5F5');
+	$legend_box->showShadow();
 
-	// Setup the labels
-	$p1->SetLabelType(PIE_VALUE_PER);    
-	$p1->value->Show();            
-	$p1->value->SetFormat('%2.1f%%');        
-	$p1->SetCSIMTargets($target,$alts);
-	// Don't display the border
-	$graph->SetFrame(false);
+	$img = $graph->done(
+						    array(
+							        'tohtml' => true,
+							        'border' => 0,
+							        'filename' => $cache_file_name,
+							        'filepath' => '',
+							        'urlpath' => ''
+							    ));
+	save_image_map($cache_file_name.'.map', $img);
 
-	$graph->Add($p1);
-
-	$graph-> Stroke( $cache_file_name );
-	$imgMap = $graph ->GetHTMLImageMap ($html_image_name);
-	save_image_map($cache_file_name.'.map', $imgMap);
-	$base_name_cache_file=basename($cache_file_name);
-	$ccc="cache/images/".$base_name_cache_file;
-	$img = "<img src=$ccc ismap usemap='#$html_image_name' border=0>" ;
-	$img.=$imgMap;
 	return $img;
 
 }

Modified: vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php (original)
+++ vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php Wed Apr  5 02:24:29 2006
@@ -10,124 +10,193 @@
 *
  ********************************************************************************/
 
-
-include ("jpgraph/src/jpgraph_flags.php");
-include ("jpgraph/src/jpgraph_iconplot.php");
-
-/** Function to render the Vertical Bar Graph
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
+require_once('config.php');
+require_once('include/utils/GraphUtils.php');
+include_once ('Image/Graph.php');
+include_once ('Image/Canvas.php');
+
+$tmp_dir=$root_directory."cache/images/";
+
+/** Function to render the Horizontal Graph
+        * Portions created by vtiger are Copyright (C) vtiger.
+        * All Rights Reserved.
+        * Contributor(s): ______________________________________..
  */
-
 function vertical_graph($referdata,$refer_code,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$cache_file_name,$html_image_name)
 {
 
-	//We'll be getting the values in the form of a string separated by commas
-	$datay=explode(",",$referdata); //The datay values
-	$datax=explode(",",$refer_code); // The datax values
-	$target_val=urldecode($target_val);// The links values for bar are given as string in the encoded form, here we are decoding it
+	global $log,$root_directory,$lang_crm,$theme;
+//We'll be getting the values in the form of a string separated by commas
+	$datay=explode(",",$referdata); // The datay values  
+	$datax=explode(",",$refer_code); // The datax values  
+
+// The links values are given as string in the encoded form, here we are decoding it
+	$target_val=urldecode($target_val);
 	$target=explode(",",$target_val);
 
-	$alts=array(); //Array which contains the data which is displayed on the mouse over
+	$alts=array();
 	$temp=array();
 	for($i=0;$i<count($datax);$i++)
 	{
 		$name=$datax[$i];
+		$pos = substr_count($name," ");
 		$alts[]=$name."=%d";
-
-		if(strlen($name)>=14)
-			$name=substr($name, 0, 14);
-		$temp[]=$name;
+//If the daatx value of a string is greater, adding '\n' to it so that it'll cme inh 2nd line
+		 if(strlen($name)>=14)
+                        $name=substr($name, 0, 14);
+		if($pos>=2)
+		{
+			$val=explode(" ",$name);
+			$n=count($val)-1;
+
+			$x="";
+			for($j=0;$j<count($val);$j++)
+			{
+				if($j != $n)
+				{
+					$x  .=" ". $val[$j];
+				}
+				else
+				{
+					$x .= "@#".$val[$j];
+				}
+			}
+			$name = $x;
+		}
+		$name=str_replace("@#", "\n",$name);
+		$temp[]=$name; 
 	}
 	$datax=$temp;
 
+	//datay is the values
+	//datax is the status
+
+	// Set the basic parameters of the graph
+	$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+	$imagemap = $canvas->getImageMap();
+	$graph =& Image_Graph::factory('graph', $canvas);
+	$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+	// set the font size to 12
+	$font->setSize(8);
+
+	if($theme == "blue")
+	{
+		$font_color = "#212473";
+	}
+	else
+	{
+		$font_color = "#000000";
+	}
+	$font->setColor($font_color);
+		
+	$graph->setFont($font);
+	$titlestr =& Image_Graph::factory('title', array($title,10));
+   	$plotarea =& Image_Graph::factory('plotarea',array(
+				'axis',
+				'axis',
+				'vertical'
+                ));
+	$graph->add(
+	    Image_Graph::vertical($titlestr,
+			$plotarea,
+    	5
+	 	)
+	);   
+
+
+	// Now create a bar plot
 	$max=0;
+	$xlabels = array();
+	$dataset = & Image_Graph::factory('dataset');
+	$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white'));
 	for($i=0;$i<count($datay); $i++)
 	{
-		$x=$datay[$i];
-		if($x>=$max)
-			$max=$x;
-		else
-			$max=$max;
-	}
-
-	// Create the graph. These two calls are always required
-	$graph = new Graph($width,$height,"auto");    
-	$graph->SetScale("textlin");
-	$graph->yaxis->scale->SetGrace(20);
-
-	// Add a drop shadow
-	$graph->SetShadow();
-
-	// Adjust the margin a bit to make more room for titles
-	$graph->img->SetMargin($left,$right,$top,$bottom);
-
-
-
-	// Create a bar pot
-	$bplot = new BarPlot($datay);
-
-	// Adjust fill color
-	$bplot->SetFillColor('orange');
-	$bplot->value->Show();
-	$graph->Add($bplot);
-
-	// Setup the titles
-	$graph->title->Set($title);
-
-	// Make the bar a little bit wider
-	$bplot->SetWidth(0.2);
+		$x=1+2*$i;
+		if($datay[$i]>=$max) $max=$datay[$i];
+		$dataset->addPoint(
+			        $x,
+			        $datay[$i],
+			        array(
+			            'url' => $target[$i],
+			            'alt' => $alts[$i]
+			        )
+	    );
+	    // build the xaxis label array to allow intermediate ticks
+	    $xlabels[$x] = $datax[$i];
+	    $xlabels[$x+1] = '';
+	}
+
+
+	//$bplot = new BarPlot($datay);
+	$bplot = & $plotarea->addNew('bar', $dataset);
+	$bplot->setFillStyle($fill);
+
+	//You can change the width of the bars if you like
+	$bplot->setBarWidth(50/count($datax),"%");
+	$bplot->setPadding(array('top'=>20));
+
+	$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', '#E5E5E5')));
 
 	// Setup X-axis
-	$graph->xaxis->SetTickLabels($datax);
-	$graph->xaxis->SetFont(FF_FONT2,FS_Bold,12);
-
-
-	$graph->xaxis->SetLabelAlign('center','top');
-	$graph->xaxis->SetLabelAngle(90);
-
-	$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
-	if($max>=5)
-	{
-		$graph->yaxis->SetLabelFormat('%d');
-	}
-
-	// Setup color for gradient fill style
-	$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER);
-	$graph->SetFrame(false);
-	$graph->SetMarginColor('white');
-	$graph->xgrid->Show();
-
-	// To get the Targets 
-	$bplot->SetCSIMTargets($target,$alts);
-
-	// Set color for the frame of each bar
-	$bplot->SetColor("navy");
-
-
-	$graph->SetBackgroundGradient('#F2FBDB','white',GRAD_VER,BGRAD_PLOT);
-
-	$graph->title->SetFont(FF_FONT1,FS_BOLD);
-
-	$img_path="test/logo/vtiger-crm-logo.jpg";
-
-	$icon = new IconPlot($img_path,0.7,0.3,1,30);
-	$icon->SetAnchor('center','center');
-	$graph->Add($icon);
-
-
-	$bplot->value->SetFormat('%d');
-
-	//Getting the graph in the form of html page
-	$graph-> Stroke( $cache_file_name );
-	$imgMap = $graph ->GetHTMLImageMap ($html_image_name);
-	save_image_map($cache_file_name.'.map', $imgMap);
-	$base_name_cache_file=basename($cache_file_name);
-	$ccc="cache/images/".$base_name_cache_file;
-	$img= "<img src=$ccc ismap usemap='#$html_image_name' border=0>" ;
-	$img.=$imgMap;
+	$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
+	$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+	$yaxis->setFontSize(10);
+			
+	// set grid
+	$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
+	$gridY->setLineColor('#E5E5E5 at 0.5');
+	$gridY2 =& $plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); 
+	$gridY2->setFillColor('#66CDAA at 0.2'); 
+
+
+	// Add some grace to y-axis so the bars doesn't go
+	// all the way to the end of the plot area
+	$yaxis->forceMaximum(round(($max * 1.1) + 0.5));
+
+	// First make the labels look right
+	$yaxis->setLabelInterval(1);
+	$yaxis->setTickOptions(5,0);
+	$yaxis->setLabelInterval(0.5,2);
+	$yaxis->setTickOptions(2,0,2);
+	
+	// Create the xaxis labels
+	$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
+	    array($xlabels) 
+	); 
+
+	// Then fix the tick marks
+	$xaxis->setDataPreprocessor($array_data);
+	$xaxis->forceMinimum(0);
+	$xaxis->forceMaximum(2*count($datay));
+	$xaxis->setFontAngle('vertical');
+	$xaxis->setLabelInterval(1);
+	$xaxis->setTickOptions(0,0);
+	$xaxis->setLabelInterval(2,2);
+	$xaxis->setTickOptions(5,0,2);
+			
+	// set markers
+	$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+	$marker->setFillColor('000000 at 0.0');
+	$marker->setBorderColor('000000 at 0.0');
+	$marker->setFontSize(10);
+	// shift markers 10 pix right
+	$marker_pointing =& $graph->addNew('Image_Graph_Marker_Pointing', array(0,-10,& $marker));
+	$marker_pointing->setLineColor('000000 at 0.0');
+	$bplot->setMarker($marker_pointing);
+
+
+	//Getting the graph in the form of html page	
+	$img = $graph->done(
+						    array(
+							        'tohtml' => true,
+							        'border' => 0,
+							        'filename' => $cache_file_name,
+							        'filepath' => '',
+							        'urlpath' => ''
+							    ));
+	save_image_map($cache_file_name.'.map', $img);
+
 	return $img;
-
 }
+
 ?>

Modified: vtigercrm/trunk/modules/Potentials/Charts.php
==============================================================================
Binary files - no diff available.





More information about the vtigercrm-commits mailing list