[Vtigercrm-commits] [vtiger-commits] r5063 - in /vtigercrm/trunk: include/utils/GraphUtils.php modules/Dashboard/horizontal_bargraph.php modules/Dashboard/vertical_bargraph.php modules/Potentials/Charts.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue Apr 11 12:02:24 EDT 2006
Author: jacquemesm
Date: Tue Apr 11 10:02:19 2006
New Revision: 5063
Log:
Dashboard add function to compute spacing of tick marks on value axis
Modified:
vtigercrm/trunk/include/utils/GraphUtils.php
vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php
vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php
vtigercrm/trunk/modules/Potentials/Charts.php
Modified: vtigercrm/trunk/include/utils/GraphUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/GraphUtils.php (original)
+++ vtigercrm/trunk/include/utils/GraphUtils.php Tue Apr 11 10:02:19 2006
@@ -28,7 +28,7 @@
/**This function is used to get the font name when a language code is given
* Param $locale - language code
-* Return type string
+* Return type string - font name
*/
function calculate_font_name($locale)
@@ -52,9 +52,11 @@
return FF_FONT1;
}
-/**This function is used to generate the color format.
-* Param $count - language code
-* Return type string
+/**This function is used to generate the n colors.
+* Param $count - number of colors to generate
+* Param $start - value of first color
+* Param $step - color increment to apply
+* Return type array - array of n colors values
*/
function color_generator($count = 1, $start = '33CCFF', $step = '221133')
@@ -78,4 +80,34 @@
}
return $result;
}
+
+/**This function is used to define the optimum spacin for tick marks on an axis
+* Param $max - maximum value of axis
+* Return type array - array of 2 values major and minor spacing
+*/
+
+function get_tickspacing($max = 10)
+{
+ $result = array(1,1);
+
+ // normalize $max to get value between 1 and 10
+ $coef = pow(10,floor(log10($max)));
+ $normalized = $max / $coef;
+
+ if($normalized < 1.5){
+ $result[0] = 0.2;
+ $result[1] = 0.1;
+ }
+ elseif($normalized < 5){
+ $result[0] = 0.5;
+ $result[1] = 0.1;
+ }
+ elseif($normalized < 10){
+ $result[0] = 1.0;
+ $result[1] = 0.5;
+ }
+ $result[0] *= $coef;
+ $result[1] *= $coef;
+ return $result;
+}
?>
Modified: vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php (original)
+++ vtigercrm/trunk/modules/Dashboard/horizontal_bargraph.php Tue Apr 11 10:02:19 2006
@@ -14,6 +14,8 @@
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.
@@ -173,11 +175,12 @@
// 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));
+ $ticks = get_tickspacing($max);
// First make the labels look right
- $yaxis->setLabelInterval(1);
+ $yaxis->setLabelInterval($ticks[0]);
$yaxis->setTickOptions(-5,0);
- $yaxis->setLabelInterval(0.5,2);
+ $yaxis->setLabelInterval($ticks[1],2);
$yaxis->setTickOptions(-2,0,2);
// Create the xaxis labels
Modified: vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php (original)
+++ vtigercrm/trunk/modules/Dashboard/vertical_bargraph.php Tue Apr 11 10:02:19 2006
@@ -14,6 +14,8 @@
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.
@@ -150,11 +152,12 @@
// 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));
+ $ticks = get_tickspacing($max);
// First make the labels look right
- $yaxis->setLabelInterval(1);
+ $yaxis->setLabelInterval($ticks[0]);
$yaxis->setTickOptions(5,0);
- $yaxis->setLabelInterval(0.5,2);
+ $yaxis->setLabelInterval($ticks[1],2);
$yaxis->setTickOptions(2,0,2);
// Create the xaxis labels
Modified: vtigercrm/trunk/modules/Potentials/Charts.php
==============================================================================
Binary files - no diff available.
More information about the vtigercrm-commits
mailing list