fix: Re-enable URL details view

pull/42/head
Raphaël Vinot 2019-05-17 16:59:56 +02:00
parent 05aaa48cc9
commit cde04c468f
1 changed files with 27 additions and 26 deletions

View File

@ -180,9 +180,8 @@ function hostnode_click(d) {
urls.forEach(function(url, index, array) { urls.forEach(function(url, index, array) {
var jdata = JSON.parse(url) var jdata = JSON.parse(url)
url_entries.datum({'data': jdata}); url_entries.datum({'data': jdata});
var text_node = text_entry(url_entries, left_margin, top_margin + overlay_header_height + (interval_entries * index), urlnode_click); url_entries.append(d => text_entry(left_margin, top_margin + overlay_header_height + (interval_entries * index), urlnode_click, d));
var height_text = text_node.node().getBBox().height; url_entries.append(d => icon_list(left_margin + 5, top_margin + 20 + overlay_header_height + (interval_entries * index), d));
icon_list(url_entries, left_margin + 5, top_margin + height_text + overlay_header_height + (interval_entries * index));
}); });
var overlay_bbox = overlay_hostname.node().getBBox() var overlay_bbox = overlay_hostname.node().getBBox()
@ -350,8 +349,13 @@ function text_entry(relative_x_pos, relative_y_pos, onclick_callback, d) {
.style("opacity", .9) .style("opacity", .9)
.attr('cursor', 'pointer') .attr('cursor', 'pointer')
.attr("clip-path", "url(#textOverlay)") .attr("clip-path", "url(#textOverlay)")
.text(d.data.name + ' (' + d.data.urls_count + ')'); .text(d => {
// .on('click',onclick_callback); if (d.data.urls_count) {
return d.data.name + ' (' + d.data.urls_count + ')'
}
return d.data.name
})
.on('click',onclick_callback);
return nodeContent.node(); return nodeContent.node();
} }
@ -469,24 +473,23 @@ function update(root, computed_node_width=0) {
}, },
update => update, update => update,
exit => exit exit => exit
// Remove any exiting nodes .transition(t)
.call(exit => exit // Remove any exiting nodes
.transition(t) .attr("transform", node => "translate(" + node.y0 + "," + node.x0 + ")")
.attr("transform", "translate(" + root.y0 + "," + root.x0 + ")") // On exit reduce the node circles size to 0
.remove() .attr('r', 1e-6)
) // On exit reduce the opacity of text labels
// On exit reduce the node circles size to 0 .style('fill-opacity', 1e-6)
.attr('r', 1e-6) .remove()
// On exit reduce the opacity of text labels
.style('fill-opacity', 1e-6)
).call(node => { ).call(node => {
// Transition to the proper position for the node node
node.attr("transform", node => "translate(" + node.y + "," + node.x + ")"); // Transition to the proper position for the node
// Update the node attributes and style .attr("transform", node => "translate(" + node.y + "," + node.x + ")")
node.select('circle.node') // Update the node attributes and style
.attr('r', 10) .select('circle.node')
.style("fill", node => node._children ? "lightsteelblue" : "#fff") .attr('r', 10)
.attr('cursor', 'pointer'); .style("fill", node => node._children ? "lightsteelblue" : "#fff")
.attr('cursor', 'pointer');
}); });
@ -510,21 +513,19 @@ function update(root, computed_node_width=0) {
.insert('path', "g") .insert('path', "g")
.attr("class", "link") .attr("class", "link")
.attr('d', d => { .attr('d', d => {
var o = {x: root.x0, y: root.y0} var o = {x: d.x0, y: d.y0}
return diagonal(o, o) return diagonal(o, o)
}), }),
update => update, update => update,
exit => exit exit => exit
.call(exit => exit .call(exit => exit
.transition(t)
.attr('d', d => { .attr('d', d => {
var o = {x: root.x0, y: root.y0} var o = {x: d.x0, y: d.y0}
return diagonal(o, o) return diagonal(o, o)
}) })
.remove() .remove()
) )
).call(link => link ).call(link => link
//.transition(t)
.attr('d', d => diagonal(d, d.parent)) .attr('d', d => diagonal(d, d.parent))
); );