2012-03-05 Sergio Martin <sergio.martin@artica.es>

* include/functions_graph.php
	include/graphs/functions_flot.php
	include/graphs/FusionCharts
	include/graphs/functions_fsgraph.php
	include/graphs/fgraph.php
	operation/agentes/estado_generalagente.php
	godmode/db/db_info.php: Removed FlashCharts library
	and clean graphs code



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5691 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-03-05 10:26:34 +00:00
parent 029b45f9c1
commit 77c33c75a9
32 changed files with 56 additions and 3832 deletions

View File

@ -1,3 +1,14 @@
2012-03-05 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php
include/graphs/functions_flot.php
include/graphs/FusionCharts
include/graphs/functions_fsgraph.php
include/graphs/fgraph.php
operation/agentes/estado_generalagente.php
godmode/db/db_info.php: Removed FlashCharts library
and clean graphs code
2012-03-01 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* general/logon_ok.php: Fixed users link in welcome page.

View File

@ -49,7 +49,7 @@ echo '<table border=0 width="98%">';
echo '<tr><td>';
echo '<h4>'.__('Modules per agent').'</h4>';
echo graph_db_agentes_modulos2(600, 250);
echo graph_db_agentes_modulos(600, 250);
echo '</td></tr><tr><td><br /></tr></td>';
echo '<tr><td>';

View File

@ -375,10 +375,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
if ($only_image) {
$flash_chart = false;
}
if ($flash_chart) {
include_flash_chart_script($homeurl);
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
@ -772,10 +768,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$flash_charts = false;
}
if ($flash_charts){
include_flash_chart_script();
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
@ -824,8 +816,6 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
global $config;
global $graphic_type;
include_flash_chart_script();
$data = array ();
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
@ -1045,8 +1035,6 @@ function grafico_db_agentes_paquetes($width = 380, $height = 300) {
global $config;
global $graphic_type;
include_flash_chart_script();
$data = array ();
$legend = array ();
@ -1060,9 +1048,12 @@ function grafico_db_agentes_paquetes($width = 380, $height = 300) {
$data[$agents[$agent_id]]['g'] = $value;
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return hbar_graph($config['flash_charts'], $data, $width, $height, array(),
$legend, "", "", true, "",
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], false);
}
@ -1072,12 +1063,10 @@ function grafico_db_agentes_paquetes($width = 380, $height = 300) {
* @param integer height graph height
* @param integer width graph width
*/
function graph_db_agentes_modulos2($width, $height) {
function graph_db_agentes_modulos($width, $height) {
global $config;
global $graphic_type;
include_flash_chart_script();
$data = array ();
switch ($config['dbtype']){
@ -1415,11 +1404,12 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") {
}
$loop++;
}
if ($config['flash_charts']){
include_flash_chart_script();
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
@ -1469,8 +1459,11 @@ function grafico_eventos_total($filter = "") {
asort ($data);
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
@ -1515,9 +1508,12 @@ function grafico_eventos_usuario ($width, $height) {
$data[$event['id_usuario']] = $event['events'];
}
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
@ -1565,92 +1561,34 @@ function graph_custom_sql_graph ($id, $width, $height, $type = 'sql_graph_vbar',
}
$flash_charts = $config['flash_charts'];
if ($flash_charts){
include_flash_chart_script();
}
if ($only_image) {
$flash_charts = false;
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
switch ($type) {
case 'sql_graph_vbar': // vertical bar
return vbar_graph($flash_charts, $data, $width, $height, array(),
array(), "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], false, $ttl);
break;
case 'sql_graph_hbar': // horizontal bar
return hbar_graph($flash_charts, $data, $width, $height, array(),
array(), "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], false, $ttl);
break;
case 'sql_graph_pie': // Pie
return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], '', $ttl);
$water_mark, $config['fontpath'], '', $ttl);
break;
}
}
/**
* Print a graph with event data of agents
*
* @param integer id_agent Agent ID
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
*/
function graphic_agentevents ($id_agent, $width, $height, $period = 0) {
global $config;
global $graphic_type;
if ($config['flash_charts']) {
include_flash_chart_script();
}
$data = array ();
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
$interval = (int) ($period / $resolution);
$date = get_system_time ();
$datelimit = $date - $period;
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
$name = date('H\h', $bottom);
} else {
$name = $bottom;
}
$top = $datelimit + ($periodtime * ($i + 1));
$criticity = (int) db_get_value_filter ('criticity',
'tevento',
array ('id_agente' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top));
switch ($criticity) {
case 3: $data[$name] = 'E5DF63';
break;
case 4: $data[$name] = 'FF3C4B';
break;
default: $data[$name] = '9ABD18';
}
}
if (! $graphic_type) {
return fs_agent_event_chart ($data, $width, $height, $resolution / 750);
}
}
/**
* Print a static graph with event data of agents
*
@ -1659,7 +1597,7 @@ function graphic_agentevents ($id_agent, $width, $height, $period = 0) {
* @param integer height pie graph height
* @param integer period time period
*/
function graph_graphic_agentevents_static($id_agent, $width, $height, $period = 0, $homeurl) {
function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl) {
global $config;
global $graphic_type;
@ -1823,8 +1761,6 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
global $config;
global $graphic_type;
include_flash_chart_script($homeurl);
// Set variables
if ($date == 0) $date = get_system_time();
$datelimit = $date - $period;
@ -2104,17 +2040,21 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
/////////////////////////////////////////////////////////////////////////////////////////
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
$long_index, "images/image_problem.opaque.png", "", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], $unit);
}
@ -2127,8 +2067,6 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $only_im
global $config;
global $graphic_type;
include_flash_chart_script($config['homeurl']);
if (empty ($data)) {
echo fs_error_image ();
return;
@ -2182,10 +2120,13 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $only_im
} else {
$homeurl = '';
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return stacked_area_graph($flash_chart, $chart, $width, $height, null, $sources,
null, "images/image_problem.opaque.png", "", "",
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], "");
}
@ -2198,8 +2139,6 @@ function graph_netflow_total_area ($data, $period, $width, $height, $only_image)
global $config;
global $graphic_type;
include_flash_chart_script($config['homeurl']);
if (empty ($data)) {
echo fs_error_image ();
return;
@ -2238,9 +2177,12 @@ function graph_netflow_total_area ($data, $period, $width, $height, $only_image)
$homeurl = '';
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return area_graph($flash_chart, $chart, $width, $height, array (), array (),
array (), "images/image_problem.opaque.png", "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], "");
}
@ -2295,8 +2237,6 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
global $config;
global $graphic_type;
include_flash_chart_script($homeurl);
// Set variables
if ($date == 0) $date = get_system_time();
$datelimit = $date - $period;
@ -2485,9 +2425,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
//$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
/////////////////////////////////////////////////////////////////////////////////////////
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}

View File

