zoom
This commit is contained in:
parent
0f6e1530c8
commit
569a6be800
5 changed files with 31 additions and 1 deletions
|
|
@ -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 + ')';
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue