#8587 tooltip option
This commit is contained in:
parent
9f1be4531b
commit
fd7af69a1d
|
@ -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;
|
global $config;
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false)
|
||||||
}
|
}
|
||||||
</style>';
|
</style>';
|
||||||
$output .= "<script language=\"javascript\" type=\"text/javascript\">
|
$output .= "<script language=\"javascript\" type=\"text/javascript\">
|
||||||
sunburst('#sunburst', $data, '$width', '$height');
|
sunburst('#sunburst', $data, '$width', '$height', '$tooltip');
|
||||||
</script>";
|
</script>";
|
||||||
|
|
||||||
if (!$return) {
|
if (!$return) {
|
||||||
|
|
|
@ -796,7 +796,7 @@ function treeMap(recipient, data, width, height) {
|
||||||
// The area (or angle, depending on implementation) of each arc corresponds to its value.
|
// The area (or angle, depending on implementation) of each arc corresponds to its value.
|
||||||
// Sunburst design by John Stasko. Data courtesy Jeff Heer.
|
// Sunburst design by John Stasko. Data courtesy Jeff Heer.
|
||||||
// http://bl.ocks.org/mbostock/4348373
|
// http://bl.ocks.org/mbostock/4348373
|
||||||
function sunburst(recipient, data, width, height) {
|
function sunburst(recipient, data, width, height, tooltip = true) {
|
||||||
if (width === "auto") {
|
if (width === "auto") {
|
||||||
width = $(recipient).innerWidth();
|
width = $(recipient).innerWidth();
|
||||||
}
|
}
|
||||||
|
@ -858,11 +858,14 @@ function sunburst(recipient, data, width, height) {
|
||||||
})
|
})
|
||||||
.style("cursor", "pointer")
|
.style("cursor", "pointer")
|
||||||
.on("click", click)
|
.on("click", click)
|
||||||
.on("mouseover", over_user)
|
.on("mouseover", tooltip === "1" ? over_user : "")
|
||||||
.on("mouseout", out_user)
|
.on("mouseout", out_user)
|
||||||
.on("mousemove", move_tooltip);
|
.on("mousemove", move_tooltip);
|
||||||
|
|
||||||
function computeTextRotation(d) {
|
function computeTextRotation(d) {
|
||||||
|
if (d.type === "central_service") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
var ang = ((x(d.x + d.dx / 2) - Math.PI / 2) / Math.PI) * 180;
|
var ang = ((x(d.x + d.dx / 2) - Math.PI / 2) / Math.PI) * 180;
|
||||||
return ang > 90 ? 180 + ang : ang;
|
return ang > 90 ? 180 + ang : ang;
|
||||||
}
|
}
|
||||||
|
@ -882,9 +885,18 @@ function sunburst(recipient, data, width, height) {
|
||||||
return computeTextRotation(d) > 180 ? -40 : -30;
|
return computeTextRotation(d) > 180 ? -40 : -30;
|
||||||
})
|
})
|
||||||
.attr("dx", "6") // margin
|
.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) {
|
.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;
|
else return 0;
|
||||||
})
|
})
|
||||||
.text(function(d) {
|
.text(function(d) {
|
||||||
|
@ -899,7 +911,11 @@ function sunburst(recipient, data, width, height) {
|
||||||
window.location.href = d.link;
|
window.location.href = d.link;
|
||||||
} else {
|
} else {
|
||||||
// fade out all text elements
|
// 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
|
path
|
||||||
.transition()
|
.transition()
|
||||||
|
|
|
@ -405,7 +405,7 @@ class ServiceMapWidget extends Widget
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
include_once $config['homedir'].'/include/graphs/functions_d3.php';
|
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();
|
$output .= ob_get_clean();
|
||||||
|
|
Loading…
Reference in New Issue