From 569a6be8000cd2d4639561aedfa9531bd8a4681f Mon Sep 17 00:00:00 2001 From: j Date: Thu, 15 Nov 2018 15:01:29 +0000 Subject: [PATCH] zoom --- ontology/ontology.json | 2 ++ static/html/print.html | 1 + static/ontology/index.css | 6 ++++++ static/ontology/index.html | 4 ++++ static/ontology/index.js | 19 ++++++++++++++++++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ontology/ontology.json b/ontology/ontology.json index df657c9..52cd6fc 100644 --- a/ontology/ontology.json +++ b/ontology/ontology.json @@ -264,6 +264,8 @@ "soup": {}, "tea": {} }, + "tech": { + }, "miscellaneous": { "bicycle": {}, "make-up": {}, diff --git a/static/html/print.html b/static/html/print.html index be06c7e..faf54f9 100644 --- a/static/html/print.html +++ b/static/html/print.html @@ -1,3 +1,4 @@ + diff --git a/static/ontology/index.js b/static/ontology/index.js index bcab5a4..d514a4e 100644 --- a/static/ontology/index.js +++ b/static/ontology/index.js @@ -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 + ')'; })