@ -1,311 +0,0 @@
/**
* FusionCharts: Flash Player detection and Chart embedding.
* Version: vFree.1.2 (1st November, 2007) - Added Player detection, New conditional fixes for IE, supports FORM in IE
*
* Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();
infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){
if (!document.getElementById) { return; }
//Flag to see whether data has been set initially
this.initialDataSet = false;
//Create container objects
this.params = new Object();
this.variables = new Object();
this.attributes = new Array();
//Set attributes for the SWF
if(swf) { this.setAttribute('swf', swf); }
if(id) { this.setAttribute('id', id); }
if(w) { this.setAttribute('width', w); }
if(h) { this.setAttribute('height', h); }
//Set background color
if(c) { this.addParam('bgcolor', c); }
//Set Quality
this.addParam('quality', 'high');
//Add scripting access parameter
this.addParam('allowScriptAccess', 'always');
//Pass width and height to be appended as chartWidth and chartHeight
this.addVariable('chartWidth', w);
this.addVariable('chartHeight', h);
//Whether in debug mode
debugMode = debugMode ? debugMode : 0;
this.addVariable('debugMode', debugMode);
//Pass DOM ID to Chart
this.addVariable('DOMId', id);
//Whether to registed with JavaScript
registerWithJS = registerWithJS ? registerWithJS : 0;
this.addVariable('registerWithJS', registerWithJS);
//Scale Mode of chart
scaleMode = scaleMode ? scaleMode : 'noScale';
this.addVariable('scaleMode', scaleMode);
//Application Message Language
lang = lang ? lang : 'EN';
this.addVariable('lang', lang);
//Whether to auto detect and re-direct to Flash Player installation
this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;
this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;
//Ger Flash Player version
this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();
if (!window.opera && document.all && this.installedVer.major > 7) {
// Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
infosoftglobal.FusionCharts.doPrepUnload = true;
}
}
infosoftglobal.FusionCharts.prototype = {
setAttribute: function(name, value){
this.attributes[name] = value;
},
getAttribute: function(name){
return this.attributes[name];
},
addParam: function(name, value){
this.params[name] = value;
},
getParams: function(){
return this.params;
},
addVariable: function(name, value){
this.variables[name] = value;
},
getVariable: function(name){
return this.variables[name];
},
getVariables: function(){
return this.variables;
},
getVariablePairs: function(){
var variablePairs = new Array();
var key;
var variables = this.getVariables();
for(key in variables){
variablePairs.push(key +"="+ variables[key]);
}
return variablePairs;
},
getSWFHTML: function() {
var swfNode = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
// netscape plugin architecture
swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" ';
swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
var params = this.getParams();
for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
var pairs = this.getVariablePairs().join("&");
if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
swfNode += '/>';
} else { // PC IE
swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
var params = this.getParams();
for(var key in params) {
swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
}
var pairs = this.getVariablePairs().join("&");
if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
swfNode += "</object>";
}
return swfNode;
},
setDataURL: function(strDataURL){
//This method sets the data URL for the chart.
//If being set initially
if (this.initialDataSet==false){
this.addVariable('dataURL',strDataURL);
//Update flag
this.initialDataSet = true;
}else{
//Else, we update the chart data using External Interface
//Get reference to chart object
var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
chartObj.setDataURL(strDataURL);
}
},
setDataXML: function(strDataXML){
//If being set initially
if (this.initialDataSet==false){
//This method sets the data XML for the chart INITIALLY.
this.addVariable('dataXML',strDataXML);
//Update flag
this.initialDataSet = true;
}else{
//Else, we update the chart data using External Interface
//Get reference to chart object
var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
chartObj.setDataXML(strDataXML);
}
},
render: function(elementId){
//First check for installed version of Flash Player - we need a minimum of 6
if((this.detectFlashVersion==1) && (this.installedVer.major < 6)){
if (this.autoInstallRedirect==1){
//If we can auto redirect to install the player?
var installationConfirm = window.confirm("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");
if (installationConfirm){
window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
}else{
return false;
}
}else{
//Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link).
//So, expect the developers to provide a course of way to their end users.
//window.alert("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. ");
return false;
}
}else{
//Render the chart
var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
n.innerHTML = this.getSWFHTML();
//Added for .NET AJAX and <FORM> compatibility
if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id'));
//or else document.forms[formName/formIndex][chartId]
return true;
}
}
}
/* ---- detection functions ---- */
infosoftglobal.FusionChartsUtil.getPlayerVersion = function(){
var PlayerVersion = new infosoftglobal.PlayerVersion([0,0,0]);
if(navigator.plugins && navigator.mimeTypes.length){
var x = navigator.plugins["Shockwave Flash"];
if(x && x.description) {
PlayerVersion = new infosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
}
}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){
//If Windows CE
var axo = 1;
var counter = 3;
while(axo) {
try {
counter++;
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
PlayerVersion = new infosoftglobal.PlayerVersion([counter,0,0]);
} catch (e) {
axo = null;
}
}
} else {
// Win IE (non mobile)
// Do minor version lookup in IE, but avoid Flash Player 6 crashing issues
try{
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
}catch(e){
try {
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
PlayerVersion = new infosoftglobal.PlayerVersion([6,0,21]);
axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
} catch(e) {
if (PlayerVersion.major == 6) {
return PlayerVersion;
}
}
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
} catch(e) {}
}
if (axo != null) {
PlayerVersion = new infosoftglobal.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}
}
return PlayerVersion;
}
infosoftglobal.PlayerVersion = function(arrVersion){
this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
// ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//
/* Fix for video streaming bug */
infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {
var objects = document.getElementsByTagName("OBJECT");
for (var i = objects.length - 1; i >= 0; i--) {
objects[i].style.display = 'none';
for (var x in objects[i]) {
if (typeof objects[i][x] == 'function') {
objects[i][x] = function(){};
}
}
}
}
// Fixes bug in fp9
if (infosoftglobal.FusionCharts.doPrepUnload) {
if (!infosoftglobal.unloadSet) {
infosoftglobal.FusionChartsUtil.prepUnload = function() {
__flash_unloadHandler = function(){};
__flash_savedUnloadHandler = function(){};
window.attachEvent("onunload", infosoftglobal.FusionChartsUtil.cleanupSWFs);
}
window.attachEvent("onbeforeunload", infosoftglobal.FusionChartsUtil.prepUnload);
infosoftglobal.unloadSet = true;
}
}
/* Add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
/* Add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
/* Function to return Flash Object from ID */
infosoftglobal.FusionChartsUtil.getChartObject = function(id)
{
// set off to test in .NET AJAX and <FORM> environment
//if (window.document[id]) {
// return window.document[id];
//}
var chartRef=null;
if (navigator.appName.indexOf("Microsoft Internet")==-1) {
if (document.embeds && document.embeds[id])
chartRef = document.embeds[id];
else
chartRef = window.document[id];
}
else {
chartRef = window[id];
}
if (!chartRef)
chartRef = document.getElementById(id);
return chartRef;
}
/*
Function to update chart's data at client side (FOR FusionCharts vFREE and 2.x
*/
infosoftglobal.FusionChartsUtil.updateChartXML = function(chartId, strXML){
//Get reference to chart object
var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(chartId);
//Set dataURL to null
chartObj.SetVariable("_root.dataURL","");
//Set the flag
chartObj.SetVariable("_root.isNewData","1");
//Set the actual data
chartObj.SetVariable("_root.newData",strXML);
//Go to the required frame
chartObj.TGotoLabel("/", "JavaScriptHandler");
}
/* Aliases for easy usage */
var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;
var updateChartXML = infosoftglobal.FusionChartsUtil.updateChartXML;
var FusionCharts = infosoftglobal.FusionCharts;

View File

@ -1,144 +0,0 @@
<?php
// Page: FusionCharts.php
// Author: InfoSoft Global (P) Ltd.
// This page contains functions that can be used to render FusionCharts.
// encodeDataURL function encodes the dataURL before it's served to FusionCharts.
// If you've parameters in your dataURL, you necessarily need to encode it.
// Param: $strDataURL - dataURL to be fed to chart
// Param: $addNoCacheStr - Whether to add aditional string to URL to disable caching of data
function encodeDataURL($strDataURL, $addNoCacheStr=false) {
//Add the no-cache string if required
if ($addNoCacheStr==true) {
// We add ?FCCurrTime=xxyyzz
// If the dataURL already contains a ?, we add &FCCurrTime=xxyyzz
// We replace : with _, as FusionCharts cannot handle : in URLs
if (strpos(strDataURL,"?")<>0)
$strDataURL .= "&FCCurrTime=" . Date("H_i_s");
else
$strDataURL .= "?FCCurrTime=" . Date("H_i_s");
}
// URL Encode it
return urlencode($strDataURL);
}
// datePart function converts MySQL database based on requested mask
// Param: $mask - what part of the date to return "m' for month,"d" for day, and "y" for year
// Param: $dateTimeStr - MySQL date/time format (yyyy-mm-dd HH:ii:ss)
function datePart($mask, $dateTimeStr) {
@list($datePt, $timePt) = explode(" ", $dateTimeStr);
$arDatePt = explode("-", $datePt);
$dataStr = "";
// Ensure we have 3 parameters for the date
if (count($arDatePt) == 3) {
list($year, $month, $day) = $arDatePt;
// determine the request
switch ($mask) {
case "m": return (int)$month;
case "d": return (int)$day;
case "y": return (int)$year;
}
// default to mm/dd/yyyy
return (trim($month . "/" . $day . "/" . $year));
}
return $dataStr;
}
// renderChart renders the JavaScript + HTML code required to embed a chart.
// This function assumes that you've already included the FusionCharts JavaScript class
// in your page.
// $chartSWF - SWF File Name (and Path) of the chart which you intend to plot
// $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
// $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
// $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
// $chartWidth - Intended width for the chart (in pixels)
// $chartHeight - Intended height for the chart (in pixels)
function renderChart($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight) {
//First we create a new DIV for each chart. We specify the name of DIV as "chartId"Div.
//DIV names are case-sensitive.
// The Steps in the script block below are:
//
// 1)In the DIV the text "Chart" is shown to users before the chart has started loading
// (if there is a lag in relaying SWF from server). This text is also shown to users
// who do not have Flash Player installed. You can configure it as per your needs.
//
// 2) The chart is rendered using FusionCharts Class. Each chart's instance (JavaScript) Id
// is named as chart_"chartId".
//
// 3) Check whether we've to provide data using dataXML method or dataURL method
// save the data for usage below
if ($strXML=="")
$tempData = "//Set the dataURL of the chart\n\t\tchart_$chartId.setDataURL(\"$strURL\")";
else
$tempData = "//Provide entire XML data using dataXML method\n\t\tchart_$chartId.setDataXML(\"$strXML\")";
// Set up necessary variables for the RENDERCAHRT
$chartIdDiv = $chartId . "Div";
// create a string for outputting by the caller
$render_chart = <<<RENDERCHART
<!-- START Script Block for Chart $chartId -->
<div id="$chartIdDiv" align="center">
Chart.
</div>
<script type="text/javascript">
//Instantiate the Chart
var chart_$chartId = new FusionCharts("$chartSWF", "$chartId", "$chartWidth", "$chartHeight");
$tempData
//Finally, render the chart.
chart_$chartId.render("$chartIdDiv");
</script>
<!-- END Script Block for Chart $chartId -->
RENDERCHART;
return $render_chart;
}
//renderChartHTML function renders the HTML code for the JavaScript. This
//method does NOT embed the chart using JavaScript class. Instead, it uses
//direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
//see the "Click to activate..." message on the chart.
// $chartSWF - SWF File Name (and Path) of the chart which you intend to plot
// $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
// $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
// $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
// $chartWidth - Intended width for the chart (in pixels)
// $chartHeight - Intended height for the chart (in pixels)
function renderChartHTML($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight) {
// Generate the FlashVars string based on whether dataURL has been provided
// or dataXML.
$strFlashVars = "&chartWidth=" . $chartWidth . "&chartHeight=" . $chartHeight ;
if ($strXML=="")
// DataURL Mode
$strFlashVars .= "&dataURL=" . $strURL;
else
//DataXML Mode
$strFlashVars .= "&dataXML=" . $strXML;
$HTML_chart = <<<HTMLCHART
<!-- START Code Block for Chart $chartId -->
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="$chartWidth" height="$chartHeight" id="$chartId">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="$chartSWF"/>
<param name="FlashVars" value="$strFlashVars" />
<param name="quality" value="high" />
<embed src="$chartSWF" FlashVars="$strFlashVars" quality="high" width="$chartWidth" height="$chartHeight" name="$chartId" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<!-- END Code Block for Chart $chartId -->
HTMLCHART;
return $HTML_chart;
}
// boolToNum function converts boolean values to numeric (1/0)
function boolToNum($bVal) {
return (($bVal==true) ? 1 : 0);
}
?>

View File

@ -185,7 +185,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) {
if($flash_chart) {
echo fs_area_chart ($chart_data, $width, $height);
return flot_area_simple_graph($chart_data, $width, $height);
}
else {
echo "<img src='include/graphs/functions_pchart.php?static_graph=1&graph_type=threshold&ttl=".$ttl."&data=".json_encode($chart_data)."&width=".$width."&height=".$height."'>";
@ -429,14 +429,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
}
if($flash_chart) {
switch($graph_type) {
case "2d":
return fs_2d_pie_chart (array_values($chart_data), array_keys($chart_data), $width, $height);
break;
case "3d":
return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size);
break;
}
return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size);
}
else {
$graph = array();
@ -460,12 +453,4 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
}
}
function gantt_graph($project_name, $from, $to, $tasks, $milestones, $width, $height, $ttl = 1) {
return fs_gantt_chart ($project_name, $from, $to, $tasks, $milestones, $width, $height, $ttl);
}
function include_flash_chart_script($homeurl = '') {
echo '<script language="JavaScript" src="' . $homeurl . 'include/graphs/FusionCharts/FusionCharts.js"></script>';
}
?>

