2012-03-06 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php include/graphs/functions_pchart.php include/graphs/functions_flot.php include/graphs/flot/pandora.flot.js include/graphs/fgraph.php include/pchart_graph.php include/FusionCharts include/pChart include/functions_ui.php images/chart_curve_threshold.png: Clean graphs code and add threshold (warning and critical min) * operation/reporting/reporting_viewer.php include/functions_reporting.php: Improve the top_n merged from 4.0 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5697 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
912f5ff9e3
commit
b42a6743e1
|
@ -1,3 +1,22 @@
|
|||
2012-03-06 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_graph.php
|
||||
include/graphs/functions_pchart.php
|
||||
include/graphs/functions_flot.php
|
||||
include/graphs/flot/pandora.flot.js
|
||||
include/graphs/fgraph.php
|
||||
include/pchart_graph.php
|
||||
include/FusionCharts
|
||||
include/pChart
|
||||
include/functions_ui.php
|
||||
images/chart_curve_threshold.png: Clean graphs code
|
||||
and add threshold (warning and critical min)
|
||||
|
||||
* operation/reporting/reporting_viewer.php
|
||||
include/functions_reporting.php: Improve the top_n
|
||||
merged from 4.0
|
||||
|
||||
|
||||
2012-03-05 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* pandora_console/include/graphs/functions_flot.php: added the function
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 797 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,361 +0,0 @@
|
|||
/**
|
||||
* FusionCharts: Flash Player detection and Chart embedding.
|
||||
* Version 1.2.3F ( 22 November 2008) - Specialized for FusionChartsFREE
|
||||
* Checking Flash Version >=6 and added updateChartXML() for FREE Charts.
|
||||
* Version: 1.2.3 (1st September, 2008) - Added Fix for % and & characters, scaled dimensions, fixes in to properly handling of double quotes and single quotes in setDataXML() function.
|
||||
* Version: 1.2.2 (10th July, 2008) - Added Fix for % scaled dimensions, fixes in setDataXML() and setDataURL() functions
|
||||
* Version: 1.2.1 (21st December, 2007) - Added setting up Transparent/opaque mode: setTransparent() function
|
||||
* Version: 1.2 (1st November, 2007) - Added FORM fixes for IE
|
||||
* Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for 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); }
|
||||
|
||||
w=w.toString().replace(/\%$/,"%25");
|
||||
if(w) { this.setAttribute('width', w); }
|
||||
h=h.toString().replace(/\%$/,"%25");
|
||||
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'));
|
||||
|
||||
if (!chartObj.setDataURL)
|
||||
{
|
||||
__flash__addCallback(chartObj, "setDataURL");
|
||||
}
|
||||
|
||||
chartObj.setDataURL(strDataURL);
|
||||
}
|
||||
},
|
||||
//This function :
|
||||
//fixes the double quoted attributes to single quotes
|
||||
//Encodes all quotes inside attribute values
|
||||
//Encodes % to %25 and & to %26;
|
||||
encodeDataXML: function(strDataXML){
|
||||
|
||||
var regExpReservedCharacters=["\\$","\\+"];
|
||||
var arrDQAtt=strDataXML.match(/=\s*\".*?\"/g);
|
||||
if (arrDQAtt){
|
||||
for(var i=0;i<arrDQAtt.length;i++){
|
||||
var repStr=arrDQAtt[i].replace(/^=\s*\"|\"$/g,"");
|
||||
repStr=repStr.replace(/\'/g,"%26apos;");
|
||||
var strTo=strDataXML.indexOf(arrDQAtt[i]);
|
||||
var repStrr="='"+repStr+"'";
|
||||
var strStart=strDataXML.substring(0,strTo);
|
||||
var strEnd=strDataXML.substring(strTo+arrDQAtt[i].length);
|
||||
var strDataXML=strStart+repStrr+strEnd;
|
||||
}
|
||||
}
|
||||
|
||||
strDataXML=strDataXML.replace(/\"/g,"%26quot;");
|
||||
strDataXML=strDataXML.replace(/%(?![\da-f]{2}|[\da-f]{4})/ig,"%25");
|
||||
strDataXML=strDataXML.replace(/\&/g,"%26");
|
||||
|
||||
return strDataXML;
|
||||
|
||||
},
|
||||
setDataXML: function(strDataXML){
|
||||
//If being set initially
|
||||
if (this.initialDataSet==false){
|
||||
//This method sets the data XML for the chart INITIALLY.
|
||||
this.addVariable('dataXML',this.encodeDataXML(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);
|
||||
}
|
||||
},
|
||||
setTransparent: function(isTransparent){
|
||||
//Sets chart to transparent mode when isTransparent is true (default)
|
||||
//When no parameter is passed, we assume transparent to be true.
|
||||
if(typeof isTransparent=="undefined") {
|
||||
isTransparent=true;
|
||||
}
|
||||
//Set the property
|
||||
if(isTransparent)
|
||||
this.addParam('WMode', 'transparent');
|
||||
else
|
||||
this.addParam('WMode', 'Opaque');
|
||||
},
|
||||
|
||||
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 8 (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 <FORM> compatibility
|
||||
//Check if it's added in Mozilla embed array or if already exits
|
||||
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)
|
||||
{
|
||||
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;
|
|
@ -1,150 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/FusionCharts
|
||||
*/
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -73,6 +73,10 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
"utimestamp < $date",
|
||||
'order' => 'utimestamp ASC'),
|
||||
array ('datos', 'utimestamp'), 'AND', true);
|
||||
|
||||
// Get module warning_min and critical_min
|
||||
$warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id);
|
||||
$critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$agent_module_id);
|
||||
|
||||
if ($data === false) {
|
||||
$data = array ();
|
||||
|
@ -174,7 +178,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
|
||||
if ($data[$j]['datos'] > $interval_max) {
|
||||
$interval_max = $data[$j]['datos'];
|
||||
} else if ($data[$j]['datos'] < $interval_max) {
|
||||
} else if ($data[$j]['datos'] < $interval_min) {
|
||||
$interval_min = $data[$j]['datos'];
|
||||
}
|
||||
$total += $data[$j]['datos'];
|
||||
|
@ -255,9 +259,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
else {
|
||||
//$chart[$timestamp]['utimestamp'] = $timestamp;
|
||||
//$chart[$timestamp]['datos'] = $total;
|
||||
$chart[$timestamp]['max'] = $interval_max;
|
||||
$chart[$timestamp]['sum'] = $total;
|
||||
$chart[$timestamp]['min'] = $interval_min;
|
||||
$chart[$timestamp]['max'] = $interval_max;
|
||||
}
|
||||
$previous_data = $total;
|
||||
// Compressed data
|
||||
|
@ -268,9 +272,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$chart[$timestamp]['sum'] = 0;
|
||||
}
|
||||
else {
|
||||
$chart[$timestamp]['max'] = 0;
|
||||
$chart[$timestamp]['sum'] = 0;
|
||||
$chart[$timestamp]['min'] = 0;
|
||||
$chart[$timestamp]['max'] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -278,9 +282,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$chart[$timestamp]['sum'] = $previous_data;
|
||||
}
|
||||
else {
|
||||
$chart[$timestamp]['max'] = $previous_data;
|
||||
$chart[$timestamp]['sum'] = $previous_data;
|
||||
$chart[$timestamp]['min'] = $previous_data;
|
||||
$chart[$timestamp]['max'] = $previous_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +350,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
///////
|
||||
// Color commented not to restrict serie colors
|
||||
$color = array();
|
||||
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
||||
if($show_events) {
|
||||
$color['event'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
||||
}
|
||||
|
@ -354,12 +357,12 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$color['alert'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
||||
}
|
||||
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
|
||||
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
||||
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
|
||||
$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
|
||||
$color['unit'] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10);
|
||||
|
||||
$legend = array();
|
||||
$legend['sum'] = __('Avg') . ' (' . $avg_value . ')';
|
||||
if($show_events) {
|
||||
$legend['event'] = __('Events');
|
||||
$chart_extra_data['legend_events'] = $legend['event'];
|
||||
|
@ -369,6 +372,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$chart_extra_data['legend_alerts'] = $legend['alert'];
|
||||
}
|
||||
$legend['max'] = __('Max') . ' (' .format_for_graph($max_value) . ')';
|
||||
$legend['sum'] = __('Avg') . ' (' . $avg_value . ')';
|
||||
$legend['min'] = __('Min') . ' (' . format_for_graph($min_value) . ')';
|
||||
$legend['baseline'] = __('Baseline');
|
||||
|
||||
|
@ -383,7 +387,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
|
||||
$long_index, "images/image_problem.opaque.png", "", "", $homeurl,
|
||||
$water_mark,
|
||||
$config['fontpath'], $config['font_size'], $unit, $ttl, $series_type, $chart_extra_data);
|
||||
$config['fontpath'], $config['font_size'], $unit, $ttl, $series_type,
|
||||
$chart_extra_data, $warning_min, $critical_min);
|
||||
}
|
||||
|
||||
function graph_get_formatted_date($timestamp, $format1, $format2) {
|
||||
|
@ -1714,80 +1719,6 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
|
|||
}
|
||||
}
|
||||
|
||||
// Clean FLASH string strips non-valid characters for flashchart
|
||||
function clean_flash_string ($string) {
|
||||
$string = html_entity_decode ($string, ENT_QUOTES, "UTF-8");
|
||||
$string = str_replace('&', '', $string);
|
||||
$string = str_replace(' ', '', $string);
|
||||
$string = str_replace ('"', '', $string);
|
||||
return substr ($string, 0, 20);
|
||||
}
|
||||
|
||||
// Returns a Pandora FMS agent event chart
|
||||
function fs_agent_event_chart ($data, $width, $height, $step = 1) {
|
||||
global $config;
|
||||
|
||||
if (sizeof ($data) == 0) {
|
||||
return fs_error_image ();
|
||||
}
|
||||
|
||||
// Generate the XML
|
||||
$chart = new FusionCharts('Area2D', $width, $height);
|
||||
|
||||
$count = 0;
|
||||
$num_vlines = 0;
|
||||
foreach ($data as $name => $value) {
|
||||
|
||||
if (($step >= 1) && ($count++ % $step == 0)) {
|
||||
$show_name = '1';
|
||||
$num_vlines++;
|
||||
} else {
|
||||
$show_name = '0';
|
||||
}
|
||||
$chart->addChartData(1, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=' . $value);
|
||||
}
|
||||
|
||||
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=0;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
||||
|
||||
// Return the code
|
||||
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Area2D.swf');
|
||||
}
|
||||
|
||||
// Returns a Pandora FMS agent event chart
|
||||
function fs_module_event_chart ($data, $width, $height, $step = 1, $homedir = '', $rotate_names = 0) {
|
||||
global $config;
|
||||
|
||||
if (sizeof ($data) == 0) {
|
||||
return fs_error_image ();
|
||||
}
|
||||
|
||||
// Generate the XML
|
||||
$chart = new FusionCharts('Area2D', $width, 160);
|
||||
|
||||
$count = 0;
|
||||
$num_vlines = 0;
|
||||
foreach ($data as $name => $value) {
|
||||
|
||||
if (($step >= 1) && ($count++ % $step == 0)) {
|
||||
$show_name = '1';
|
||||
$num_vlines++;
|
||||
} else {
|
||||
$show_name = '0';
|
||||
}
|
||||
$chart->addChartData(1, 'name=' . $name . ';showName=' . $show_name . ';color=' . $value);
|
||||
}
|
||||
|
||||
if ($rotate_names == 0){
|
||||
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=0;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
||||
}elseif ($rotate_names == 1){
|
||||
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=1;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
||||
}
|
||||
|
||||
// Return the code
|
||||
return get_chart_code ($chart, $width, 105, $homedir . 'include/FusionCharts/FCF_Area2D.swf');
|
||||
}
|
||||
|
||||
|
||||
// Prints an error image
|
||||
function fs_error_image () {
|
||||
global $config;
|
||||
|
|
|
@ -3506,6 +3506,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
$top_n_value = $content['top_n_value'];
|
||||
$show_graph = $content['show_graph'];
|
||||
|
||||
$table->style[0] = 'padding: 8px 5px 8px 5px;';
|
||||
$table->style[1] = 'text-align: right';
|
||||
$data = array ();
|
||||
$data[0] = $sizh.__('Top').' '.$content['top_n_value'].$sizhfin;
|
||||
|
@ -3524,6 +3525,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
where id_report_content = %d", $content['id_rc']);
|
||||
|
||||
$tops = db_process_sql ($sql);
|
||||
|
||||
if ($tops === false) {
|
||||
$data = array ();
|
||||
$table->colspan[2][0] = 3;
|
||||
|
@ -3531,7 +3533,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
array_push ($table->data, $data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($show_graph == 0 || $show_graph == 1) {
|
||||
$table1->width = '99%';
|
||||
$table1->data = array ();
|
||||
|
@ -3539,10 +3541,11 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
$table1->head[0] = __('Agent');
|
||||
$table1->head[1] = __('Module');
|
||||
$table1->head[2] = __('Value');
|
||||
$table1->style[0] = 'text-align: center';
|
||||
$table1->style[1] = 'text-align: center';
|
||||
$table1->style[2] = 'text-align: center';
|
||||
$table1->style[0] = 'text-align: left';
|
||||
$table1->style[1] = 'text-align: left';
|
||||
$table1->style[2] = 'text-align: left';
|
||||
}
|
||||
|
||||
$data_top = array();
|
||||
foreach ($tops as $key => $row) {
|
||||
|
||||
|
@ -3555,7 +3558,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ag_name = modules_get_agentmodule_agent_name($row ['id_agent_module']);
|
||||
$mod_name = modules_get_agentmodule_name ($row ['id_agent_module']);
|
||||
|
||||
|
@ -3574,6 +3577,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
$value = reporting_get_agentmodule_data_average ($row['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
|
||||
//If the returned value from modules_get_agentmodule_data_max/min/avg is false it won't be stored.
|
||||
if ($value !== false) {
|
||||
$data_top[$key] = $value;
|
||||
|
@ -3587,7 +3591,13 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($data_top)) {
|
||||
$data = array ();
|
||||
$table->colspan[2][0] = 3;
|
||||
$data[0] = __('Insuficient data');
|
||||
array_push ($table->data, $data);
|
||||
break;
|
||||
}
|
||||
switch ($top_n) {
|
||||
//Max
|
||||
case 1:
|
||||
|
@ -3631,6 +3641,9 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
break;
|
||||
}
|
||||
|
||||
// Define truncate size depends the graph width
|
||||
$truncate_size = $sizgraph_w / (4 * ($config['font_size']))-1;
|
||||
|
||||
if ($order_uptodown == 1 || $order_uptodown == 2) {
|
||||
$i = 0;
|
||||
$data_pie_graph = array();
|
||||
|
@ -3638,18 +3651,19 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
foreach ($data_top as $dt) {
|
||||
$item_name = '';
|
||||
$item_name =
|
||||
ui_print_truncate_text($agent_name[$i], 12, false, true, false, "...") .
|
||||
ui_print_truncate_text($agent_name[$i], $truncate_size, false, true, false, "...") .
|
||||
' - ' .
|
||||
ui_print_truncate_text($module_name[$i], 12, false, true, false, "...");
|
||||
ui_print_truncate_text($module_name[$i], $truncate_size, false, true, false, "...");
|
||||
|
||||
$data_hbar[$item_name]['g'] = $dt;
|
||||
$data_pie_graph[$item_name] = $dt;
|
||||
|
||||
if ($show_graph == 0 || $show_graph == 1) {
|
||||
$data = array();
|
||||
$data[0] = printSmallFont($agent_name[$i]);
|
||||
$data[1] = printSmallFont($module_name[$i]);
|
||||
$data[2] = $dt;
|
||||
$data[0] = $agent_name[$i];
|
||||
$data[1] = $module_name[$i];
|
||||
|
||||
$data[2] = round($dt,2);
|
||||
array_push ($table1->data, $data);
|
||||
}
|
||||
$i++;
|
||||
|
@ -3663,9 +3677,9 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
foreach ($agent_name as $an) {
|
||||
$item_name = '';
|
||||
$item_name =
|
||||
ui_print_truncate_text($agent_name[$i], 12, false, true, false, "...") .
|
||||
ui_print_truncate_text($agent_name[$i], $truncate_size, false, true, false, "...") .
|
||||
' - ' .
|
||||
ui_print_truncate_text($module_name[$i], 12, false, true, false, "...");
|
||||
ui_print_truncate_text($module_name[$i], $truncate_size, false, true, false, "...");
|
||||
|
||||
$data_pie_graph[$item_name] = $data_top[$i];
|
||||
$data_hbar[$item_name]['g'] = $data_top[$i];
|
||||
|
@ -3681,13 +3695,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
}
|
||||
}
|
||||
|
||||
unset($data);
|
||||
$table->colspan[2][0] = 3;
|
||||
$table->style[2] = 'text-align:center';
|
||||
if ($show_graph == 0 || $show_graph == 1) {
|
||||
$data = array();
|
||||
$data[0] = html_print_table($table1, true);
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
|
||||
$table->colspan[3][0] = 3;
|
||||
$data = array();
|
||||
if ($show_graph == 1 || $show_graph == 2) {
|
||||
|
@ -3698,9 +3714,10 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
array_push ($table->data, $data);
|
||||
//Display bars graph
|
||||
$table->colspan[4][0] = 3;
|
||||
$table->style[0] .= 'text-align:center';
|
||||
$height = count($data_pie_graph)*20+35;
|
||||
$data = array();
|
||||
$data[0] = hbar_graph(false, $data_hbar, $sizgraph_w, $height, array(), array(), "", "", true, "", $config['homedir'] . "/images/logo_vertical_water.png", '', '', true, 1, true);
|
||||
$data[0] = hbar_graph(false, $data_hbar, $sizgraph_w, $height, array(), array(), "", "", true, "", $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], true, 1, true);
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
@ -3725,13 +3742,23 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
}
|
||||
$avg = $avg / $i;
|
||||
|
||||
$data_resume = array();
|
||||
$data_resume[0] = __('Max Value').': '.$max;
|
||||
array_push ($table->data, $data_resume);
|
||||
$data_resume[0] = __('Min Value').': '.$min;
|
||||
array_push ($table->data, $data_resume);
|
||||
$data_resume[0] = __('Average Value').': '.$avg;
|
||||
array_push ($table->data, $data_resume);
|
||||
unset($table_summary);
|
||||
|
||||
$table_summary->width = '99%';
|
||||
$table_summary->data = array ();
|
||||
$table_summary->head = array ();
|
||||
$table_summary->head[0] = __('Min Value');
|
||||
$table_summary->head[1] = __('Average Value');
|
||||
$table_summary->head[2] = __('Max Value');
|
||||
|
||||
$table_summary->data[0][0] = round($min,2);
|
||||
$table_summary->data[0][1] = round($avg,2);
|
||||
$table_summary->data[0][2] = round($max,2);
|
||||
|
||||
$table->colspan[5][0] = 2;
|
||||
array_push ($table->data, array('<b>'.__('Summary').'</b>'));
|
||||
$table->colspan[6][0] = 2;
|
||||
array_push ($table->data, array(html_print_table($table_summary, true)));
|
||||
}
|
||||
break;
|
||||
case 'exception':
|
||||
|
@ -3973,6 +4000,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
}
|
||||
|
||||
$table->colspan[3][0] = 3;
|
||||
$table->style[0] .= 'text-align: center';
|
||||
$data = array();
|
||||
if ($show_graph == 1 || $show_graph == 2) {
|
||||
$data[0] = pie3d_graph($config['flash_charts'], $data_pie_graph,
|
||||
|
|
|
@ -106,7 +106,7 @@ function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = tru
|
|||
* @param boolean $return Flag to return as string or not.
|
||||
*/
|
||||
function printSmallFont ($string, $return = true) {
|
||||
$str = str_replace (' ', ' ', $string);
|
||||
$str = io_safe_output($string);
|
||||
$length = strlen($str);
|
||||
if ($length >= 30) {
|
||||
$size = 0.7;
|
||||
|
|
|
@ -187,7 +187,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
|
|||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
if($flash_chart) {
|
||||
echo flot_vcolumn_chart ($chart_data, $width, $height, $water_mark_url, $homedir, $reduce_data_columns);
|
||||
return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir, $reduce_data_columns);
|
||||
}
|
||||
else {
|
||||
$graph = array();
|
||||
|
@ -221,7 +221,7 @@ function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) {
|
|||
function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
||||
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="",
|
||||
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $series_type = array(),
|
||||
$chart_extra_data = array()) {
|
||||
$chart_extra_data = array(), $yellow_threshold, $red_threshold) {
|
||||
|
||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
|
@ -235,7 +235,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
|||
}
|
||||
|
||||
if($flash_chart) {
|
||||
return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data);
|
||||
return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data, $yellow_threshold, $red_threshold);
|
||||
}
|
||||
else {
|
||||
$graph = array();
|
||||
|
|
|
@ -14,7 +14,7 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||
|
||||
var label_conf;
|
||||
|
||||
if(width < 300) {
|
||||
if(width < 400) {
|
||||
label_conf = {
|
||||
show: false
|
||||
};
|
||||
|
@ -82,14 +82,7 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||
}
|
||||
|
||||
if(water_mark) {
|
||||
// Set the watermark position
|
||||
$('#watermark_image_'+graph_id)[0].onload = function() {
|
||||
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
|
||||
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
|
||||
$('#watermark_'+graph_id).css('left',canvaslimit_right-parseInt(this.width));
|
||||
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
|
||||
$('#watermark_'+graph_id).show();
|
||||
}
|
||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,24 +205,30 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
});
|
||||
|
||||
if(water_mark) {
|
||||
// Adjust the menu image on top of the plot
|
||||
$('#watermark_image_'+graph_id)[0].onload = function() {
|
||||
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
|
||||
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
|
||||
$('#watermark_'+graph_id).css('left',canvaslimit_right);
|
||||
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
|
||||
$('#watermark_'+graph_id).show();
|
||||
}
|
||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||
}
|
||||
}
|
||||
|
||||
function pandoraFlotVBars(graph_id, values, labels, water_mark, maxvalue, water_mark, separator, separator2) {
|
||||
function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, water_mark, maxvalue, water_mark, separator, separator2) {
|
||||
|
||||
values = values.split(separator2);
|
||||
legend = legend.split(separator);
|
||||
labels_long = labels_long.split(separator);
|
||||
colors = colors.split(separator);
|
||||
|
||||
var datas = new Array();
|
||||
|
||||
for(i=0;i<values.length;i++) {
|
||||
var serie = values[i].split(separator);
|
||||
|
||||
var serie_color;
|
||||
if(colors[i] != '') {
|
||||
serie_color = colors[i];
|
||||
}
|
||||
else {
|
||||
serie_color = null;
|
||||
}
|
||||
|
||||
var aux = new Array();
|
||||
$.each(serie,function(i,v) {
|
||||
aux.push([i, v]);
|
||||
|
@ -237,6 +236,7 @@ function pandoraFlotVBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
|
||||
datas.push({
|
||||
data: aux,
|
||||
color: serie_color,
|
||||
bars: { show: true, horizontal: false, fillColor: { colors: [ { opacity: 0.7 }, { opacity: 1 } ] }, lineWidth:1, steps:false }
|
||||
});
|
||||
}
|
||||
|
@ -249,9 +249,11 @@ function pandoraFlotVBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
series: {
|
||||
shadowSize: 0.1
|
||||
},
|
||||
|
||||
crosshair: { mode: 'xy' },
|
||||
selection: { mode: 'x', color: '#777' },
|
||||
grid: {
|
||||
hoverable: true,
|
||||
clickable: true,
|
||||
borderWidth:1,
|
||||
borderColor: '#666',
|
||||
tickColor: '#eee'
|
||||
|
@ -342,14 +344,7 @@ function pandoraFlotVBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
//~ });
|
||||
|
||||
if(water_mark) {
|
||||
// Adjust the menu image on top of the plot
|
||||
$('#watermark_image_'+graph_id)[0].onload = function() {
|
||||
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
|
||||
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
|
||||
$('#watermark_'+graph_id).css('left',canvaslimit_right);
|
||||
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
|
||||
$('#watermark_'+graph_id).show();
|
||||
}
|
||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,10 +413,11 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||
}
|
||||
}
|
||||
|
||||
function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors, type, serie_types, water_mark, width, max_x, homeurl, unit, font_size, menu, events, event_ids, legend_events, alerts, alert_ids, legend_alerts, separator, separator2) {
|
||||
|
||||
var threshold = false;
|
||||
|
||||
function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors, type, serie_types, water_mark, width, max_x, homeurl, unit, font_size, menu, events, event_ids, legend_events, alerts, alert_ids, legend_alerts, yellow_threshold, red_threshold, separator, separator2) {
|
||||
|
||||
var threshold = true;
|
||||
var thresholded = false;
|
||||
|
||||
values = values.split(separator2);
|
||||
serie_types = serie_types.split(separator);
|
||||
labels_long = labels_long.split(separator);
|
||||
|
@ -460,14 +456,12 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
stacked = 'stack';
|
||||
filled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
var datas = new Array();
|
||||
|
||||
vwarning_min = 60;
|
||||
vwarning_max = 70;
|
||||
vcritical_min = 70;
|
||||
vcritical_max = -1;
|
||||
var data_base = new Array();
|
||||
|
||||
// Prepared to turn series with a checkbox
|
||||
// var showed = new Array();
|
||||
|
||||
for(i=0;i<values.length;i++) {
|
||||
var serie = values[i].split(separator);
|
||||
|
@ -477,8 +471,8 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
$.each(serie,function(i,v) {
|
||||
aux.push([i, v]);
|
||||
if(threshold) {
|
||||
critical_min.push([i,vcritical_min]);
|
||||
warning_min.push([i,vwarning_min]);
|
||||
critical_min.push([i,red_threshold]);
|
||||
warning_min.push([i,yellow_threshold]);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -510,7 +504,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
var critical = '#f00';
|
||||
|
||||
// setup background areas
|
||||
vnormal_max = vwarning_min - 1;
|
||||
//vnormal_max = vwarning_min - 1;
|
||||
|
||||
var markings = null;
|
||||
|
||||
|
@ -521,44 +515,44 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
//~ { color: criticalw, yaxis: { from: vcritical_min } },
|
||||
//~ { color: criticalw, yaxis: { to: -1 } }
|
||||
//~ ];
|
||||
|
||||
if(threshold) {
|
||||
// Warning and critical treshold
|
||||
datas.push({
|
||||
id: 'critical_min',
|
||||
data: critical_min,
|
||||
label: null,
|
||||
color: critical,
|
||||
lines: { show: true, fill: false, lineWidth:3},
|
||||
});
|
||||
datas.push({
|
||||
id: 'warning_min',
|
||||
data: warning_min,
|
||||
label: null,
|
||||
color: warning,
|
||||
lines: { show: true, fill: false, lineWidth:3},
|
||||
});
|
||||
}
|
||||
|
||||
// Data
|
||||
datas.push({
|
||||
data_base.push({
|
||||
id: 'serie_'+i,
|
||||
data: aux,
|
||||
label: legend[i],
|
||||
color: serie_color,
|
||||
//threshold: [{ below: 80, color: "rgb(200, 20, 30)" } , { below: 65, color: "rgb(30, 200, 30)" }, { below: 50, color: "rgb(30, 200, 30)" }],
|
||||
lines: { show: line_show, fill: filled, fillColor: { colors: [ { opacity: 1 }, { opacity: 0.7 } ]}, lineWidth:1, steps:false },
|
||||
lines: { show: line_show, fill: filled, fillColor: { colors: [ { opacity: 1 }, { opacity: 1 } ]}, lineWidth:1, steps:false },
|
||||
points: { show: points_show }
|
||||
});
|
||||
|
||||
|
||||
//~ datas.push({
|
||||
//~ id: 'normal_min',
|
||||
//~ data: normal_min,
|
||||
//~ label: null,
|
||||
//~ color: normal,
|
||||
//~ lines: { show: true, fill: filled, fillColor: { colors: [ { opacity: 0.4 }, { opacity: 0.4 } ]}, lineWidth:0},
|
||||
//~ });
|
||||
// Prepared to turn series with a checkbox
|
||||
// showed[i] = true;
|
||||
}
|
||||
|
||||
var threshold_data = new Array();
|
||||
|
||||
if(threshold) {
|
||||
// Warning and critical treshold
|
||||
threshold_data.push({
|
||||
id: 'critical_min',
|
||||
data: critical_min,
|
||||
label: null,
|
||||
color: critical,
|
||||
lines: { show: true, fill: false, lineWidth:3},
|
||||
});
|
||||
threshold_data.push({
|
||||
id: 'warning_min',
|
||||
data: warning_min,
|
||||
label: null,
|
||||
color: warning,
|
||||
lines: { show: true, fill: false, lineWidth:3},
|
||||
});
|
||||
}
|
||||
|
||||
// The first execution, the graph data is the base data
|
||||
datas = data_base;
|
||||
|
||||
// minTickSize
|
||||
var mts = 130;
|
||||
|
@ -570,7 +564,6 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
},
|
||||
crosshair: { mode: 'xy' },
|
||||
selection: { mode: 'x', color: '#777' },
|
||||
|
||||
grid: {
|
||||
hoverable: true,
|
||||
clickable: true,
|
||||
|
@ -603,9 +596,10 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
labelFormatter: lFormatter
|
||||
}
|
||||
};
|
||||
var stack = 0, bars = true, lines = false, steps = false;
|
||||
|
||||
var plot = $.plot($('#'+graph_id), datas, options );
|
||||
var stack = 0, bars = true, lines = false, steps = false;
|
||||
|
||||
var plot = $.plot($('#'+graph_id), datas, options);
|
||||
|
||||
// Adjust the overview plot to the width and position of the main plot
|
||||
yAxisWidth = $('#'+graph_id+' .yAxis .tickLabel').css('width');
|
||||
|
@ -692,7 +686,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
var j, dataset = currentPlot.getData();
|
||||
|
||||
var i = 0;
|
||||
for (k = 0; k < dataset.length; ++k) {
|
||||
for (k = 0; k < dataset.length; k++) {
|
||||
|
||||
// k is the real series counter
|
||||
// i is the series counter without thresholds
|
||||
|
@ -799,6 +793,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
break;
|
||||
}
|
||||
|
||||
extra_info = get_event_details(eventsz[item.dataIndex]);
|
||||
if(extra_show) {
|
||||
$('#extra_'+graph_id).html(extra_info);
|
||||
$('#extra_'+graph_id).css('display','');
|
||||
|
@ -806,6 +801,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
plot.highlight(item.series, item.datapoint);
|
||||
}
|
||||
else {
|
||||
$('#extra_'+graph_id).html('');
|
||||
$('#extra_'+graph_id).css('display','none');
|
||||
}
|
||||
});
|
||||
|
@ -845,18 +841,51 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
return '<div style=font-size:'+font_size+'pt>'+v+' '+unit+'</div>';
|
||||
}
|
||||
|
||||
function lFormatter(v, axis) {
|
||||
function lFormatter(v, item) {
|
||||
return '<div style=color:#000;font-size:'+font_size+'pt>'+v+'</div>';
|
||||
// Prepared to turn series with a checkbox
|
||||
//return '<div style=color:#000;font-size:'+font_size+'pt><input type="checkbox" id="' + graph_id + '_' + item.id +'" checked="checked" class="check_serie_'+graph_id+'">'+v+'</div>';
|
||||
}
|
||||
|
||||
// Prepared to turn series with a checkbox
|
||||
//~ $('.check_serie_'+graph_id).click(function() {
|
||||
//~ // Format of the id is graph_3905jf93f03_serie_id
|
||||
//~ id_clicked = this.id.split('_')[3];
|
||||
//~ // Update the serie clicked
|
||||
//~ showed[id_clicked] = this.checked;
|
||||
//~ });
|
||||
|
||||
if(menu) {
|
||||
$('#menu_overview_'+graph_id).click(function() {
|
||||
$('#overview_'+graph_id).toggle();
|
||||
});
|
||||
|
||||
$('#menu_threshold_'+graph_id).click(function() {
|
||||
datas = new Array();
|
||||
|
||||
if(thresholded) {
|
||||
thresholded = false;
|
||||
}
|
||||
else {
|
||||
$.each(threshold_data, function() {
|
||||
datas.push(this);
|
||||
});
|
||||
thresholded = true;
|
||||
}
|
||||
|
||||
$.each(data_base, function() {
|
||||
// Prepared to turning series
|
||||
//if(showed[this.id.split('_')[1]]) {
|
||||
datas.push(this);
|
||||
//}
|
||||
});
|
||||
|
||||
plot = $.plot($('#'+graph_id), datas, options);
|
||||
});
|
||||
|
||||
$('#menu_cancelzoom_'+graph_id).click(function() {
|
||||
// cancel the zooming
|
||||
plot = $.plot($('#'+graph_id), datas,
|
||||
plot = $.plot($('#'+graph_id), data_base,
|
||||
$.extend(true, {}, options, {
|
||||
xaxis: { min: 0, max: max_x },
|
||||
legend: { show: false }
|
||||
|
@ -868,27 +897,43 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
// Adjust the menu image on top of the plot
|
||||
$('#menu_overview_'+graph_id)[0].onload = function() {
|
||||
var canvaslimit_right = parseInt(plot.offset().left + plot.width() - 20);
|
||||
var menu_width = $('#menu_'+graph_id).css('width').split('px')[0];
|
||||
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
|
||||
var canvaslimit_top = parseInt(plot.offset().top - 8);
|
||||
var n_options = parseInt($('#menu_'+graph_id).children().length);
|
||||
$('#menu_'+graph_id).css('left',canvaslimit_right-parseInt(this.width)*n_options);
|
||||
|
||||
$('#menu_'+graph_id).css('left',canvaslimit_right-menu_width-20);
|
||||
$('#menu_'+graph_id).css('top',canvaslimit_top-parseInt(this.height));
|
||||
$('#menu_'+graph_id).show();
|
||||
}
|
||||
}
|
||||
|
||||
if(water_mark) {
|
||||
// Adjust the menu image on top of the plot
|
||||
$('#watermark_image_'+graph_id)[0].onload = function() {
|
||||
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
|
||||
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
|
||||
$('#watermark_'+graph_id).css('left',canvaslimit_right);
|
||||
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
|
||||
$('#watermark_'+graph_id).show();
|
||||
}
|
||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||
}
|
||||
}
|
||||
|
||||
function set_watermark(graph_id, plot, watermark_src) {
|
||||
var img = new Image();
|
||||
img.src = watermark_src;
|
||||
var context = plot.getCanvas().getContext('2d');
|
||||
|
||||
// Once it's loaded draw the image on the canvas.
|
||||
img.addEventListener('load', function () {
|
||||
//~ // Now resize the image: x, y, w, h.
|
||||
|
||||
var down_ticks_height = 0;
|
||||
if($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
|
||||
down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0];
|
||||
}
|
||||
var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width;
|
||||
var top_pos = parseInt(context.canvas.height - down_ticks_height - 20) - $('#watermark_image_'+graph_id)[0].height;
|
||||
|
||||
context.drawImage(this, left_pos, top_pos);
|
||||
|
||||
}, false);
|
||||
}
|
||||
|
||||
function get_event_details (event_ids) {
|
||||
var inputs = [];
|
||||
var table;
|
||||
|
|
|
@ -77,39 +77,39 @@ function include_javascript_dependencies_flot_graph($return = false) {
|
|||
///////////////////////////////
|
||||
////////// AREA GRAPHS ////////
|
||||
///////////////////////////////
|
||||
function flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array()) {
|
||||
function flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = '', $red_threshold = '') {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_stacked', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold);
|
||||
}
|
||||
|
||||
function flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = '', $red_threshold = '') {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_stacked', $water_mark, $serie_types, $chart_extra_data);
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold);
|
||||
}
|
||||
|
||||
function flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array()) {
|
||||
function flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = '', $red_threshold = '') {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_simple', $water_mark, $serie_types, $chart_extra_data);
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_stacked', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold);
|
||||
}
|
||||
|
||||
function flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array()) {
|
||||
function flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = '', $red_threshold = '') {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_stacked', $water_mark, $serie_types, $chart_extra_data);
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold);
|
||||
}
|
||||
|
||||
function flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array()) {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_simple', $water_mark, $serie_types, $chart_extra_data);
|
||||
}
|
||||
|
||||
function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $type, $water_mark, $serie_types, $chart_extra_data) {
|
||||
function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $type, $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold) {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
@ -139,13 +139,16 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||
$separator2 = ':,:,,,:,:';
|
||||
|
||||
// Transform data from our format to library format
|
||||
$legend2 = array();
|
||||
$labels = array();
|
||||
$a = array();
|
||||
$vars = array();
|
||||
$serie_types2 = array();
|
||||
|
||||
$colors = array();
|
||||
foreach($legend as $serie_key => $serie) {
|
||||
$index = array_keys(reset($chart_data));
|
||||
|
||||
foreach($index as $serie_key) {
|
||||
if(isset($color[$serie_key])) {
|
||||
$colors[] = $color[$serie_key]['color'];
|
||||
}
|
||||
|
@ -172,7 +175,14 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||
}
|
||||
else {
|
||||
$data[$jsvar][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($legend[$key])) {
|
||||
$legend2[$jsvar] = 'null';
|
||||
}
|
||||
else {
|
||||
$legend2[$jsvar] = $legend[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,9 +208,24 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||
$max_x--;
|
||||
|
||||
if($menu) {
|
||||
$return .= "<div id='menu_$graph_id' style='display:none; text-align:center; width:38px; position:absolute; border: solid 1px #666; border-bottom: 0px; padding: 4px 4px 0px 4px'>
|
||||
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>
|
||||
<a href='javascript:'><img id='menu_overview_$graph_id' src='".$homeurl."images/chart_curve_overview.png' alt='".__('Overview graph')."' title='".__('Overview graph')."'></a>
|
||||
$threshold = false;
|
||||
if($yellow_threshold != '' && $red_threshold != '') {
|
||||
$threshold = true;
|
||||
}
|
||||
|
||||
$nbuttons = 2;
|
||||
|
||||
if($threshold) {
|
||||
$nbuttons++;
|
||||
}
|
||||
|
||||
$menu_width = 18 * $nbuttons + 8;
|
||||
$return .= "<div id='menu_$graph_id' style='display:none; text-align:center; width:".$menu_width."px; position:absolute; border: solid 1px #666; border-bottom: 0px; padding: 4px 4px 0px 4px'>
|
||||
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
|
||||
if($threshold) {
|
||||
$return .= "<a href='javascript:'><img id='menu_threshold_$graph_id' src='".$homeurl."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
|
||||
}
|
||||
$return .= "<a href='javascript:'><img id='menu_overview_$graph_id' src='".$homeurl."images/chart_curve_overview.png' alt='".__('Overview graph')."' title='".__('Overview graph')."'></a>
|
||||
</div>";
|
||||
}
|
||||
$extra_height = $height - 50;
|
||||
|
@ -244,14 +269,14 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||
$alert_ids = implode($separator,$alert_ids);
|
||||
$labels = implode($separator,$labels);
|
||||
$labels_long = implode($separator,$long_index);
|
||||
$legend = io_safe_output(implode($separator,$legend));
|
||||
$legend = io_safe_output(implode($separator,$legend2));
|
||||
$serie_types = implode($separator, $serie_types2);
|
||||
$colors = implode($separator, $colors);
|
||||
|
||||
// Javascript code
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= "//<![CDATA[\n";
|
||||
$return .= "pandoraFlotArea('$graph_id', '$values', '$labels', '$labels_long', '$legend', '$colors', '$type', '$serie_types', $watermark, $width, $max_x, '".$config['homeurl']."', '$unit', $font_size, $menu, '$events', '$event_ids', '$legend_events', '$alerts', '$alert_ids', '$legend_alerts', '$separator', '$separator2');";
|
||||
$return .= "pandoraFlotArea('$graph_id', '$values', '$labels', '$labels_long', '$legend', '$colors', '$type', '$serie_types', $watermark, $width, $max_x, '".$config['homeurl']."', '$unit', $font_size, $menu, '$events', '$event_ids', '$legend_events', '$alerts', '$alert_ids', '$legend_alerts', '$yellow_threshold', '$red_threshold', '$separator', '$separator2');";
|
||||
$return .= "\n//]]>";
|
||||
$return .= "</script>";
|
||||
|
||||
|
@ -394,7 +419,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark) {
|
|||
}
|
||||
|
||||
// Returns a 3D column chart
|
||||
function flot_vcolumn_chart ($graph_data, $width, $height, $water_mark, $homedir, $reduce_data_columns) {
|
||||
function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $reduce_data_columns) {
|
||||
global $config;
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
@ -418,6 +443,18 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $water_mark, $homedir
|
|||
$watermark = 'false';
|
||||
}
|
||||
|
||||
$colors = array();
|
||||
$index = array_keys(reset($graph_data));
|
||||
|
||||
foreach($index as $serie_key) {
|
||||
if(isset($color[$serie_key])) {
|
||||
$colors[] = $color[$serie_key]['color'];
|
||||
}
|
||||
else {
|
||||
$colors[] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Set a weird separator to serialize and unserialize passing data from php to javascript
|
||||
$separator = ';;::;;';
|
||||
$separator2 = ':,:,,,:,:';
|
||||
|
@ -459,7 +496,8 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $water_mark, $homedir
|
|||
|
||||
// Store serialized data to use it from javascript
|
||||
$labels = implode($separator,$labels);
|
||||
|
||||
$colors = implode($separator, $colors);
|
||||
|
||||
// Store data series in javascript format
|
||||
$jsvars = '';
|
||||
$jsseries = array();
|
||||
|
@ -475,11 +513,11 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $water_mark, $homedir
|
|||
$values = implode($separator2, $values2);
|
||||
|
||||
$jsseries = implode(',', $jsseries);
|
||||
|
||||
|
||||
// Javascript code
|
||||
$return .= "<script type='text/javascript'>";
|
||||
|
||||
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', false, $max, '$water_mark', '$separator', '$separator2')";
|
||||
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2')";
|
||||
|
||||
$return .= "</script>";
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
|
|||
$PieChart->draw2DPie($width/4,$height/2,array("DataGapAngle"=>0,"DataGapRadius"=>0, "Border"=>FALSE, "BorderR"=>200, "BorderG"=>200, "BorderB"=>200, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
|
||||
break;
|
||||
case "pie3d":
|
||||
$PieChart->draw3DPie($width/4, $height/2,array("DataGapAngle"=>10,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
|
||||
$PieChart->draw3DPie($width/4, $height/2,array("DataGapAngle"=>5,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -549,8 +549,8 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
|
|||
case "hbar":
|
||||
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,
|
||||
"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "Pos"=>SCALE_POS_TOPBOTTOM,
|
||||
"LabelValuesRotation" => 60);
|
||||
$margin_left = 5 * $max_chars;
|
||||
"LabelValuesRotation" => 30);
|
||||
$margin_left = $font_size * $max_chars;
|
||||
$margin_top = 40;
|
||||
$margin_bottom = 10;
|
||||
break;
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
pCache - Faster renderding using data cache
|
||||
Copyright (C) 2008 Jean-Damien POGOLOTTI
|
||||
Version 1.1.2 last updated on 06/17/08
|
||||
|
||||
|
||||
http://pchart.sourceforge.net
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 1,2,3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class initialisation :
|
||||
pCache($CacheFolder="Cache/")
|
||||
Cache management :
|
||||
IsInCache($Data)
|
||||
GetFromCache($ID,$Data)
|
||||
WriteToCache($ID,$Data,$Picture)
|
||||
DeleteFromCache($ID,$Data)
|
||||
ClearCache()
|
||||
Inner functions :
|
||||
GetHash($ID,$Data)
|
||||
*/
|
||||
|
||||
/* pCache class definition */
|
||||
class pCache
|
||||
{
|
||||
var $HashKey = "";
|
||||
var $CacheFolder = "Cache/";
|
||||
|
||||
/* Create the pCache object */
|
||||
function pCache($CacheFolder="Cache/")
|
||||
{
|
||||
$this->CacheFolder = $CacheFolder;
|
||||
}
|
||||
|
||||
/* This function is clearing the cache folder */
|
||||
function ClearCache()
|
||||
{
|
||||
if ($handle = opendir($this->CacheFolder))
|
||||
{
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
if ( $file != "." && $file != ".." )
|
||||
unlink($this->CacheFolder.$file);
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
|
||||
/* This function is checking if we have an offline version of this chart */
|
||||
function IsInCache($ID,$Data,$Hash="")
|
||||
{
|
||||
if ( $Hash == "" )
|
||||
$Hash = $this->GetHash($ID,$Data);
|
||||
|
||||
if ( file_exists($this->CacheFolder.$Hash) )
|
||||
return(TRUE);
|
||||
else
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* This function is making a copy of drawn chart in the cache folder */
|
||||
function WriteToCache($ID,$Data,$Picture)
|
||||
{
|
||||
$Hash = $this->GetHash($ID,$Data);
|
||||
$FileName = $this->CacheFolder.$Hash;
|
||||
|
||||
imagepng($Picture->Picture,$FileName);
|
||||
}
|
||||
|
||||
/* This function is removing any cached copy of this chart */
|
||||
function DeleteFromCache($ID,$Data)
|
||||
{
|
||||
$Hash = $this->GetHash($ID,$Data);
|
||||
$FileName = $this->CacheFolder.$Hash;
|
||||
|
||||
if ( file_exists($FileName ) )
|
||||
unlink($FileName);
|
||||
}
|
||||
|
||||
/* This function is retrieving the cached picture if applicable */
|
||||
function GetFromCache($ID,$Data)
|
||||
{
|
||||
$Hash = $this->GetHash($ID,$Data);
|
||||
if ( $this->IsInCache("","",$Hash ) )
|
||||
{
|
||||
$FileName = $this->CacheFolder.$Hash;
|
||||
|
||||
header('Content-type: image/png');
|
||||
@readfile($FileName);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/* This function is building the graph unique hash key */
|
||||
function GetHash($ID,$Data)
|
||||
{
|
||||
$mKey = "$ID";
|
||||
foreach($Data as $key => $Values)
|
||||
{
|
||||
$tKey = "";
|
||||
foreach($Values as $Serie => $Value)
|
||||
$tKey = $tKey.$Serie.$Value;
|
||||
$mKey = $mKey.md5($tKey);
|
||||
}
|
||||
return(md5($mKey));
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,266 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
pData - Simplifying data population for pChart
|
||||
Copyright (C) 2008 Jean-Damien POGOLOTTI
|
||||
Version 1.13 last updated on 08/17/08
|
||||
|
||||
http://pchart.sourceforge.net
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 1,2,3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class initialisation :
|
||||
pData()
|
||||
Data populating methods :
|
||||
ImportFromCSV($FileName,$Delimiter=",",$DataColumns=-1,$HasHeader=FALSE,$DataName=-1)
|
||||
AddPoint($Value,$Serie="Serie1",$Description="")
|
||||
Series manipulation methods :
|
||||
AddSerie($SerieName="Serie1")
|
||||
AddAllSeries()
|
||||
RemoveSerie($SerieName="Serie1")
|
||||
SetAbsciseLabelSerie($SerieName = "Name")
|
||||
SetSerieName($Name,$SerieName="Serie1")
|
||||
+ SetSerieSymbol($Name,$Symbol)
|
||||
SetXAxisName($Name="X Axis")
|
||||
SetYAxisName($Name="Y Axis")
|
||||
SetXAxisFormat($Format="number")
|
||||
SetYAxisFormat($Format="number")
|
||||
SetXAxisUnit($Unit="")
|
||||
SetYAxisUnit($Unit="")
|
||||
removeSerieName($SerieName)
|
||||
removeAllSeries()
|
||||
Data retrieval methods :
|
||||
GetData()
|
||||
GetDataDescription()
|
||||
*/
|
||||
|
||||
/* pData class definition */
|
||||
class pData
|
||||
{
|
||||
var $Data;
|
||||
var $DataDescription;
|
||||
|
||||
function pData()
|
||||
{
|
||||
$this->Data = "";
|
||||
$this->DataDescription = "";
|
||||
$this->DataDescription["Position"] = "Name";
|
||||
$this->DataDescription["Format"]["X"] = "number";
|
||||
$this->DataDescription["Format"]["Y"] = "number";
|
||||
$this->DataDescription["Unit"]["X"] = NULL;
|
||||
$this->DataDescription["Unit"]["Y"] = NULL;
|
||||
}
|
||||
|
||||
function ImportFromCSV($FileName,$Delimiter=",",$DataColumns=-1,$HasHeader=FALSE,$DataName=-1)
|
||||
{
|
||||
$handle = @fopen($FileName,"r");
|
||||
if ($handle)
|
||||
{
|
||||
$HeaderParsed = FALSE;
|
||||
while (!feof($handle))
|
||||
{
|
||||
$buffer = fgets($handle, 4096);
|
||||
$buffer = str_replace(chr(10),"",$buffer);
|
||||
$buffer = str_replace(chr(13),"",$buffer);
|
||||
$Values = split($Delimiter,$buffer);
|
||||
|
||||
if ( $buffer != "" )
|
||||
{
|
||||
if ( $HasHeader == TRUE && $HeaderParsed == FALSE )
|
||||
{
|
||||
if ( $DataColumns == -1 )
|
||||
{
|
||||
$ID = 1;
|
||||
foreach($Values as $key => $Value)
|
||||
{ $this->SetSerieName($Value,"Serie".$ID); $ID++; }
|
||||
}
|
||||
else
|
||||
{
|
||||
$SerieName = "";
|
||||
|
||||
foreach($DataColumns as $key => $Value)
|
||||
$this->SetSerieName($Values[$Value],"Serie".$Value);
|
||||
}
|
||||
$HeaderParsed = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $DataColumns == -1 )
|
||||
{
|
||||
$ID = 1;
|
||||
foreach($Values as $key => $Value)
|
||||
{ $this->AddPoint(intval($Value),"Serie".$ID); $ID++; }
|
||||
}
|
||||
else
|
||||
{
|
||||
$SerieName = "";
|
||||
if ( $DataName != -1 )
|
||||
$SerieName = $Values[$DataName];
|
||||
|
||||
foreach($DataColumns as $key => $Value)
|
||||
$this->AddPoint($Values[$Value],"Serie".$Value,$SerieName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
function AddPoint($Value,$Serie="Serie1",$Description="")
|
||||
{
|
||||
if (is_array($Value) && count($Value) == 1)
|
||||
$Value = $Value[0];
|
||||
|
||||
$ID = 0;
|
||||
for($i=0;$i<=count($this->Data);$i++)
|
||||
{
|
||||
if (isset($this->Data[$i]))
|
||||
if(isset($this->Data[$i][$Serie]))
|
||||
{
|
||||
$ID = $i+1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($Value) == 1 )
|
||||
{
|
||||
$this->Data[$ID][$Serie] = $Value;
|
||||
if ( $Description != "" )
|
||||
$this->Data[$ID]["Name"] = $Description;
|
||||
elseif (!isset($this->Data[$ID]["Name"]))
|
||||
$this->Data[$ID]["Name"] = $ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($Value as $key => $Val)
|
||||
{
|
||||
$this->Data[$ID][$Serie] = $Val;
|
||||
if (!isset($this->Data[$ID]["Name"]))
|
||||
$this->Data[$ID]["Name"] = $ID;
|
||||
$ID++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AddSerie($SerieName="Serie1")
|
||||
{
|
||||
if ( !isset($this->DataDescription["Values"]) )
|
||||
{
|
||||
$this->DataDescription["Values"][] = $SerieName;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Found = FALSE;
|
||||
foreach($this->DataDescription["Values"] as $key => $Value )
|
||||
if ( $Value == $SerieName ) { $Found = TRUE; }
|
||||
|
||||
if ( !$Found )
|
||||
$this->DataDescription["Values"][] = $SerieName;
|
||||
}
|
||||
}
|
||||
|
||||
function AddAllSeries()
|
||||
{
|
||||
unset($this->DataDescription["Values"]);
|
||||
|
||||
if ( isset($this->Data[0]) )
|
||||
{
|
||||
foreach($this->Data[0] as $Key => $Value)
|
||||
{
|
||||
if ( $Key != "Name" )
|
||||
$this->DataDescription["Values"][] = $Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function RemoveSerie($SerieName="Serie1")
|
||||
{
|
||||
if ( !isset($this->DataDescription["Values"]) )
|
||||
return(0);
|
||||
|
||||
$Found = FALSE;
|
||||
foreach($this->DataDescription["Values"] as $key => $Value )
|
||||
{
|
||||
if ( $Value == $SerieName )
|
||||
unset($this->DataDescription["Values"][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
function SetAbsciseLabelSerie($SerieName = "Name")
|
||||
{
|
||||
$this->DataDescription["Position"] = $SerieName;
|
||||
}
|
||||
|
||||
function SetSerieName($Name,$SerieName="Serie1")
|
||||
{
|
||||
$this->DataDescription["Description"][$SerieName] = $Name;
|
||||
}
|
||||
|
||||
function SetXAxisName($Name="X Axis")
|
||||
{
|
||||
$this->DataDescription["Axis"]["X"] = $Name;
|
||||
}
|
||||
|
||||
function SetYAxisName($Name="Y Axis")
|
||||
{
|
||||
$this->DataDescription["Axis"]["Y"] = $Name;
|
||||
}
|
||||
|
||||
function SetXAxisFormat($Format="number")
|
||||
{
|
||||
$this->DataDescription["Format"]["X"] = $Format;
|
||||
}
|
||||
|
||||
function SetYAxisFormat($Format="number")
|
||||
{
|
||||
$this->DataDescription["Format"]["Y"] = $Format;
|
||||
}
|
||||
|
||||
function SetXAxisUnit($Unit="")
|
||||
{
|
||||
$this->DataDescription["Unit"]["X"] = $Unit;
|
||||
}
|
||||
|
||||
function SetYAxisUnit($Unit="")
|
||||
{
|
||||
$this->DataDescription["Unit"]["Y"] = $Unit;
|
||||
}
|
||||
|
||||
function SetSerieSymbol($Name,$Symbol)
|
||||
{
|
||||
$this->DataDescription["Symbol"][$Name] = $Symbol;
|
||||
}
|
||||
|
||||
function removeSerieName($SerieName)
|
||||
{
|
||||
if ( isset($this->DataDescription["Description"][$SerieName]) )
|
||||
unset($this->DataDescription["Description"][$SerieName]);
|
||||
}
|
||||
|
||||
function removeAllSeries()
|
||||
{
|
||||
foreach($this->DataDescription["Values"] as $Key => $Value)
|
||||
unset($this->DataDescription["Values"][$Key]);
|
||||
}
|
||||
|
||||
function GetData()
|
||||
{
|
||||
return($this->Data);
|
||||
}
|
||||
|
||||
function GetDataDescription()
|
||||
{
|
||||
return($this->DataDescription);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,657 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for 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 General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Graphs
|
||||
*/
|
||||
|
||||
/**#@+
|
||||
* Include the pChart class.
|
||||
*/
|
||||
require_once ('pChart/pData.class');
|
||||
require_once ('pChart/pChart.class');
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
*/
|
||||
class PchartGraph extends PandoraGraphAbstract {
|
||||
public $palette_path = false;
|
||||
private $graph = NULL;
|
||||
private $dataset = NULL;
|
||||
private $x1;
|
||||
private $x2;
|
||||
private $y1;
|
||||
private $y2;
|
||||
|
||||
public function load_palette ($palette_path) {
|
||||
$this->palette_path = $palette_path;
|
||||
}
|
||||
|
||||
public function pie_graph () {
|
||||
// dataset definition
|
||||
$this->dataset = new pData;
|
||||
$this->dataset->AddPoint ($this->data, "Serie1", $this->legend);
|
||||
$this->dataset->AddPoint ($this->legend, "Serie2");
|
||||
$this->dataset->AddAllSeries ();
|
||||
$this->dataset->SetAbsciseLabelSerie ("Serie2");
|
||||
|
||||
// Initialise the graph
|
||||
$this->graph = new pChart ($this->width, $this->height);
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
if ($this->palette_path) {
|
||||
$this->graph->loadColorPalette ($this->palette_path);
|
||||
}
|
||||
$this->add_background ();
|
||||
|
||||
// Draw the pie chart
|
||||
if ($this->three_dimensions) {
|
||||
$this->graph->drawPieGraph ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
$this->width / 2,
|
||||
$this->height / 2 - 15, $this->zoom,
|
||||
PIE_PERCENTAGE_LABEL, 5, 70, 20, 5);
|
||||
} else {
|
||||
$this->graph->drawFlatPieGraph ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
$this->width / 2,
|
||||
$this->height / 2, $this->zoom,
|
||||
PIE_PERCENTAGE_LABEL, 5);
|
||||
}
|
||||
|
||||
if ($this->show_legend) {
|
||||
$this->graph->drawPieLegend (10, 10, $this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (), 255, 255, 255);
|
||||
}
|
||||
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
public function horizontal_bar_graph () {
|
||||
// dataset definition
|
||||
$this->dataset = new pData;
|
||||
foreach ($this->data as $x => $y) {
|
||||
$this->dataset->AddPoint ($y, "Serie1", $x);
|
||||
}
|
||||
$this->dataset->AddAllSeries ();
|
||||
$this->dataset->SetXAxisFormat ("label");
|
||||
$this->dataset->SetYAxisFormat ($this->yaxis_format);
|
||||
|
||||
// Initialise the graph
|
||||
$this->graph = new pChart ($this->width, $this->height);
|
||||
if ($this->palette_path) {
|
||||
$this->graph->loadColorPalette ($this->palette_path);
|
||||
}
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
$this->add_background ();
|
||||
$this->graph->drawGraphArea (255, 255, 255, true);
|
||||
if ($this->show_grid)
|
||||
$this->graph->drawGrid (4, true, 230, 230, 230, 50);
|
||||
|
||||
// Draw the bar graph
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
$this->graph->setFixedScale (0, max ($this->data));
|
||||
$this->graph->drawOverlayBarGraphH ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (), 50);
|
||||
|
||||
// Finish the graph
|
||||
$this->add_legend ();
|
||||
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
public function single_graph () {
|
||||
// Dataset definition
|
||||
$this->dataset = new pData;
|
||||
$this->graph = new pChart ($this->width, $this->height+2);
|
||||
|
||||
foreach ($this->data as $x => $y) {
|
||||
$this->dataset->AddPoint ($y, "Serie1", $x);
|
||||
}
|
||||
$color = $this->get_rgb_values ($this->graph_color[2]);
|
||||
$this->graph->setColorPalette (0, $color['r'], $color['g'], $color['b']);
|
||||
$this->dataset->AddAllSeries ();
|
||||
if ($this->legend !== false)
|
||||
$this->dataset->SetSerieName ($this->legend[0], "Serie1");
|
||||
|
||||
if ($this->palette_path)
|
||||
$this->graph->loadColorPalette ($this->palette_path);
|
||||
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
|
||||
// White background
|
||||
$this->graph->drawFilledRoundedRectangle(1,1,$this->width,$this->height,0,254,254,254);
|
||||
$this->add_background ();
|
||||
$this->dataset->SetXAxisFormat ($this->xaxis_format);
|
||||
$this->dataset->SetYAxisFormat ($this->yaxis_format);
|
||||
$this->graph->drawGraphArea (254, 254, 254, true);
|
||||
|
||||
if ($this->max_value == 0 || $this->max_value == 1)
|
||||
$this->graph->setFixedScale (0, 1, 1);
|
||||
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis,
|
||||
0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
|
||||
if ($this->show_grid)
|
||||
$this->graph->drawGrid (1, false, 200, 200, 200);
|
||||
if ($this->max_value > 0) {
|
||||
// Draw the graph
|
||||
$this->graph->drawFilledLineGraph ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
50, true);
|
||||
}
|
||||
|
||||
// Finish the graph
|
||||
// $this->add_legend ();
|
||||
$this->add_events ();
|
||||
$this->add_alert_levels ();
|
||||
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
public function sparse_graph ($period, $avg_only, $min_value, $max_value, $unit_name, $baseline = 0) {
|
||||
// Dataset definition
|
||||
$this->dataset = new pData;
|
||||
$this->graph = new pChart ($this->width, $this->height+5);
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
$this->legend = array ();
|
||||
|
||||
if ($avg_only) {
|
||||
foreach ($this->data as $data) {
|
||||
$this->dataset->AddPoint ($data['sum'], "AVG", $data['timestamp_bottom']);
|
||||
}
|
||||
$color = $this->get_rgb_values ($this->graph_color[2]);
|
||||
$this->graph->setColorPalette (0, $color['r'], $color['g'], $color['b']);
|
||||
} else {
|
||||
foreach ($this->data as $data) {
|
||||
$this->dataset->AddPoint ($data['sum'], "AVG", $data['timestamp_bottom']);
|
||||
$this->dataset->AddPoint ($data['min'], "MIN");
|
||||
$this->dataset->AddPoint ($data['max'], "MAX");
|
||||
}
|
||||
$this->legend[1] = __("Min");
|
||||
$this->legend[0] = __("Avg");
|
||||
$this->legend[2] = __("Max");
|
||||
$this->dataset->SetSerieName (__("Min"), "MIN");
|
||||
$this->dataset->SetSerieName (__("Avg"), "AVG");
|
||||
$this->dataset->SetSerieName (__("Max"), "MAX");
|
||||
$this->set_colors ();
|
||||
}
|
||||
|
||||
// Draw baseline
|
||||
if ($baseline == 1) {
|
||||
foreach ($this->data as $data) {
|
||||
$this->dataset->AddPoint ($data['baseline'], "BLINE");
|
||||
}
|
||||
}
|
||||
|
||||
$this->dataset->SetXAxisFormat ('datetime');
|
||||
$this->graph->setDateFormat ("Y");
|
||||
$this->dataset->SetYAxisFormat ('metric');
|
||||
$this->dataset->AddAllSeries ();
|
||||
|
||||
$this->dataset->SetSerieName (__("Avg"), "AVG");
|
||||
$this->legend[0] = __("Avg");
|
||||
|
||||
if ($this->palette_path) {
|
||||
$this->graph->loadColorPalette ($this->palette_path);
|
||||
}
|
||||
|
||||
// White background
|
||||
$this->graph->drawFilledRoundedRectangle(1,1,$this->width,$this->height+2,0,254,254,254);
|
||||
|
||||
// Graph border
|
||||
// Now graph border is in the style image attribute
|
||||
//$this->graph->drawRoundedRectangle(1,1,$this->width-1,$this->height+4,5,230,230,230);
|
||||
|
||||
|
||||
$this->add_background ();
|
||||
// If graph is small remove blank spaces
|
||||
if ($this->width < MIN_WIDTH || $this->height < MIN_HEIGHT)
|
||||
$this->graph->setGraphArea (5,5,$this->width-5,$this->height-5);
|
||||
$this->graph->drawGraphArea (254, 254, 254, false);
|
||||
|
||||
$this->xaxis_interval = ($this->xaxis_interval / 7 >= 1) ? ($this->xaxis_interval / 7) : 10;
|
||||
|
||||
// Remove axis values if graph is small
|
||||
if ($this->width > MIN_WIDTH && $this->height > MIN_HEIGHT) {
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (), SCALE_START0,
|
||||
80, 80, 80, $this->show_axis, 0, 50, false,
|
||||
$this->xaxis_interval);
|
||||
}
|
||||
else {
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (), SCALE_START0,
|
||||
80, 80, 80, false, 0, 50, false,
|
||||
$this->xaxis_interval);
|
||||
}
|
||||
|
||||
/* NOTICE: The final "false" is a Pandora modificaton of pChart to avoid showing vertical lines. */
|
||||
if ($this->show_grid)
|
||||
$this->graph->drawGrid (1, true, 225, 225, 225, 100, false);
|
||||
|
||||
// Draw the graph
|
||||
$this->graph->drawFilledLineGraph ($this->dataset->GetData(), $this->dataset->GetDataDescription(), 50, true);
|
||||
|
||||
// Remove legends if graph is small
|
||||
if ($this->width > MIN_WIDTH && $this->height > MIN_HEIGHT)
|
||||
$this->add_legend ();
|
||||
$this->add_events ("AVG");
|
||||
$this->add_alert_levels ();
|
||||
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
public function vertical_bar_graph () {
|
||||
// dataset definition
|
||||
$this->dataset = new pData;
|
||||
foreach ($this->data as $x => $y) {
|
||||
$this->dataset->AddPoint ($y, "Serie1", $x);
|
||||
}
|
||||
$this->dataset->AddAllSeries ();
|
||||
$this->dataset->SetAbsciseLabelSerie ();
|
||||
$this->dataset->SetXAxisFormat ($this->xaxis_format);
|
||||
$this->dataset->SetYAxisFormat ($this->yaxis_format);
|
||||
|
||||
// Initialise the graph
|
||||
$this->graph = new pChart ($this->width, $this->height);
|
||||
if ($this->palette_path) {
|
||||
$this->graph->loadColorPalette ($this->palette_path);
|
||||
}
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
$this->add_background ();
|
||||
$this->graph->drawGraphArea (255, 255, 255, true);
|
||||
if ($this->show_grid)
|
||||
$this->graph->drawGrid (4, true, 230, 230, 230, 50);
|
||||
|
||||
// Draw the bar graph
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80,
|
||||
$this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawOverlayBarGraph ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
50);
|
||||
$this->add_events ("Serie1");
|
||||
$this->add_alert_levels ();
|
||||
|
||||
// Finish the graph
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
public function combined_graph ($values, $events, $alerts, $unit_name, $max_value, $stacked) {
|
||||
set_time_limit (0);
|
||||
// Dataset definition
|
||||
$this->dataset = new pData;
|
||||
$this->graph = new pChart ($this->width, $this->height+5);
|
||||
|
||||
$graph_items = 0;
|
||||
// $previo stores values from last series to made the stacked graph
|
||||
foreach ($this->data as $i => $data) {
|
||||
$graph_items++;
|
||||
$max = 0;
|
||||
$min = 10000000000000;
|
||||
$avg = 0;
|
||||
$count = 0;
|
||||
foreach ($data as $j => $value) {
|
||||
$count ++;
|
||||
$avg += $value;
|
||||
if ($value > $max )
|
||||
$max = $value;
|
||||
if ($value < $min )
|
||||
$min = $value;
|
||||
|
||||
// New code for stacked. Due pchart doesnt not support stacked
|
||||
// area graph, we "made it", adding to a series the values of the
|
||||
// previous one consecutive sum.
|
||||
if ((($stacked == 1) OR ($stacked==3)) AND ($i >0)){
|
||||
$this->dataset->AddPoint ($value+$previo[$j], $this->legend[$i],
|
||||
$values[$j]['timestamp_bottom']);
|
||||
} else {
|
||||
$this->dataset->AddPoint ($value, $this->legend[$i],
|
||||
$values[$j]['timestamp_bottom']);
|
||||
}
|
||||
if ($i == 0)
|
||||
$previo[$j] = $value;
|
||||
else
|
||||
$previo[$j] = $previo[$j] + $value;
|
||||
|
||||
}
|
||||
if ($count > 0)
|
||||
$avgdata[$i] = $avg / $count;
|
||||
else
|
||||
$avgdata[$i] = 0;
|
||||
$maxdata[$i] = format_for_graph($max);
|
||||
$mindata[$i] = format_for_graph($min);
|
||||
$avgdata[$i] = format_for_graph($avgdata[$i]);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($this->legend as $name) {
|
||||
$legend = $name . " (".__("Max"). ":$maxdata[$i], ".__("Min"). ":$mindata[$i], ". __("Avg"). ": $avgdata[$i])";
|
||||
$this->dataset->setSerieName ($legend, $name);
|
||||
$this->dataset->AddSerie ($name);
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Set different colors for combined graphs because need to be
|
||||
// very different.
|
||||
|
||||
$this->graph_color[1] = "#FF0000"; // Red
|
||||
$this->graph_color[2] = "#00FF00"; // Green
|
||||
$this->graph_color[3] = "#0000FF"; // Blue
|
||||
|
||||
// White background
|
||||
$this->graph->drawFilledRoundedRectangle(1,1,$this->width,$this->height,0,254,254,254);
|
||||
|
||||
$this->set_colors ();
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
$this->dataset->SetXAxisFormat ('datetime');
|
||||
$this->dataset->SetYAxisFormat ('metric');
|
||||
$this->dataset->AddAllSeries ();
|
||||
$this->add_background ();
|
||||
|
||||
|
||||
$legend_offset = $this->height - 21 - ($graph_items*15);
|
||||
|
||||
$this->graph->setGraphArea (35,10,$this->width-10, $legend_offset);
|
||||
$this->graph->drawGraphArea (254, 254, 254, false);
|
||||
|
||||
|
||||
// Fixed missing X-labels (6Ago09)
|
||||
$this->xaxis_interval = ($this->xaxis_interval / 7 >= 1) ? ($this->xaxis_interval / 7) : 10;
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (), SCALE_START0,
|
||||
80, 80, 80, $this->show_axis, 0, 50, false,
|
||||
$this->xaxis_interval);
|
||||
|
||||
$this->graph->drawGrid (1, true, 225, 225, 225, 100, false);
|
||||
|
||||
// Draw the graph
|
||||
if ($stacked == 1) { // Stacked solid
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
||||
$this->dataset->GetDataDescription(), 1, 30, true);
|
||||
}
|
||||
elseif ($stacked == 3) { // Stacked wired
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
||||
$this->dataset->GetDataDescription(), 1, 0, true);
|
||||
|
||||
}
|
||||
else if ($stacked == 2) { // Wired mode
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawLineGraph ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription ());
|
||||
}
|
||||
else { // Non-stacked, area overlapped
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
||||
$this->dataset->GetDataDescription(), 1, 30, true);
|
||||
}
|
||||
|
||||
$this->graph->setFontProperties($this->fontpath,7);
|
||||
$this->graph->drawLegend(15,$legend_offset+29,$this->dataset->GetDataDescription(),92,92,92,50,50,50,45,45,45,0);
|
||||
|
||||
// Legend line separator
|
||||
// $this->graph->drawFilledRoundedRectangle(35, $legend_offset + 30 ,$this->width-35,$legend_offset+30,0,220,220,220);
|
||||
|
||||
$this->add_events ($this->legend[0]);
|
||||
$this->add_alert_levels ();
|
||||
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
public function progress_bar ($value, $color) {
|
||||
set_time_limit (0);
|
||||
// Dataset definition
|
||||
$this->graph = new pChart ($this->width, $this->height);
|
||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
||||
|
||||
// Round corners defined in global setup
|
||||
|
||||
global $config;
|
||||
if ($config["round_corner"] != 0)
|
||||
$radius = ($this->height > 18) ? 8 : 0;
|
||||
else
|
||||
$radius = 0;
|
||||
|
||||
$ratio = (int) $value / 100 * $this->width;
|
||||
|
||||
/* Color stuff */
|
||||
$bgcolor = $this->get_rgb_values ($this->background_color);
|
||||
$r = hexdec (substr ($this->background_color, 1, 2));
|
||||
$g = hexdec (substr ($this->background_color, 3, 2));
|
||||
$b = hexdec (substr ($this->background_color, 5, 2));
|
||||
|
||||
/* Actual percentage */
|
||||
if (! $this->show_title || $value > 0) {
|
||||
$color = $this->get_rgb_values ($color);
|
||||
$this->graph->drawFilledRoundedRectangle (0, 0, $ratio,
|
||||
$this->height, $radius, $color['r'], $color['g'], $color['b']);
|
||||
}
|
||||
|
||||
if ($config["round_corner"]) {
|
||||
/* Under this value, the rounded rectangle is painted great */
|
||||
if ($ratio <= 16) {
|
||||
/* Clean a bit of pixels */
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$this->graph->drawLine (0, $i, 6 - $i, $i, 255, 255, 255);
|
||||
}
|
||||
$end = $this->height - 1;
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$this->graph->drawLine (0, $end - $i, 5 - $i, $end - $i, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ratio <= 60) {
|
||||
if ($this->show_title) {
|
||||
$this->graph->drawTextBox (0, 0, $this->width, $this->height,
|
||||
$this->title, 0, 0, 0, 0, ALIGN_CENTER, false);
|
||||
}
|
||||
} else {
|
||||
if ($this->show_title) {
|
||||
$this->graph->drawTextBox (0, 0, $this->width, $this->height,
|
||||
$this->title, 0, 255, 255, 255, ALIGN_CENTER, false);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->border) {
|
||||
$this->graph->drawRoundedRectangle (0, 0, $this->width - 1,
|
||||
$this->height - 1,
|
||||
$radius, 157, 157, 157);
|
||||
}
|
||||
|
||||
$this->graph->Stroke ();
|
||||
}
|
||||
|
||||
/* Gets an array with each the components of a RGB string */
|
||||
private static function get_rgb_values ($rgb_string) {
|
||||
$color = array ('r' => 0, 'g' => 0, 'b' => 0);
|
||||
$offset = 0;
|
||||
if ($rgb_string[0] == '#')
|
||||
$offset = 1;
|
||||
$color['r'] = hexdec (substr ($rgb_string, $offset, 2));
|
||||
$color['g'] = hexdec (substr ($rgb_string, $offset + 2, 2));
|
||||
$color['b'] = hexdec (substr ($rgb_string, $offset + 4, 2));
|
||||
return $color;
|
||||
}
|
||||
|
||||
private function add_alert_levels () {
|
||||
if ($this->alert_top !== false) {
|
||||
$this->graph->drawTreshold ($this->alert_top, 57,
|
||||
96, 255, true, true, 4,
|
||||
"Alert top");
|
||||
}
|
||||
if ($this->alert_bottom !== false) {
|
||||
$this->graph->drawTreshold ($this->alert_bottom, 7,
|
||||
96, 255, true, true, 4,
|
||||
"Alert bottom");
|
||||
}
|
||||
}
|
||||
|
||||
private function add_events ($serie = "Serie1") {
|
||||
if (! $this->events)
|
||||
return;
|
||||
|
||||
/* Unfortunatelly, the events must be draw manually */
|
||||
|
||||
$first = $this->dataset->Data[0]["Name"];
|
||||
$len = count ($this->dataset->Data) - 1;
|
||||
|
||||
$last = $this->dataset->Data[$len]["Name"];
|
||||
$ylen = $this->y2 - $this->y1;
|
||||
|
||||
foreach ($this->data as $i => $data) {
|
||||
/* Finally, check if there were events */
|
||||
if (! $data['events'])
|
||||
continue;
|
||||
|
||||
if (!isset($this->dataset->Data[$i]))
|
||||
continue;
|
||||
|
||||
$x1 = (int) ($this->x1 + $i * $this->graph->DivisionWidth);
|
||||
$y1 = (int) ($this->y2 - ($this->dataset->Data[$i][$serie] * $this->graph->DivisionRatio));
|
||||
$this->graph->drawFilledCircle ($x1, $y1, 1.5, 255, 0, 0);
|
||||
if ($y1 == $this->y2)
|
||||
/* Lines in the same dot fails */
|
||||
continue;
|
||||
|
||||
$this->graph->drawDottedLine ($x1 - 1, $y1,
|
||||
$x1 - 1, $this->y2,
|
||||
5, 255, 150, 150);
|
||||
}
|
||||
}
|
||||
|
||||
private function add_background () {
|
||||
if ($this->graph == NULL)
|
||||
return;
|
||||
|
||||
$this->graph->setDateFormat ($this->date_format);
|
||||
|
||||
$this->x1 = ($this->width > 300) ? 30 : 35;
|
||||
// $this->y1 = ($this->height > 200) ? 25 : 10;
|
||||
$this->x2 = ($this->width > 300) ? $this->width - 15 : $this->width - 15;
|
||||
$this->y2 = ($this->height > 200) ? $this->height - 25 : $this->height - 25;
|
||||
|
||||
if ($this->max_value > 10000 && $this->show_axis)
|
||||
$this->x1 += 20;
|
||||
|
||||
$this->graph->drawGraphArea (255, 255, 255, true);
|
||||
|
||||
$this->graph->setFontProperties ($this->fontpath, 7);
|
||||
$size = $this->graph->getLegendBoxSize ($this->dataset->GetDataDescription ());
|
||||
|
||||
/* Old resize code for graph area, discard, we need all area in pure mode
|
||||
if (is_array ($size)) {
|
||||
while ($size[1] > $this->y1)
|
||||
$this->y1 += (int) $size[1] / 2;
|
||||
if ($this->y1 > $this->y2)
|
||||
$this->y1 = $this->y2;
|
||||
}
|
||||
*/
|
||||
|
||||
if ($this->show_title == 1){
|
||||
$this->y1=40;
|
||||
} else {
|
||||
$this->y1=10;
|
||||
}
|
||||
|
||||
// No title for combined
|
||||
if ($this->stacked !== false){
|
||||
$this->y1=10;
|
||||
}
|
||||
|
||||
|
||||
$this->graph->setGraphArea ($this->x1, $this->y1, $this->x2, $this->y2);
|
||||
|
||||
if ($this->show_title) {
|
||||
$this->graph->setFontProperties ($this->fontpath, 12);
|
||||
$this->graph->drawTextBox (2, 7, $this->width, 20, $this->title, 0, 0, 0, 0, ALIGN_LEFT, false);
|
||||
$this->graph->setFontProperties ($this->fontpath, 9);
|
||||
$this->graph->drawTextBox (0, 10, $this->width, 20, $this->subtitle,
|
||||
0, 0, 0, 0, ALIGN_CENTER, false);
|
||||
|
||||
$this->graph->setFontProperties ($this->fontpath, 6);
|
||||
}
|
||||
|
||||
/* This is a tiny watermark */
|
||||
if ($this->watermark) {
|
||||
if ($this->show_title){
|
||||
$this->graph->setFontProperties ($this->fontpath, 7);
|
||||
$this->graph->drawTextBox ($this->width - 8, 40,
|
||||
$this->width - 240, 90, 'PANDORA FMS', 90,
|
||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||
}
|
||||
else {
|
||||
$this->graph->setFontProperties ($this->fontpath, 7);
|
||||
$this->graph->drawTextBox ($this->width - 8, 50,
|
||||
$this->width - 240, 60, 'PANDORA FMS', 90,
|
||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function add_legend () {
|
||||
if ((! $this->show_title || $this->legend === false) && ($this->stacked === false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add legend */
|
||||
$this->graph->setFontProperties ($this->fontpath, 6);
|
||||
$size = $this->graph->getLegendBoxSize ($this->dataset->GetDataDescription ());
|
||||
|
||||
// No title for combined, so legends goes up
|
||||
if ($this->stacked !== false)
|
||||
$this->graph->drawLegend ( 35, 12,
|
||||
$this->dataset->GetDataDescription (),
|
||||
245, 245, 245);
|
||||
else
|
||||
$this->graph->drawLegend ( 35, 52,
|
||||
$this->dataset->GetDataDescription (),
|
||||
245, 245, 245);
|
||||
}
|
||||
|
||||
private function set_colors () {
|
||||
if ($this->graph == NULL)
|
||||
return;
|
||||
|
||||
for ($a = 0; $a<9; $a++){
|
||||
$color = $this->get_rgb_values ($this->graph_color[$a+1]);
|
||||
$this->graph->setColorPalette ($a, $color['r'], $color['g'], $color['b']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -57,7 +57,7 @@ $report["datetime"] = $datetime;
|
|||
// Calculations in order to modify init date of the report
|
||||
$date_init_less = strtotime(date ('Y-m-j')) - 86400;
|
||||
$date_init = get_parameter('date_init', date ('Y-m-j', $date_init_less));
|
||||
$time_init = get_parameter('time_init', date ('h:iA'));
|
||||
$time_init = get_parameter('time_init', date ('h:iA', $date_init_less));
|
||||
$datetime_init = strtotime ($date_init.' '.$time_init);
|
||||
$enable_init_date = get_parameter('enable_init_date', 0);
|
||||
|
||||
|
@ -86,23 +86,28 @@ if ($enable_init_date) {
|
|||
$table->width = '99%';
|
||||
$table->class = 'databox';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'width: 60px;';
|
||||
|
||||
// Set initial conditions for these controls, later will be modified by javascript
|
||||
if (!$enable_init_date){
|
||||
$table->style[3] = 'display: none';
|
||||
$table->style[4] = 'display: none';
|
||||
$table->style[5] = 'width: 380.583px';
|
||||
$table->style[0] .= 'font-weight: bold; display: none';
|
||||
$table->style[1] = 'display: none';
|
||||
$table->style[2] = 'display: ""';
|
||||
$table->style[3] .= 'display: none';
|
||||
//~ $table->style[5] = 'width: 380.583px';
|
||||
}
|
||||
else{
|
||||
$table->style[0] .= 'font-weight: bold; display: ""';
|
||||
$table->style[1] = 'display: ""';
|
||||
$table->style[2] = 'display: none';
|
||||
$table->style[3] = 'display: ""';
|
||||
$table->style[4] = 'display: ""';
|
||||
$table->style[5] = 'display: none';
|
||||
}
|
||||
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '50px';
|
||||
$table->colspan[0][1] = 4;
|
||||
$table->size[0] = '60px';
|
||||
$table->size[2] = '60px';
|
||||
$table->colspan[0][1] = 2;
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = html_print_image("images/reporting.png", true, array("width" => "32", "height" => "32"));
|
||||
if ($report['description'] != '') {
|
||||
|
@ -110,15 +115,18 @@ if ($report['description'] != '') {
|
|||
} else {
|
||||
$table->data[0][1] = $report['name'];
|
||||
}
|
||||
$table->data[1][0] = __('Date');
|
||||
$table->data[1][1] = html_print_input_text ('date', $date, '', 12, 10, true). ' ';
|
||||
$table->data[1][1] .= html_print_input_text ('time', $time, '', 7, 7, true). ' ';
|
||||
$table->data[1][1] .= html_print_submit_button (__('Update'), 'date_submit', false, 'class="sub next"', true);
|
||||
$table->data[1][2] = __('Set initial date of all reports') . html_print_checkbox('enable_init_date', 1, $enable_init_date, true);
|
||||
$table->data[1][3] = '<b>' . __('Date') . '</b>' . ui_print_help_tip(__('This is the begin date for all reports'), true);
|
||||
$table->data[1][4] = html_print_input_text ('date_init', $date_init, '', 12, 10, true). ' ';
|
||||
$table->data[1][4] .= html_print_input_text ('time_init', $time_init, '', 7, 7, true). ' ';
|
||||
$table->data[1][4] .= html_print_submit_button (__('Update'), 'date_submit_init', false, 'class="sub next"', true);
|
||||
|
||||
$table->data[0][3] = '<span style="text-align:right;width:100%">'.__('Set initial date of all reports') . html_print_checkbox('enable_init_date', 1, $enable_init_date, true).'</span>';
|
||||
|
||||
$table->data[1][0] = '<b>' . __('From') . ':</b>';
|
||||
$table->data[1][1] = html_print_input_text ('date_init', $date_init, '', 12, 10, true). ' ';
|
||||
$table->data[1][1] .= html_print_input_text ('time_init', $time_init, '', 7, 7, true). ' ';
|
||||
//~ $table->data[1][1] .= html_print_submit_button (__('Update'), 'date_submit_init', false, 'class="sub next"', true);
|
||||
$table->data[1][2] = '<b>' . __('Day before') . ':</b>';
|
||||
$table->data[1][3] = '<b>' . __('to') . ':</b>';
|
||||
$table->data[1][4] = html_print_input_text ('date', $date, '', 12, 10, true). ' ';
|
||||
$table->data[1][4] .= html_print_input_text ('time', $time, '', 7, 7, true). ' ';
|
||||
$table->data[1][4] .= html_print_submit_button (__('Update'), 'date_submit', false, 'class="sub next"', true);
|
||||
$table->data[1][5] = '';
|
||||
|
||||
echo '<form method="post" action="">';
|
||||
|
@ -207,6 +215,7 @@ foreach ($contents as $content) {
|
|||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
$(document).ready (function () {
|
||||
$("#loading").slideUp ();
|
||||
$("#text-time").timeEntry ({spinnerImage: 'images/time-entry.png', spinnerSize: [20, 20, 0]});
|
||||
|
@ -221,15 +230,18 @@ $(document).ready (function () {
|
|||
$("#checkbox-enable_init_date").click(function() {
|
||||
flag = $("#checkbox-enable_init_date").is(':checked');
|
||||
if (flag == true){
|
||||
$("#table1-1-0").css("display", "");
|
||||
$("#table1-1-1").css("display", "");
|
||||
$("#table1-1-2").css("display", "none");
|
||||
$("#table1-1-3").css("display", "");
|
||||
$("#table1-1-4").css("display", "");
|
||||
$("#table1-1-5").css("display", "none");
|
||||
}
|
||||
else {
|
||||
$("#table1-1-6").css("display", "none");
|
||||
}else{
|
||||
$("#table1-1-0").css("display", "none");
|
||||
$("#table1-1-1").css("display", "none");
|
||||
$("#table1-1-2").css("display", "");
|
||||
$("#table1-1-3").css("display", "none");
|
||||
$("#table1-1-4").css("display", "none");
|
||||
$("#table1-1-5").css("display", "");
|
||||
$("#table1-1-5").css("width", "380.583px");
|
||||
$("#table1-1-6").css("display", "");
|
||||
$("#table1-1-6").css("width", "380.583px");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue