#7963 Fixed netflow view 2

This commit is contained in:
Daniel Maya 2021-09-29 10:57:57 +02:00
parent af4e49e156
commit fb449910c9
2 changed files with 62 additions and 15 deletions

View File

@ -420,7 +420,8 @@ function netflow_get_data(
$max,
$absolute,
$connection_name='',
$address_resolution=false
$address_resolution=false,
$network_format_bytes=false
) {
global $nfdump_date_format;
global $config;
@ -560,7 +561,25 @@ function netflow_get_data(
continue;
}
$values['data'][$interval_end][$line['agg']] = $line['data'];
if ($network_format_bytes == true) {
$pos = 0;
$number = $line['data'];
while ($number >= 1024) {
// As long as the number can be divided by divider.
$pos++;
// Position in array starting with 0.
$number = ($number / 1024);
}
while ($pos > 0) {
$number = ($number * 1000);
$pos --;
}
$values['data'][$interval_end][$line['agg']] = $number;
} else {
$values['data'][$interval_end][$line['agg']] = $line['data'];
}
}
}
@ -1082,7 +1101,8 @@ function netflow_draw_item(
$max_aggregates,
true,
$connection_name,
$address_resolution
$address_resolution,
true
);
if (empty($data) === true) {

View File

@ -99,18 +99,26 @@ function chordDiagram(recipient, elements, matrix, width) {
.transition()
.style("opacity", opacity);
svg.selectAll(".chord").filter(function(d) {
if (
event.type == "mouseover" &&
(d.source.index == i || d.target.index == i)
) {
show_tooltip(d);
return;
} else {
hide_tooltip();
return;
}
});
if (event.type == "mouseover") {
const chords = chord.chords();
$.each(chords, function(key, value) {
if (
(value.source.index == i && value.target.subindex == i) ||
(value.source.subindex == i && value.target.index == i)
) {
if (
$("#tooltip").is(":hidden") ||
$("#tooltip").length == 0
) {
show_tooltip(value);
} else {
add_tooltip(value);
}
}
});
} else {
hide_tooltip();
}
};
};
@ -273,6 +281,25 @@ function chordDiagram(recipient, elements, matrix, width) {
);
}
function add_tooltip(d) {
$("#tooltip").append(
"</br>" +
elements[d.source.index] +
" → " +
elements[d.target.index] +
": <b>" +
valueToBytes(d.source.value) +
"</b>" +
"<br>" +
elements[d.target.index] +
" → " +
elements[d.source.index] +
": <b>" +
valueToBytes(d.target.value) +
"</b>"
);
}
function show_tooltip(d) {
x = d3.event.pageX + 10;
y = d3.event.pageY + 10;