View File

@ -211,181 +211,8 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
}
///////////////////////////////
///// END OF AREA GRAPHS //////
///////////////////////////////
function fs_line_graph2($chart_data, $width, $height, $color, $legend, $long_index) {
global $config;
$graph_type = "MSLine";
$chart = new FusionCharts($graph_type, $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($chart_data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($chart_data))) {
$data2 = array();
$count = 0;
foreach($chart_data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
if (isset($long_index[$i])) {
$chart->addCategory($i, //'');
'hoverText=' . $long_index[$i] .
';showName=' . $show_name);
}
else {
$chart->addCategory($i, 'showName=' . $show_name);
}
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($chart_data);
}
$a = 0;
$empty = 1;
foreach ($data as $i => $value) {
$legend_text = '';
if (isset($legend[$i])) {
$legend_text = $legend[$i];
}
$alpha = '';
$areaBorderColor = '';
$color = '';
$showAreaBorder = 1; //0 old default
if (isset($color[$i])) {
if (!isset($color[$i]['border'])) {
$showAreaBorder = 1;
}
if (isset($color[$i]['alpha'])) {
$alpha = 'alpha=' . $color[$i]['alpha'] . ';';
}
if (isset($color[$i]['border'])) {
$areaBorderColor = 'areaBorderColor=' . $color[$i]['border'] . ';';
}
if (isset($color[$i]['color'])) {
$color = 'color=#' . $color[$i]['color'];
}
}
$chart->addDataSet($legend_text, $alpha .
'showAreaBorder=' . $showAreaBorder . ';' .
$areaBorderColor .
$color);
$count = 0;
$step = 10;
$num_vlines = 0;
foreach ($value as $i2 => $v) {
if ($count++ % $step == 0) {
$show_name = '1';
$num_vlines++;
}
else {
$show_name = '0';
}
$empty = 0;
if ($a < 3) {
$a++;
// $chart->addCategory(date('G:i', $i2), //'');
// 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i2) .
// ';showName=' . $show_name);
}
//Add data
$chart->addChartData($v);
}
}
$chart->setChartParams('animation=0;numVDivLines=' . $num_vlines .
';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;' .
'lineThickness=3;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;' .
'showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
$random_number = uniqid();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
//$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>';
$output .= '<script type="text/javascript">
<!--
function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("include/graphs/FusionCharts/FCF_'.$graph_type.'.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.addParam("WMode", "Transparent");
myChart.render("' . $div_id . '");
}
pie_' . $chart_id . ' ();
-->
</script>';
return $output;
}
///////////////////////////////
///////////////////////////////
///////////////////////////////
// Returns the number of seconds since the Epoch for a date in the format dd/mm/yyyy
function date_to_epoch2 ($date) {
$date_array = explode ('/', $date);
return mktime (0, 0, 0, $date_array [1], $date_array [0], $date_array [2]);
}
// Returns the code needed to display the chart
function get_chart_code2 ($chart, $width, $height, $swf) {
$random_number = rand ();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$output = '<div id="' . $div_id. '"></div>';
$output .= '<script type="text/javascript">
<!--
$(document).ready(function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("' . $swf . '", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.render("' . $div_id . '");
})
-->
</script>';
return $output;
}
// Prints a FLOT pie chart
function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font = '', $font_size = 8) {
@ -420,184 +247,6 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font =
return $return;
}
// Prints a 2D pie chart
function fs_2d_pie_chart2 ($data, $names, $width, $height, $background = "FFFFFF") {
if ((sizeof ($data) != sizeof ($names)) OR (sizeof($data) == 0) ){
return;
}
// Generate the XML
$chart = new FusionCharts("Pie3D", $width, $height);
$chart->setSWFPath("include/graphs/FusionCharts/");
$params="showNames=1;showValues=0;showPercentageValues=0;baseFontSize=9;bgColor=$background;bgAlpha=100;canvasBgAlpha=100;";
$chart->setChartParams($params);
for ($i = 0; $i < sizeof ($data); $i++) {
$chart->addChartData($data[$i], 'name=' . clean_flash_string($names[$i]));
}
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Pie2D.swf');
}
// Returns a 2D column chart
function fs_2d_column_chart2 ($data, $width, $height, $homeurl = '', $reduce_data_columns = false) {
if (sizeof ($data) == 0) {
return;
}
// Generate the XML
$chart = new FusionCharts('Column2D', $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($data))) {
$data2 = array();
$count = 0;
foreach($data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
$chart->addCategory($i, //'');
'hoverText=' . $i .
';showName=' . $show_name);
$c = 0;
$previous = false;
foreach($values as $i2 => $value) {
if ($reduce_data_columns) {
if ($previous !== false) {
if ($previous == $value) continue;
}
}
$data2[$i2][$i] = $value;
$c++;
$previous = $value;
}
}
$data = $data2;
}
else {
$data = array($data);
}
$empty = 0;
$num_vlines = 0;
$count = 0;
foreach ($data as $legend_value => $values) {
foreach($values as $name => $value) {
if (($count++ % $step) == 0) {
$show_name = '1';
$num_vlines++;
} else {
$show_name = '0';
}
if ($value != 0) {
$empty = 0;
}
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=95BB04');
}
}
$chart->setChartParams('decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;'
. ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
// Return the code
return get_chart_code ($chart, $width, $height, $homeurl . 'include/graphs/FusionCharts/FCF_Column2D.swf');
}
// Returns a BAR Horizontalchart
function fs_2d_hcolumn_chart2 ($data, $width, $height) {
if (sizeof ($data) == 0) {
return;
}
// Generate the XML
$chart = new FusionCharts('Bar2D', $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($data))) {
$data2 = array();
$count = 0;
foreach($data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
$chart->addCategory($i, //'');
'hoverText=' . $i .
';showName=' . $show_name);
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($data);
}
$empty = 0;
$num_vlines = 0;
$count = 0;
foreach ($data as $legend_value => $values) {
foreach($values as $name => $value) {
if (($count++ % $step) == 0) {
$show_name = '1';
$num_vlines++;
} else {
$show_name = '0';
}
if ($value != 0) {
$empty = 0;
}
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name/* . ';color=95BB04'*/);
}
}
$params='showNames=1;showValues=0;showPercentageValues=0;baseFontSize=9;rotateNames=1;chartLeftMargin=0;chartRightMargin=0;chartBottomMargin=0;chartTopMargin=0;showBarShadow=1;showLimits=1';
$chart->setChartParams($params.';numVDivLines='.$num_vlines.($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Bar2D.swf');
}
// Returns a 3D column chart
function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark) {
global $config;
@ -895,162 +544,6 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $
return $return;
}
// Prints a Gantt chart
function fs_gantt_chart2 ($title, $from, $to, $tasks, $milestones, $width, $height) {
// Generate the XML
$chart = new FusionCharts("Gantt", $width, $height, "1", "0");
$chart->setSWFPath("include/graphs/FusionCharts/");
$chart->setChartParams('dateFormat=dd/mm/yyyy;hoverCapBorderColor=2222ff;hoverCapBgColor=e1f5ff;ganttLineAlpha=80;canvasBorderColor=024455;canvasBorderThickness=0;gridBorderColor=2179b1;gridBorderAlpha=20;ganttWidthPercent=80');
$chart->setGanttProcessesParams('headerText=' . __('Task') . ';fontColor=ffffff;fontSize=9;isBold=1;isAnimated=1;bgColor=2179b1;headerbgColor=2179b1;headerFontColor=ffffff;headerFontSize=12;align=left');
$chart->setGanttTasksParams('');
$start_date = explode ('/', $from);
$start_day = $start_date[0];
$start_month = $start_date[1];
$start_year = $start_date[2];
$end_date = explode ('/', $to);
$end_day = $end_date[0];
$end_month = $end_date[1];
$end_year = $end_date[2];
$time_span = date_to_epoch ($to) - date_to_epoch ($from);
// Years
$chart->addGanttCategorySet ('bgColor=2179b1;fontColor=ff0000');
for ($i = $start_year; $i <= $end_year; $i++) {
if ($i == $start_year) {
$start = sprintf ('%02d/%02d/%04d', $start_day, $start_month, $start_year);
} else {
$start = sprintf ('%02d/%02d/%04d', 1, 1, $i);
}
if ($i == $end_year) {
$end = sprintf ('%02d/%02d/%04d', $end_day, $end_month, $end_year);
} else {
$end = sprintf ('%02d/%02d/%04d', cal_days_in_month (CAL_GREGORIAN, 12, $i), 12, $i);
}
$chart->addGanttCategory ($i, ';start=' . $start . ';end=' . $end . ';align=center;fontColor=ffffff;isBold=1;fontSize=16');
}
// Months
$chart->addGanttCategorySet ('bgColor=ffffff;fontColor=1288dd;fontSize=10');
for ($i = $start_year ; $i <= $end_year; $i++) {
for ($j = 1 ; $j <= 12; $j++) {
if ($i == $start_year && $j < $start_month) {
continue;
} else if ($i == $end_year && $j > $end_month) {
break;
}
if ($i == $start_year && $j == $start_month) {
$start = sprintf ('%02d/%02d/%04d', $start_day, $start_month, $start_year);
} else {
$start = sprintf ('%02d/%02d/%04d', 1, $j, $i);
}
if ($i == $end_year && $j == $end_month) {
$end = sprintf ('%02d/%02d/%04d', $end_day, $end_month, $end_year);
} else {
$end = sprintf ('%02d/%02d/%04d', cal_days_in_month (CAL_GREGORIAN, $j, $i), $j, $i);
}
$chart->addGanttCategory (date('F', mktime(0,0,0,$j,1)), ';start=' . $start . ';end=' . $end . ';align=center;isBold=1');
}
}
// Days
if ($time_span < 2592000) {
$chart->addGanttCategorySet ();
for ($i = $start_year ; $i <= $end_year; $i++) {
for ($j = 1 ; $j <= 12; $j++) {
if ($i == $start_year && $j < $start_month) {
continue;
} else if ($i == $end_year && $j > $end_month) {
break;
}
$num_days = cal_days_in_month (CAL_GREGORIAN, $j, $i);
for ($k = 1 ; $k <= $num_days; $k++) {
if ($i == $start_year && $j == $start_month && $k < $start_day) {
continue;
} else if ($i == $end_year && $j == $end_month && $k > $end_day) {
break;
}
$start = sprintf ('%02d/%02d/%04d', $k, $j, $i);
$end = sprintf ('%02d/%02d/%04d', $k, $j, $i);
$chart->addGanttCategory ($k, ';start=' . $start . ';end=' . $end . ';fontSize=8;isBold=0');
}
}
}
}
// Weeks
else if ($time_span < 10368000) {
$chart->addGanttCategorySet ();
for ($i = $start_year ; $i <= $end_year; $i++) {
for ($j = 1 ; $j <= 12; $j++) {
if ($i == $start_year && $j < $start_month) {
continue;
} else if ($i == $end_year && $j > $end_month) {
break;
}
$num_days = cal_days_in_month (CAL_GREGORIAN, $j, $i);
for ($k = 1, $l = 1; $k <= $num_days; $k += 8, $l++) {
if ($i == $start_year && $j == $start_month && $k + 7 < $start_day) {
continue;
}
if ($i == $end_year && $j == $end_month && $k > $end_day) {
break;
}
if ($i == $start_year && $j == $start_month && $k < $start_day) {
$start = sprintf ('%02d/%02d/%04d', $start_day, $j, $i);
} else {
$start = sprintf ('%02d/%02d/%04d', $k, $j, $i);
}
if ($i == $end_year && $j == $end_month && $k + 7 > $end_day) {
$end = sprintf ('%02d/%02d/%04d', $end_day, $j, $i);
} else if ($k + 7 > $num_days) {
$end = sprintf ('%02d/%02d/%04d', $num_days, $j, $i);
} else {
$end = sprintf ('%02d/%02d/%04d', $k + 7, $j, $i);
}
$chart->addGanttCategory (__('Week') . " $l", ';start=' . $start . ';end=' . $end . ';fontSize=8;isBold=0');
}
}
}
}
// Tasks
foreach ($tasks as $task) {
$chart->addGanttProcess (clean_flash_string($task['name']), 'id=' . $task['id'] . ';link=' . urlencode($task['link']));
$chart->addGanttTask (__('Planned'), 'start=' . $task['start'] . ';end=' . $task['end'] . ';id=' . $task['id'] . ';processId=' . $task['id'] . ';color=4b3cff;height=5;topPadding=10;animation=0');
if ($task['real_start'] !== false && $task['real_end']) {
$chart->addGanttTask (__('Actual'), 'start=' . $task['real_start'] . ';end=' . $task['real_end'] . ';processId=' . $task['id'] . ';color=ff3c4b;alpha=100;topPadding=15;height=5');
}
if ($task['completion'] != 0) {
$task_span = date_to_epoch ($task['end']) - date_to_epoch ($task['start']);
$end = date ('d/m/Y', date_to_epoch ($task['start']) + $task_span * $task['completion'] / 100.0);
$chart->addGanttTask (__('Completion')." (".$task['completion'].")", 'start=' . $task['start'] . ';end=' . $end . ';processId=' . $task['id'] . ';color=32cd32;alpha=100;topPadding=20;height=5');
}
if ($task['parent'] != 0) {
$chart->addGanttConnector ($task['parent'], $task['id'], 'color=2179b1;thickness=2;fromTaskConnectStart=1');
}
}
// Milestones
if ($milestones !== '') {
$chart->addGanttProcess (__('Milestones'), 'id=0');
foreach ($milestones as $milestone) {
$chart->addGanttTask (clean_flash_string($milestone['name']), 'start=' . $milestone['date'] . ';end=' . $milestone['date'] . ';id=ms-' . $milestone['id'] . ';processId=0;color=ffffff;alpha=0;height=60;topPadding=0;animation=0');
$chart->addGanttMilestone ('ms-' . $milestone['id'], 'date=' . $milestone['date'] . ';radius=8;color=efbb07;shape=star;numSides=3;borderThickness=1');
}
}
// Today
$chart->addTrendLine ('start=' . date ('d/m/Y') . ';displayValue='. __('Today') . ';color=666666;isTrendZone=1;alpha=20');
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Gantt.swf');
}
?>
<script type="text/javascript">

View File

@ -1,873 +0,0 @@
<?PHP
// Copyright (c) 2007-2008 Sancho Lerena, slerena@gmail.com
// Copyright (c) 2008 Esteban Sanchez, estebans@artica.es
// Copyright (c) 2007-2011 Artica, info@artica.es
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// (LGPL) as published by the Free Software Foundation; version 2
// This program 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 Lesser General Public License for more details.
if (!class_exists("FusionCharts")) {
require_once ("FusionCharts/FusionCharts_Gen.php");
}
///////////////////////////////
///////////////////////////////
///////////////////////////////
function fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index) {
global $config;
$graph_type = "StackedArea2D";
$chart = new FusionCharts($graph_type, $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($chart_data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($chart_data))) {
$data2 = array();
$count = 0;
foreach($chart_data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
if (isset($long_index[$i])) {
$chart->addCategory($i, //'');
'hoverText=' . $long_index[$i] .
';showName=' . $show_name);
}
else {
$chart->addCategory($i, 'showName=' . $show_name);
}
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($chart_data);
}
$a = 0;
$empty = 1;
foreach ($data as $i => $value) {
$legend_text = '';
if (isset($legend[$i])) {
$legend_text = $legend[$i];
}
$alpha = '';
$areaBorderColor = '';
$color = '';
$showAreaBorder = 1; //0 old default
if (isset($color[$i])) {
if (!isset($color[$i]['border'])) {
$showAreaBorder = 1;
}
if (isset($color[$i]['alpha'])) {
$alpha = 'alpha=' . $color[$i]['alpha'] . ';';
}
if (isset($color[$i]['border'])) {
$areaBorderColor = 'areaBorderColor=' . $color[$i]['border'] . ';';
}
if (isset($color[$i]['color'])) {
$color = 'color=#' . $color[$i]['color'];
}
}
$chart->addDataSet($legend_text, $alpha .
'showAreaBorder=' . $showAreaBorder . ';' .
$areaBorderColor .
$color);
$count = 0;
$step = 10;
$num_vlines = 0;
foreach ($value as $i2 => $v) {
if ($count++ % $step == 0) {
$show_name = '1';
$num_vlines++;
}
else {
$show_name = '0';
}
$empty = 0;
if ($a < 3) {
$a++;
// $chart->addCategory(date('G:i', $i2), //'');
// 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i2) .
// ';showName=' . $show_name);
}
//Add data
$chart->addChartData($v);
}
}
$chart->setChartParams('animation=0;numVDivLines=' . $num_vlines .
';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;' .
'lineThickness=0.1;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;' .
'showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
$random_number = uniqid();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
//$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>';
$output .= '<script type="text/javascript">
<!--
function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("include/graphs/FusionCharts/FCF_'.$graph_type.'.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.addParam("WMode", "Transparent");
myChart.render("' . $div_id . '");
}
pie_' . $chart_id . ' ();
-->
</script>';
return $output;
}
function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index) {
global $config;
$graph_type = "MSLine";
$chart = new FusionCharts($graph_type, $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($chart_data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($chart_data))) {
$data2 = array();
$count = 0;
foreach($chart_data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
if (isset($long_index[$i])) {
$chart->addCategory($i, //'');
'hoverText=' . $long_index[$i] .
';showName=' . $show_name);
}
else {
$chart->addCategory($i, 'showName=' . $show_name);
}
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($chart_data);
}
$a = 0;
$empty = 1;
foreach ($data as $i => $value) {
$legend_text = '';
if (isset($legend[$i])) {
$legend_text = $legend[$i];
}
$alpha = '';
$areaBorderColor = '';
$color = '';
$showAreaBorder = 1; //0 old default
if (isset($color[$i])) {
if (!isset($color[$i]['border'])) {
$showAreaBorder = 1;
}
if (isset($color[$i]['alpha'])) {
$alpha = 'alpha=' . $color[$i]['alpha'] . ';';
}
if (isset($color[$i]['border'])) {
$areaBorderColor = 'areaBorderColor=' . $color[$i]['border'] . ';';
}
if (isset($color[$i]['color'])) {
$color = 'color=#' . $color[$i]['color'];
}
}
$chart->addDataSet($legend_text, $alpha .
'showAreaBorder=' . $showAreaBorder . ';' .
$areaBorderColor .
$color);
$count = 0;
$step = 10;
$num_vlines = 0;
foreach ($value as $i2 => $v) {
if ($count++ % $step == 0) {
$show_name = '1';
$num_vlines++;
}
else {
$show_name = '0';
}
$empty = 0;
if ($a < 3) {
$a++;
// $chart->addCategory(date('G:i', $i2), //'');
// 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i2) .
// ';showName=' . $show_name);
}
//Add data
$chart->addChartData($v);
}
}
$chart->setChartParams('animation=0;numVDivLines=' . $num_vlines .
';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;' .
'lineThickness=3;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;' .
'showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
$random_number = uniqid();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
//$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>';
$output .= '<script type="text/javascript">
<!--
function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("include/graphs/FusionCharts/FCF_'.$graph_type.'.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.addParam("WMode", "Transparent");
myChart.render("' . $div_id . '");
}
pie_' . $chart_id . ' ();
-->
</script>';
return $output;
}
function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit) {
global $config;
$graph_type = "MSArea2D"; //MSLine is possible also
$chart = new FusionCharts($graph_type, $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($chart_data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($chart_data))) {
$data2 = array();
$count = 0;
foreach($chart_data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
if (isset($long_index[$i])) {
$chart->addCategory($i, //'');
'hoverText=' . $long_index[$i] .
';showName=' . $show_name);
}
else {
$chart->addCategory($i, 'showName=' . $show_name);
}
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($chart_data);
}
$a = 0;
$empty = 1;
foreach ($data as $i => $value) {
$legend_text = '';
if (isset($legend[$i])) {
$legend_text = $legend[$i];
}
$alpha = '';
$areaBorderColor = '';
$color = '';
$showAreaBorder = 1; //0 old default
if (isset($colors[$i])) {
if (!isset($colors[$i]['border'])) {
$showAreaBorder = 1;
}
if (isset($colors[$i]['alpha'])) {
$alpha = 'alpha=' . $colors[$i]['alpha'] . ';';
}
if (isset($colors[$i]['border'])) {
$areaBorderColor = 'areaBorderColor=' . $colors[$i]['border'] . ';';
}
if (isset($colors[$i]['color'])) {
$color = 'color=#' . $colors[$i]['color'];
}
}
$chart->addDataSet($legend_text, $alpha .
'showAreaBorder=' . $showAreaBorder . ';' .
$areaBorderColor .
$color);
$count = 0;
$step = 10;
$num_vlines = 0;
foreach ($value as $i2 => $v) {
if ($count++ % $step == 0) {
$show_name = '1';
$num_vlines++;
}
else {
$show_name = '0';
}
if ($v != 0) {
$empty = 0;
}
if ($a < 3) {
$a++;
// $chart->addCategory(date('G:i', $i2), //'');
// 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i2) .
// ';showName=' . $show_name);
}
//Add data
$chart->addChartData($v);
}
}
$chart->setChartParams('yAxisName=' . $unit . ';'.'animation=0;numVDivLines=' . $num_vlines .
';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;' .
'lineThickness=0.1;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;' .
'showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
$random_number = uniqid();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
//$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>';
$output .= '<script type="text/javascript">
<!--
function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("' . $homeurl . 'include/graphs/FusionCharts/FCF_'.$graph_type.'.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.addParam("WMode", "Transparent");
myChart.render("' . $div_id . '");
}
pie_' . $chart_id . ' ();
-->
</script>';
return $output;
}
///////////////////////////////
///////////////////////////////
///////////////////////////////
// Returns the number of seconds since the Epoch for a date in the format dd/mm/yyyy
function date_to_epoch ($date) {
$date_array = explode ('/', $date);
return mktime (0, 0, 0, $date_array [1], $date_array [0], $date_array [2]);
}
// Returns the code needed to display the chart
function get_chart_code ($chart, $width, $height, $swf) {
$random_number = rand ();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$output = '<div id="' . $div_id. '"></div>';
$output .= '<script type="text/javascript">
<!--
$(document).ready(function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("' . $swf . '", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.render("' . $div_id . '");
})
-->
</script>';
return $output;
}
// Prints a 3D pie chart
function fs_3d_pie_chart ($data, $names, $width, $height, $background = "FFFFFF") {
if ((sizeof ($data) != sizeof ($names)) OR (sizeof($data) == 0) ){
return;
}
// Generate the XML
$chart = new FusionCharts("Pie3D", $width, $height);
$chart->setSWFPath("include/graphs/FusionCharts/");
$params="showNames=1;showValues=0;showPercentageValues=0;baseFontSize=9;bgColor=$background;bgAlpha=100;canvasBgAlpha=100;";
$chart->setChartParams($params);
for ($i = 0; $i < sizeof ($data); $i++) {
$chart->addChartData($data[$i], 'name=' . clean_flash_string($names[$i]));
}
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Pie3D.swf');
}
// Prints a 2D pie chart
function fs_2d_pie_chart ($data, $names, $width, $height, $background = "FFFFFF") {
if ((sizeof ($data) != sizeof ($names)) OR (sizeof($data) == 0) ){
return;
}
// Generate the XML
$chart = new FusionCharts("Pie3D", $width, $height);
$chart->setSWFPath("include/graphs/FusionCharts/");
$params="showNames=1;showValues=0;showPercentageValues=0;baseFontSize=9;bgColor=$background;bgAlpha=100;canvasBgAlpha=100;";
$chart->setChartParams($params);
for ($i = 0; $i < sizeof ($data); $i++) {
$chart->addChartData($data[$i], 'name=' . clean_flash_string($names[$i]));
}
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Pie2D.swf');
}
// Returns a 2D column chart
function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data_columns = false, $yaxisname = '') {
if (sizeof ($data) == 0) {
return;
}
// Generate the XML
$chart = new FusionCharts('Column2D', $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($data))) {
$data2 = array();
$count = 0;
foreach($data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
$chart->addCategory($i, //'');
'hoverText=' . $i .
';showName=' . $show_name);
$c = 0;
$previous = false;
foreach($values as $i2 => $value) {
if ($reduce_data_columns) {
if ($previous !== false) {
if ($previous == $value) continue;
}
}
$data2[$i2][$i] = $value;
$c++;
$previous = $value;
}
}
$data = $data2;
}
else {
$data = array($data);
}
$empty = 0;
$num_vlines = 0;
$count = 0;
foreach ($data as $legend_value => $values) {
foreach($values as $name => $value) {
if (($count++ % $step) == 0) {
$show_name = '1';
$num_vlines++;
} else {
$show_name = '0';
}
if ($value != 0) {
$empty = 0;
}
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=95BB04');
}
}
$chart->setChartParams('yAxisName=' . $yaxisname . ';decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;'
. ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
// Return the code
return get_chart_code ($chart, $width, $height, $homeurl . 'include/graphs/FusionCharts/FCF_Column2D.swf');
}
// Returns a BAR Horizontalchart
function fs_2d_hcolumn_chart ($data, $width, $height) {
if (sizeof ($data) == 0) {
return;
}
// Generate the XML
$chart = new FusionCharts('Bar2D', $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($data))) {
$data2 = array();
$count = 0;
foreach($data as $i =>$values) {
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
$chart->addCategory($i, //'');
'hoverText=' . $i .
';showName=' . $show_name);
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($data);
}
$empty = 0;
$num_vlines = 0;
$count = 0;
foreach ($data as $legend_value => $values) {
foreach($values as $name => $value) {
if (($count++ % $step) == 0) {
$show_name = '1';
$num_vlines++;
} else {
$show_name = '0';
}
if ($value != 0) {
$empty = 0;
}
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name/* . ';color=95BB04'*/);
}
}
$params='showNames=1;showValues=0;showPercentageValues=0;baseFontSize=9;rotateNames=1;chartLeftMargin=0;chartRightMargin=0;chartBottomMargin=0;chartTopMargin=0;showBarShadow=1;showLimits=1';
$chart->setChartParams($params.';numVDivLines='.$num_vlines.($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Bar2D.swf');
}
// Returns a 3D column chart
function fs_3d_column_chart ($data, $width, $height) {
if (sizeof ($data) == 0) {
return;
}
// Generate the XML
$chart = new FusionCharts('Column2D', $width, $height);
$empty = 0;
$num_vlines = 0;
$count = 0;
$step = 3;
foreach ($data as $name => $value) {
if ($count++ % $step == 0) {
$show_name = '1';
$num_vlines++;
} else {
$show_name = '0';
}
if ($value != 0) {
$empty = 0;
}
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=95BB04');
}
$chart->setChartParams('decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;'
. ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Column2D.swf');
}
// Prints a Gantt chart
function fs_gantt_chart ($title, $from, $to, $tasks, $milestones, $width, $height) {
// Generate the XML
$chart = new FusionCharts("Gantt", $width, $height, "1", "0");
$chart->setSWFPath("include/graphs/FusionCharts/");
$chart->setChartParams('dateFormat=dd/mm/yyyy;hoverCapBorderColor=2222ff;hoverCapBgColor=e1f5ff;ganttLineAlpha=80;canvasBorderColor=024455;canvasBorderThickness=0;gridBorderColor=2179b1;gridBorderAlpha=20;ganttWidthPercent=80');
$chart->setGanttProcessesParams('headerText=' . __('Task') . ';fontColor=ffffff;fontSize=9;isBold=1;isAnimated=1;bgColor=2179b1;headerbgColor=2179b1;headerFontColor=ffffff;headerFontSize=12;align=left');
$chart->setGanttTasksParams('');
$start_date = explode ('/', $from);
$start_day = $start_date[0];
$start_month = $start_date[1];
$start_year = $start_date[2];
$end_date = explode ('/', $to);
$end_day = $end_date[0];
$end_month = $end_date[1];
$end_year = $end_date[2];
$time_span = date_to_epoch ($to) - date_to_epoch ($from);
// Years
$chart->addGanttCategorySet ('bgColor=2179b1;fontColor=ff0000');
for ($i = $start_year; $i <= $end_year; $i++) {
if ($i == $start_year) {
$start = sprintf ('%02d/%02d/%04d', $start_day, $start_month, $start_year);
} else {
$start = sprintf ('%02d/%02d/%04d', 1, 1, $i);
}
if ($i == $end_year) {
$end = sprintf ('%02d/%02d/%04d', $end_day, $end_month, $end_year);
} else {
$end = sprintf ('%02d/%02d/%04d', cal_days_in_month (CAL_GREGORIAN, 12, $i), 12, $i);
}
$chart->addGanttCategory ($i, ';start=' . $start . ';end=' . $end . ';align=center;fontColor=ffffff;isBold=1;fontSize=16');
}
// Months
$chart->addGanttCategorySet ('bgColor=ffffff;fontColor=1288dd;fontSize=10');
for ($i = $start_year ; $i <= $end_year; $i++) {
for ($j = 1 ; $j <= 12; $j++) {
if ($i == $start_year && $j < $start_month) {
continue;
} else if ($i == $end_year && $j > $end_month) {
break;
}
if ($i == $start_year && $j == $start_month) {
$start = sprintf ('%02d/%02d/%04d', $start_day, $start_month, $start_year);
} else {
$start = sprintf ('%02d/%02d/%04d', 1, $j, $i);
}
if ($i == $end_year && $j == $end_month) {
$end = sprintf ('%02d/%02d/%04d', $end_day, $end_month, $end_year);
} else {
$end = sprintf ('%02d/%02d/%04d', cal_days_in_month (CAL_GREGORIAN, $j, $i), $j, $i);
}
$chart->addGanttCategory (date('F', mktime(0,0,0,$j,1)), ';start=' . $start . ';end=' . $end . ';align=center;isBold=1');
}
}
// Days
if ($time_span < 2592000) {
$chart->addGanttCategorySet ();
for ($i = $start_year ; $i <= $end_year; $i++) {
for ($j = 1 ; $j <= 12; $j++) {
if ($i == $start_year && $j < $start_month) {
continue;
} else if ($i == $end_year && $j > $end_month) {
break;
}
$num_days = cal_days_in_month (CAL_GREGORIAN, $j, $i);
for ($k = 1 ; $k <= $num_days; $k++) {
if ($i == $start_year && $j == $start_month && $k < $start_day) {
continue;
} else if ($i == $end_year && $j == $end_month && $k > $end_day) {
break;
}
$start = sprintf ('%02d/%02d/%04d', $k, $j, $i);
$end = sprintf ('%02d/%02d/%04d', $k, $j, $i);
$chart->addGanttCategory ($k, ';start=' . $start . ';end=' . $end . ';fontSize=8;isBold=0');
}
}
}
}
// Weeks
else if ($time_span < 10368000) {
$chart->addGanttCategorySet ();
for ($i = $start_year ; $i <= $end_year; $i++) {
for ($j = 1 ; $j <= 12; $j++) {
if ($i == $start_year && $j < $start_month) {
continue;
} else if ($i == $end_year && $j > $end_month) {
break;
}
$num_days = cal_days_in_month (CAL_GREGORIAN, $j, $i);
for ($k = 1, $l = 1; $k <= $num_days; $k += 8, $l++) {
if ($i == $start_year && $j == $start_month && $k + 7 < $start_day) {
continue;
}
if ($i == $end_year && $j == $end_month && $k > $end_day) {
break;
}
if ($i == $start_year && $j == $start_month && $k < $start_day) {
$start = sprintf ('%02d/%02d/%04d', $start_day, $j, $i);
} else {
$start = sprintf ('%02d/%02d/%04d', $k, $j, $i);
}
if ($i == $end_year && $j == $end_month && $k + 7 > $end_day) {
$end = sprintf ('%02d/%02d/%04d', $end_day, $j, $i);
} else if ($k + 7 > $num_days) {
$end = sprintf ('%02d/%02d/%04d', $num_days, $j, $i);
} else {
$end = sprintf ('%02d/%02d/%04d', $k + 7, $j, $i);
}
$chart->addGanttCategory (__('Week') . " $l", ';start=' . $start . ';end=' . $end . ';fontSize=8;isBold=0');
}
}
}
}
// Tasks
foreach ($tasks as $task) {
$chart->addGanttProcess (clean_flash_string($task['name']), 'id=' . $task['id'] . ';link=' . urlencode($task['link']));
$chart->addGanttTask (__('Planned'), 'start=' . $task['start'] . ';end=' . $task['end'] . ';id=' . $task['id'] . ';processId=' . $task['id'] . ';color=4b3cff;height=5;topPadding=10;animation=0');
if ($task['real_start'] !== false && $task['real_end']) {
$chart->addGanttTask (__('Actual'), 'start=' . $task['real_start'] . ';end=' . $task['real_end'] . ';processId=' . $task['id'] . ';color=ff3c4b;alpha=100;topPadding=15;height=5');
}
if ($task['completion'] != 0) {
$task_span = date_to_epoch ($task['end']) - date_to_epoch ($task['start']);
$end = date ('d/m/Y', date_to_epoch ($task['start']) + $task_span * $task['completion'] / 100.0);
$chart->addGanttTask (__('Completion')." (".$task['completion'].")", 'start=' . $task['start'] . ';end=' . $end . ';processId=' . $task['id'] . ';color=32cd32;alpha=100;topPadding=20;height=5');
}
if ($task['parent'] != 0) {
$chart->addGanttConnector ($task['parent'], $task['id'], 'color=2179b1;thickness=2;fromTaskConnectStart=1');
}
}
// Milestones
if ($milestones !== '') {
$chart->addGanttProcess (__('Milestones'), 'id=0');
foreach ($milestones as $milestone) {
$chart->addGanttTask (clean_flash_string($milestone['name']), 'start=' . $milestone['date'] . ';end=' . $milestone['date'] . ';id=ms-' . $milestone['id'] . ';processId=0;color=ffffff;alpha=0;height=60;topPadding=0;animation=0');
$chart->addGanttMilestone ('ms-' . $milestone['id'], 'date=' . $milestone['date'] . ';radius=8;color=efbb07;shape=star;numSides=3;borderThickness=1');
}
}
// Today
$chart->addTrendLine ('start=' . date ('d/m/Y') . ';displayValue='. __('Today') . ';color=666666;isTrendZone=1;alpha=20');
// Return the code
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Gantt.swf');
}
?>

View File

@ -67,7 +67,7 @@ echo '<div style="height:25px">&nbsp;</div>';
echo '<b>'.__('Events generated -by module-').'</b><br />';
echo graph_event_module (290, 120, $id_agente);
echo '<br>';
graph_graphic_agentevents_static ($id_agente, 290, 15, 86400, '');
graph_graphic_agentevents ($id_agente, 290, 15, 86400, '');
echo '</div>';