This commit is contained in:
j 2018-11-15 15:01:29 +00:00
commit 569a6be800
5 changed files with 31 additions and 1 deletions

View file

@ -51,6 +51,22 @@ function resize() {
update(root);
}
function zoom(size) {
height = size;
tree.size([height, width]);
svg.attr("width", width).attr("height", height + margin.top + margin.bottom)
document.querySelector('svg').attributes.height.value = height + margin.top + margin.bottom
resize()
}
document.querySelector('.zoom button.plus').addEventListener('click', function(event) {
zoom(height*1.5)
})
document.querySelector('.zoom button.minus').addEventListener('click', function(event) {
zoom(height/1.5)
})
function get_color(d) {
if (d.children || d._children) {
@ -95,7 +111,8 @@ function update(source) {
})
.text(function(d) {
if (d.children || d._children) {
return d.name;
//return d.name;
return d.name + '(' + (d.children || d._children).length +')';
}
return d.name + ' (' + d.size + ')';
})