in ui-modules/app-inspector/app/components/task-sunburst/task-sunburst.directive.js [286:399]
function update(rawData) {
if (rawData && rawData.children!=null && !rawData.children.length) {
// just hide if there's no data
d3_root.style("display", "none");
} else {
d3_root.style("display", "");
}
if (rawData.children.length>5) return;
var root = d3.hierarchy(rawData);
// set depth on the data so we can stop recursively sizing beyond a given depth
root.each(n => { n.data.depth = n.depth; });
scaling.updateMaxDepthFor(root);
root.sum(function(x) {
if (x.depth && max_depth_to_show > 0 && x.depth > max_depth_to_show) {
// disregard nodes that are out of scope (so that piece of pie doesn't get huge)
return 0;
}
var kidsValue = 0;
if (x.children) x.children.forEach((c) => { kidsValue += c.value; });
return Math.max(0, sizeOfTask(x) - kidsValue);
});
root.sort(util.orderFn);
var data = root;
var dd = partition(root).descendants().filter(function(d) {
return d.depth > 0 && (max_depth_to_show <= 0 || d.depth <= max_depth_to_show);
});
var g = chart.selectAll("g.node").data(dd, util.taskId);
g.exit().remove();
var g_enter = g.enter().append("g").attr("class", "node");
var path_enter = g_enter.append("path")
.attr("class", function(d) { return util.taskClasses(d, ["arc", "primary"]).join(" "); })
.on("mouseover", mouseover)
.on("click", click)
.style("fill", function(d) { return util.colors.f(d, $scope.colorScheme); });
path_enter
.transition().duration(300 * options.transitionScale)
.attrTween("d", function (d) { return function(t) {
return util.arcF({ scaling: scaling, visible_arc_length: sizing.visible_arc_length,
visible_arc_start_fn: sizing.visible_arc_start_fn, t: t })(d);
}; });
g.select("path.arc.primary")
.attr("class", function(d) { return util.taskClasses(d, ["arc", "primary"]).join(" "); })
.transition().duration(300 * options.transitionScale)
.attr("d", util.arcF({ scaling: scaling, visible_arc_length: sizing.visible_arc_length,
visible_arc_start_fn: sizing.visible_arc_start_fn }))
.style("fill", function(d) { return util.colors.f(d, $scope.colorScheme); });
path_enter.append("animate")
.attr("attributeType", "XML")
.attr("attributeName", "fill");
g.select("path.arc.primary animate")
.attr("values", function(d) { return util.isInProgress(d)
? util.colors.ACTIVE_ANIMATE_VALUES : util.colors.f(d, $scope.colorScheme); })
.attr("dur", "1.5s")
.attr("repeatCount", function(d) { return util.isInProgress(d) ? "indefinite" : 0; });
g_enter.filter(util.isNewEntity).append("path").on("click", click)
.attr("class", function(d) { return util.taskClasses(d, ["arc", "primary"]).join(" "); })
.style("fill", function(d) { return util.colors.f(d, $scope.colorScheme); })
.transition().duration(300 * options.transitionScale)
.attrTween("d", function (d) { return function(t) {
return util.arcF({ scaling: scaling, visible_arc_length: sizing.visible_arc_length,
visible_arc_start_fn: sizing.visible_arc_start_fn, isMinimal: true, t: t })(d);
}; });
g.select("path.arc.entering-new-entity")
.attr("class", function(d) { return util.taskClasses(d, ["arc", "entering-new-entity"]).join(" "); })
.transition().duration(300 * options.transitionScale)
.attr("d", util.arcF({ scaling: scaling, visible_arc_length: sizing.visible_arc_length,
visible_arc_start_fn: sizing.visible_arc_start_fn, isMinimal: true}))
.style("fill", function(d) { return util.colors.f(d, $scope.colorScheme); });
g_enter.append("text")
.attr("class", function(d) { return util.taskClasses(d, ["arc-label"]).join(" "); })
.attr("font-size", sizing.font_size) // vertical-align
.attr("dy", ".35em")
.style("opacity", 0)
.on("click", click)
.transition().duration(600 * options.transitionScale).style("opacity", function(t) {
return t < 0.5 ? 0 : (t-0.5)*2;
});
// fade in text, slower than arcs so that they are in the right place when text becomes visible
g.select("text.arc-label")
.attr("class", function(d) { return util.taskClasses(d, ["arc-label"]).join(" "); })
.text(function(d) {
// only display if arc is big enough
if (shouldTextBeHorizontal(d)) {
if (d.y1 - d.y0 < 0.07) return "";
} else {
if (d.x1 - d.x0 < 0.07) return "";
}
var display = d.data.name || "";
if (display.length>25) display = display.substr(0, 23)+"...";
return display; })
.attr("transform", function(d) {
return "rotate(" + computeTextRotation(d) + ")" +
(shouldTextBeHorizontal(d) ? " rotate(-90,"+xPosOfText(d)+",0) " : "");
})
.attr("x", function(d) { return xPosOfText(d); })
.attr("text-anchor", function(d) { return shouldTextBeHorizontal(d) ? "middle" : ""; })
.attr("dx", function(d) {
// margin - slightly greater on inner arcs, and if it's a cross-entity
return (shouldTextBeHorizontal(d) ? "0" : "" + ((d.depth > 3 ? 2 : 4 - d.depth/2) + (util.isNewEntity(d) ? 1.5 : 0)));
})
.transition().duration(600 * options.transitionScale).style("opacity", 1);
}