mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
2013-10-14 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/flot/pandora.flot.js, include/graphs/functions_flot.php, operation/agentes/stat_win.php: fixed the charts with negative values and a flot type. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8906 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4524961a4e
commit
3a215820c1
@ -1,3 +1,9 @@
|
|||||||
|
2013-10-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/graphs/flot/pandora.flot.js,
|
||||||
|
include/graphs/functions_flot.php, operation/agentes/stat_win.php:
|
||||||
|
fixed the charts with negative values and a flot type.
|
||||||
|
|
||||||
2013-10-14 Vanessa Gil <vanessa.gil@artica.es>
|
2013-10-14 Vanessa Gil <vanessa.gil@artica.es>
|
||||||
|
|
||||||
* include/languages/ar.mo
|
* include/languages/ar.mo
|
||||||
|
@ -546,12 +546,12 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
// Prepared to turn series with a checkbox
|
// Prepared to turn series with a checkbox
|
||||||
// var showed = new Array();
|
// var showed = new Array();
|
||||||
|
|
||||||
for(i=0;i<values.length;i++) {
|
for (i = 0; i < values.length; i++) {
|
||||||
var serie = values[i].split(separator);
|
var serie = values[i].split(separator);
|
||||||
var aux = new Array();
|
var aux = new Array();
|
||||||
var critical_min = new Array();
|
var critical_min = new Array();
|
||||||
var warning_min = new Array();
|
var warning_min = new Array();
|
||||||
$.each(serie,function(i,v) {
|
$.each(serie, function(i, v) {
|
||||||
aux.push([i, v]);
|
aux.push([i, v]);
|
||||||
if (threshold) {
|
if (threshold) {
|
||||||
critical_min.push([i,red_threshold]);
|
critical_min.push([i,red_threshold]);
|
||||||
@ -562,12 +562,12 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
switch(serie_types[i]) {
|
switch(serie_types[i]) {
|
||||||
case 'line':
|
case 'line':
|
||||||
default:
|
default:
|
||||||
line_show = true;
|
line_show = true;
|
||||||
points_show = false;
|
points_show = false;
|
||||||
break;
|
break;
|
||||||
case 'points':
|
case 'points':
|
||||||
line_show = false;
|
line_show = false;
|
||||||
points_show = true;
|
points_show = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,12 +601,18 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
|
|
||||||
// Data
|
// Data
|
||||||
data_base.push({
|
data_base.push({
|
||||||
id: 'serie_'+i,
|
id: 'serie_' + i,
|
||||||
data: aux,
|
data: aux,
|
||||||
label: legend[i],
|
label: legend[i],
|
||||||
color: serie_color,
|
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)" }],
|
//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: 0.9 }, { opacity: 0.9 } ]}, lineWidth:1, steps:false },
|
lines: { show: line_show,
|
||||||
|
fill: filled,
|
||||||
|
fillColor: {
|
||||||
|
colors: [ { opacity: 0.9 }, { opacity: 0.9 } ]
|
||||||
|
},
|
||||||
|
lineWidth: 1,
|
||||||
|
steps: false },
|
||||||
points: { show: points_show }
|
points: { show: points_show }
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -642,14 +648,14 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
var min_tick_pixels = 80;
|
var min_tick_pixels = 80;
|
||||||
var steps = parseInt( count_data / (width/min_tick_pixels));
|
var steps = parseInt( count_data / (width/min_tick_pixels));
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
series: {
|
series: {
|
||||||
stack: stacked,
|
stack: stacked,
|
||||||
shadowSize: 0.1
|
shadowSize: 0.1
|
||||||
},
|
},
|
||||||
crosshair: { mode: 'xy' },
|
crosshair: { mode: 'xy' },
|
||||||
selection: { mode: 'x', color: '#777' },
|
selection: { mode: 'x', color: '#777' },
|
||||||
grid: {
|
grid: {
|
||||||
hoverable: true,
|
hoverable: true,
|
||||||
clickable: true,
|
clickable: true,
|
||||||
borderWidth:1,
|
borderWidth:1,
|
||||||
@ -657,27 +663,26 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
tickColor: '#eee',
|
tickColor: '#eee',
|
||||||
markings: markings
|
markings: markings
|
||||||
},
|
},
|
||||||
xaxes: [ {
|
xaxes: [ {
|
||||||
tickFormatter: xFormatter,
|
tickFormatter: xFormatter,
|
||||||
minTickSize: steps,
|
minTickSize: steps,
|
||||||
color: '#000'
|
color: '#000'
|
||||||
} ],
|
} ],
|
||||||
yaxes: [ {
|
yaxes: [ {
|
||||||
tickFormatter: yFormatter,
|
tickFormatter: yFormatter,
|
||||||
min: 0,
|
color: '#000'
|
||||||
color: '#000'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// align if we are to the right
|
// align if we are to the right
|
||||||
alignTicksWithAxis: 1,
|
alignTicksWithAxis: 1,
|
||||||
position: 'right'
|
position: 'right'
|
||||||
|
|
||||||
//tickFormatter: dFormatter
|
//tickFormatter: dFormatter
|
||||||
} ]
|
} ]
|
||||||
,
|
,
|
||||||
legend: {
|
legend: {
|
||||||
position: 'se',
|
position: 'se',
|
||||||
container: $('#legend_'+graph_id),
|
container: $('#legend_' + graph_id),
|
||||||
labelFormatter: lFormatter
|
labelFormatter: lFormatter
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -700,20 +705,20 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
},
|
},
|
||||||
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
|
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
|
||||||
xaxis: { },
|
xaxis: { },
|
||||||
xaxes: [ {
|
xaxes: [ {
|
||||||
tickFormatter: xFormatter,
|
tickFormatter: xFormatter,
|
||||||
minTickSize: steps,
|
minTickSize: steps,
|
||||||
color: '#000'
|
color: '#000'
|
||||||
} ],
|
} ],
|
||||||
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
|
yaxis: {ticks: [], autoscaleMargin: 0.1 },
|
||||||
selection: { mode: 'x', color: '#777' },
|
selection: {mode: 'x', color: '#777' },
|
||||||
legend: {show: false},
|
legend: {show: false},
|
||||||
crosshair: { mode: 'x' }
|
crosshair: {mode: 'x'}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Connection between plot and miniplot
|
// Connection between plot and miniplot
|
||||||
|
|
||||||
$('#'+graph_id).bind('plotselected', function (event, ranges) {
|
$('#' + graph_id).bind('plotselected', function (event, ranges) {
|
||||||
// do the zooming if exist menu to undo it
|
// do the zooming if exist menu to undo it
|
||||||
if (menu == 0) {
|
if (menu == 0) {
|
||||||
return;
|
return;
|
||||||
@ -723,9 +728,9 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
|
|
||||||
factor = dataInSelection / dataInPlot;
|
factor = dataInSelection / dataInPlot;
|
||||||
|
|
||||||
new_steps = parseInt(factor*steps);
|
new_steps = parseInt(factor * steps);
|
||||||
|
|
||||||
plot = $.plot($('#'+graph_id), datas,
|
plot = $.plot($('#' + graph_id), datas,
|
||||||
$.extend(true, {}, options, {
|
$.extend(true, {}, options, {
|
||||||
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to},
|
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to},
|
||||||
xaxes: [ {
|
xaxes: [ {
|
||||||
@ -736,18 +741,20 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
legend: { show: false }
|
legend: { show: false }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.png');
|
$('#menu_cancelzoom_' + graph_id)
|
||||||
|
.attr('src',homeurl + '/images/zoom_cross.png');
|
||||||
|
|
||||||
currentRanges = ranges;
|
currentRanges = ranges;
|
||||||
// don't fire event on the overview to prevent eternal loop
|
// don't fire event on the overview to prevent eternal loop
|
||||||
overview.setSelection(ranges, true);
|
overview.setSelection(ranges, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#overview_'+graph_id).bind('plotselected', function (event, ranges) {
|
$('#overview_' + graph_id)
|
||||||
plot.setSelection(ranges);
|
.bind('plotselected', function (event, ranges) {
|
||||||
});
|
plot.setSelection(ranges);
|
||||||
|
});
|
||||||
|
|
||||||
var legends = $('#legend_'+graph_id+' .legendLabel');
|
var legends = $('#legend_' + graph_id + ' .legendLabel');
|
||||||
|
|
||||||
var updateLegendTimeout = null;
|
var updateLegendTimeout = null;
|
||||||
var latestPosition = null;
|
var latestPosition = null;
|
||||||
@ -991,7 +998,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
// cancel the zooming
|
// cancel the zooming
|
||||||
plot = $.plot($('#'+graph_id), data_base,
|
plot = $.plot($('#'+graph_id), data_base,
|
||||||
$.extend(true, {}, options, {
|
$.extend(true, {}, options, {
|
||||||
xaxis: { min: 0, max: max_x },
|
xaxis: {max: max_x },
|
||||||
legend: { show: false }
|
legend: { show: false }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -163,12 +163,12 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||||||
$colors[] = '';
|
$colors[] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($chart_data as $label => $values) {
|
foreach($chart_data as $label => $values) {
|
||||||
$labels[] = io_safe_output($label);
|
$labels[] = io_safe_output($label);
|
||||||
|
|
||||||
foreach($values as $key => $value) {
|
foreach($values as $key => $value) {
|
||||||
$jsvar = "data_".$graph_id."_".$key;
|
$jsvar = "data_" . $graph_id . "_" . $key;
|
||||||
|
|
||||||
if (!isset($serie_types[$key])) {
|
if (!isset($serie_types[$key])) {
|
||||||
$serie_types2[$jsvar] = 'line';
|
$serie_types2[$jsvar] = 'line';
|
||||||
@ -298,14 +298,42 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||||||
else {
|
else {
|
||||||
$force_integer = 'false';
|
$force_integer = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trick to get translated string from javascript
|
// Trick to get translated string from javascript
|
||||||
$return .= html_print_input_hidden('unknown_text', __('Unknown'), true);
|
$return .= html_print_input_hidden('unknown_text', __('Unknown'),
|
||||||
|
true);
|
||||||
|
|
||||||
// Javascript code
|
// Javascript code
|
||||||
$return .= "<script type='text/javascript'>";
|
$return .= "<script type='text/javascript'>";
|
||||||
$return .= "//<![CDATA[\n";
|
$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', '$yellow_threshold', '$red_threshold', $force_integer, '$separator', '$separator2', '$series_suffix_str');";
|
$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', " .
|
||||||
|
"$force_integer, " .
|
||||||
|
"'$separator', " .
|
||||||
|
"'$separator2', " .
|
||||||
|
"'$series_suffix_str');";
|
||||||
$return .= "\n//]]>";
|
$return .= "\n//]]>";
|
||||||
$return .= "</script>";
|
$return .= "</script>";
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ $label = base64_decode(get_parameter('label', ''));
|
|||||||
echo '<div style="margin-left: 70px; padding-top: 10px;">';
|
echo '<div style="margin-left: 70px; padding-top: 10px;">';
|
||||||
else
|
else
|
||||||
echo '<div style="margin-left: 50px; padding-top: 10px;">';
|
echo '<div style="margin-left: 50px; padding-top: 10px;">';
|
||||||
|
|
||||||
switch ($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user