From fd7af69a1d0f34ed6dd2646a128afb0991c48e0b Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 13 Apr 2022 15:24:31 +0200 Subject: [PATCH] #8587 tooltip option --- .../include/graphs/functions_d3.php | 4 +-- pandora_console/include/graphs/pandora.d3.js | 26 +++++++++++++++---- .../lib/Dashboard/Widgets/service_map.php | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 57cf3a1f43..8c4a1b6ade 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -150,7 +150,7 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false) } -function d3_sunburst_graph($data, $width=700, $height=700, $return=false) +function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true) { global $config; @@ -167,7 +167,7 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false) } '; $output .= ""; if (!$return) { diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index a07c780501..aad0506f86 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -796,7 +796,7 @@ function treeMap(recipient, data, width, height) { // The area (or angle, depending on implementation) of each arc corresponds to its value. // Sunburst design by John Stasko. Data courtesy Jeff Heer. // http://bl.ocks.org/mbostock/4348373 -function sunburst(recipient, data, width, height) { +function sunburst(recipient, data, width, height, tooltip = true) { if (width === "auto") { width = $(recipient).innerWidth(); } @@ -858,11 +858,14 @@ function sunburst(recipient, data, width, height) { }) .style("cursor", "pointer") .on("click", click) - .on("mouseover", over_user) + .on("mouseover", tooltip === "1" ? over_user : "") .on("mouseout", out_user) .on("mousemove", move_tooltip); function computeTextRotation(d) { + if (d.type === "central_service") { + return 0; + } var ang = ((x(d.x + d.dx / 2) - Math.PI / 2) / Math.PI) * 180; return ang > 90 ? 180 + ang : ang; } @@ -882,9 +885,18 @@ function sunburst(recipient, data, width, height) { return computeTextRotation(d) > 180 ? -40 : -30; }) .attr("dx", "6") // margin - .attr("dy", ".35em") // vertical-align + .attr("dy", function(d) { + if (d.type === "central_service") { + return "-7em"; + } + return ".35em"; + }) // vertical-align .attr("opacity", function(d) { - if (typeof d.show_name != "undefined" && d.show_name) return 1; + if ( + (typeof d.show_name != "undefined" && d.show_name) || + d.type === "central_service" + ) + return 1; else return 0; }) .text(function(d) { @@ -899,7 +911,11 @@ function sunburst(recipient, data, width, height) { window.location.href = d.link; } else { // fade out all text elements - text.transition().attr("opacity", 0); + if (d.type === "central_service") { + text.transition().attr("opacity", 1); + } else { + text.transition().attr("opacity", 0); + } path .transition() diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index a05f71c92a..21a7edc82c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -405,7 +405,7 @@ class ServiceMapWidget extends Widget ); } else { include_once $config['homedir'].'/include/graphs/functions_d3.php'; - servicemap_print_sunburst($this->values['serviceId'], $size['width'], $size['height']); + servicemap_print_sunburst($this->values['serviceId'], $size['width'], $size['height'], false); } $output .= ob_get_clean();