Skip to content

Commit 0b5fd99

Browse files
author
Robert Jackson
committed
Add node texts
Includes output similar to `broccoli-viz`: * `id` * `name` * `totalTime` * `selfTime`
1 parent 20daa13 commit 0b5fd99

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

app/components/basic-tree.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,32 @@ export default Ember.Component.extend({
111111
return "translate(" + d.y + "," + d.x + ")";
112112
});
113113

114-
node.append("circle")
115-
.attr("r", 2.5);
114+
nodeEnter.append('text')
115+
.attr('dy', '-1.1em')
116+
.style("text-anchor", function(d) { return d.children ? "end" : "start"; })
117+
.text(d => d.data._id);
116118

117-
node.append("text")
118-
.attr("dy", 3)
119-
.attr("x", function(d) { return d.children ? -8 : 8; })
119+
nodeEnter.append("text")
120+
.attr("dy", '0.1em')
120121
.style("text-anchor", function(d) { return d.children ? "end" : "start"; })
121122
.text(function(d) {
122123
return d.data.id.name;
123124
});
124125

126+
nodeEnter.append("text")
127+
.attr("dy", '1.1em')
128+
.style("text-anchor", function(d) { return d.children ? "end" : "start"; })
129+
.text(function(d) {
130+
return `total: ${(d.value / 1000000).toFixed(2)}`;
131+
});
132+
133+
nodeEnter.append("text")
134+
.attr("dy", '2.1em')
135+
.style("text-anchor", function(d) { return d.children ? "end" : "start"; })
136+
.text(function(d) {
137+
return `self: ${(d.data.stats.time.self / 1000000).toFixed(2)}`;
138+
});
139+
125140
let zoomHandler = zoom()
126141
.scaleExtent([0.1, 3])
127142
.on("zoom", () => {

0 commit comments

Comments
 (0)