Fixed bug in histogram graph report

This commit is contained in:
manuel 2019-10-11 09:04:13 +02:00
parent 9a165dc9d8
commit a69cfb63f1
3 changed files with 58 additions and 52 deletions

View File

@ -172,7 +172,6 @@ function pandoraFlotPieCustom(
show: true,
radius: 5 / 8,
formatter: function(label, series) {
console.log(series);
return (
'<div style="font-size:' +
font_size +
@ -783,9 +782,7 @@ function pandoraFlotSlicebar(
graph_id,
values,
datacolor,
labels,
legend,
acumulate_data,
intervaltick,
font,
font_size,
@ -794,12 +791,11 @@ function pandoraFlotSlicebar(
id_agent,
full_legend,
not_interactive,
show_date
show_date,
datelimit
) {
values = values.split(separator2);
labels = labels.split(separator);
legend = legend.split(separator);
acumulate_data = acumulate_data.split(separator);
datacolor = datacolor.split(separator);
if (full_legend != false) {
@ -822,9 +818,7 @@ function pandoraFlotSlicebar(
var serie = values[i].split(separator);
var aux = new Array();
$.each(serie, function(i, v) {
aux.push([v, i]);
});
aux.push([parseInt(serie[0]), 0]);
datas.push({
data: aux,
@ -902,18 +896,16 @@ function pandoraFlotSlicebar(
}
$("#extra_" + graph_id).text(from + "-" + to);
var extra_height = parseInt(
$("#extra_" + graph_id)
.css("height")
.split("px")[0]
);
var extra_width = parseInt(
$("#extra_" + graph_id)
.css("width")
.split("px")[0]
);
$("#extra_" + graph_id).css("left", pos.pageX - extra_width / 4 + "px");
//$('#extra_'+graph_id).css('top',plot.offset().top-extra_height-5+'px');
$("#extra_" + graph_id).css(
"left",
parseInt(pos.pageX - extra_width - 200) + "px"
);
$("#extra_" + graph_id).show();
}
});
@ -992,13 +984,33 @@ function pandoraFlotSlicebar(
// Format functions
function xFormatter(v, axis) {
v = new Date(1000 * v);
date_format =
(v.getHours() < 10 ? "0" : "") +
v.getHours() +
d = new Date(1000 * (v + datelimit));
var monthNames = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
];
var date_format =
(d.getDate() < 10 ? "0" : "") +
d.getDate() +
" " +
monthNames[d.getMonth()] +
"<br>" +
(d.getHours() < 10 ? "0" : "") +
d.getHours() +
":" +
(v.getMinutes() < 10 ? "0" : "") +
v.getMinutes();
(d.getMinutes() < 10 ? "0" : "") +
d.getMinutes();
return date_format;
}
}

View File

@ -786,6 +786,8 @@ function flot_slicesbar_graph(
// Get a unique identifier to graph
$graph_id = uniqid('graph_');
$height = ((int) $height + 15);
// Set some containers to legend, graph, timestamp tooltip, etc.
if ($stat_win) {
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'%; height: '.$height."px; display: inline-block;'></div>";
@ -804,8 +806,6 @@ function flot_slicesbar_graph(
$separator2 = ':,:,,,:,:';
// Transform data from our format to library format
$labels = [];
$a = [];
$vars = [];
$datacolor = [];
@ -819,12 +819,12 @@ function flot_slicesbar_graph(
$fontsize = $config['font_size'];
$fontpath = $config['fontpath'];
$extra_height = 15;
$extra_height = 40;
if (defined('METACONSOLE')) {
$extra_height = 20;
$extra_height = 50;
}
$return .= "<div id='extra_$graph_id' style='font-size: ".$fontsize.'pt; display:none; position:absolute; overflow: auto; height: '.$extra_height."px; background:#fff; padding: 2px 2px 2px 2px; border: solid #000 1px;'></div>";
$return .= '<div id="extra_'.$graph_id.'" class="slicebar-box-hover-styles" style="display:none; font-size:'.$fontsize.'"></div>';
$maxticks = (int) 20;
@ -842,11 +842,7 @@ function flot_slicesbar_graph(
$intervaltick = (int) $intervaltick;
$acumulate = 0;
$c = 0;
$acumulate_data = [];
foreach ($graph_data as $label => $values) {
$labels[] = $label;
$i--;
foreach ($values as $key => $value) {
@ -857,19 +853,10 @@ function flot_slicesbar_graph(
}
$data[$jsvar][] = $value;
$acumulate_data[$c] = $acumulate;
$acumulate += $value;
$c++;
if ($value > $max) {
$max = $value;
}
}
}
// Store serialized data to use it from javascript
$labels = implode($separator, $labels);
// Store serialized data to use it from javascript.
$datacolor = implode($separator, $datacolor);
if (is_array($legend)) {
$legend = io_safe_output(implode($separator, $legend));
@ -881,19 +868,11 @@ function flot_slicesbar_graph(
$full_legend_date = false;
}
$acumulate_data = io_safe_output(implode($separator, $acumulate_data));
// Store data series in javascript format
$jsvars = '';
$jsseries = [];
$date = get_system_time();
$datelimit = (($date - $period) * 1000);
$datelimit = (($date - $period));
$i = 0;
$values2 = [];
foreach ($data as $jsvar => $values) {
$values2[] = implode($separator, $values);
$i ++;
@ -901,10 +880,10 @@ function flot_slicesbar_graph(
$values = implode($separator2, $values2);
// Javascript code
// Javascript code.
$return .= "<script type='text/javascript'>";
$return .= "//<![CDATA[\n";
$return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$labels','$legend','$acumulate_data',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show')";
$return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$legend',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show', $datelimit)";
$return .= "\n//]]>";
$return .= '</script>';

View File

@ -5888,3 +5888,18 @@ table.table_modal_alternate tr td:first-child {
.fullwidth {
width: 100%;
}
.slicebar-box-hover-styles {
position: absolute;
background-color: #fff;
width: 80px;
height: 20px;
text-align: center;
font-family: arial, sans-serif, verdana;
padding: 3px;
border: 1px solid black;
}
.flot-text {
width: 101%;
}