diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 9ac6e5e9df..7d57f50870 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -506,6 +506,7 @@ function treeMap(recipient, data, width, height, childLinks = false) { .attr("width", function(d) { return Math.max(0.01, d.dx); }) + .attr("style", "transition: all 0.5s ease-out;") .attr("height", headerHeight) .text(function(d) { return d.name; @@ -636,6 +637,29 @@ function treeMap(recipient, data, width, height, childLinks = false) { zoom(node); + function calculateSizeText() { + $(recipient + " .parent .clip .label").each((key, node) => { + const textElement = node; + const containerWidth = parseFloat( + $(textElement) + .parent() + .attr("width") + ); + const originalFontSize = 12; + + textElement.style.fontSize = "16px"; + const textWidth = textElement.getComputedTextLength() + 8; + textElement.style.fontSize = originalFontSize; + + const scaleFactor = containerWidth / textWidth; + let scaledFontSize = parseFloat(originalFontSize) * scaleFactor; + + scaledFontSize = scaledFontSize > 12 ? 12 : scaledFontSize; + + textElement.style.fontSize = scaledFontSize; + }); + } + function size(d) { return d.size; } @@ -756,6 +780,9 @@ function treeMap(recipient, data, width, height, childLinks = false) { if (d3.event) { d3.event.stopPropagation(); } + setTimeout(() => { + calculateSizeText(); + }, transitionDuration); } function position() { diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php index 81309103ca..447e3ccbca 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php @@ -408,7 +408,7 @@ class GroupsStatusMapWidget extends Widget foreach ($level1['children'] as $id_grupo => $group) { $level2['children'][] = [ 'id' => uniqid(), - 'name' => $names[$id_grupo], + 'name' => io_safe_output($names[$id_grupo]), 'children' => $group, ]; }