From 42ceb56dab45babf9049dfdefdf00314762baa23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?FEL=C5=A0=C3=96CI=20Marek?= <marek.felsoci@inria.fr> Date: Mon, 6 Nov 2023 04:52:23 +0100 Subject: [PATCH] Remove unused tools --- tools/js-hmat/index.html | 117 ------- tools/js-hmat/parse_hmat_json.js | 218 ------------- tools/js-perf/index.html | 139 -------- tools/js-perf/parse_spido_perf_reports.js | 86 ----- tools/js-perf/tree.js | 379 ---------------------- 5 files changed, 939 deletions(-) delete mode 100644 tools/js-hmat/index.html delete mode 100644 tools/js-hmat/parse_hmat_json.js delete mode 100644 tools/js-perf/index.html delete mode 100644 tools/js-perf/parse_spido_perf_reports.js delete mode 100644 tools/js-perf/tree.js diff --git a/tools/js-hmat/index.html b/tools/js-hmat/index.html deleted file mode 100644 index 1c9b269..0000000 --- a/tools/js-hmat/index.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<style type="text/css"> - .box { - background-color: #000; - color: #ffffff; - opacity: .8; - padding:10px; - box-shadow: rgba(0,0,0,0.2) 0px 2px 3px, inset rgba(0,0,0,0.2) 0px -1px 2px; - border-radius: 5px; - padding:10px; - font-family: Helvetica; - font-size: 14pt; - } - - #legend { - position: absolute; - right: 10px; - top: 10px; - opacity: .0; - display: none; - width: 250px; - z-index:10; - } - - #report-selector-box { - position: absolute; - right: 10px; - top: 10px; - opacity: .0; - display: none; - } - - #node-name { - position: fixed; - top: 0; - left: 0; - width: 100%; - padding: 5px; - text-align: center; - border-radius: 0px; - } - -#file-selector-box { - position: absolute; - left: 10px; - top: 10px; - } - - #hmat-container { - position: absolute; - width: 100%; - height: 100%; - } -</style> - -<body> - <div id="hmat-container"></div> - <div id="legend" class="box"> - <table style="font-size: 12pt"> - <tr> - <td>Leaf Type</td> - <td><b id="leaf-type"></b></td> - </tr> - <tr> - <td>Rows</td> - <td><b id="rows-count"></b></td> - </tr> - <tr> - <td>Cols</td> - <td><b id="cols-count"></b></td> - </tr> - <tr> - <td>Rank</td> - <td><b id="rank"></b></td> - </tr> - <tr> - <td>Compression Ratio</td> - <td><b id="compression-ratio"></b></td> - </tr> - <tr> - <td>Compression Method</td> - <td><b id="compression-method"></b></td> - </tr> - </table> - </div> - <div id="file-selector-box" class="box"> - Fichier: - <input type="file" id="file-input"/> - </div> - - <script src="../js/lib/jquery-1.10.2.min.js"></script> - <script src="../js/lib/d3.v3.min.js"></script> - <script src="../js/draggable.js"></script> - <script src="parse_hmat_json.js"></script> - <script> - document.getElementById('file-input') - .addEventListener('change', - function (e) { - var file = e.target.files[0]; - if (!file) { - return; - } - var reader = new FileReader(); - reader.onload = function (e) { - $('#file-selector-box').animate({opacity: 0}, 700, - function() {$('#file-selector-box').hide()}); - var contents = e.target.result; - Hmat.parseHmatJson(contents); - Hmat.drawHMatrix("#hmat-container", Hmat.highlightNode); - } - reader.readAsText(file); - }, false); - $("#legend").drags(); - </script> -</body> -</html> diff --git a/tools/js-hmat/parse_hmat_json.js b/tools/js-hmat/parse_hmat_json.js deleted file mode 100644 index 9938027..0000000 --- a/tools/js-hmat/parse_hmat_json.js +++ /dev/null @@ -1,218 +0,0 @@ -Hmat = (function () { - var hmat = null; - - function isEmpty(obj) { - return Object.keys(obj).length === 0; - } - - function setHMat(m) { - hmat = m; - } - function parseHmatJson(jsonData) { - hmat = JSON.parse(jsonData); - } - - function findNodeAtCoords(x, y, node) { - function isInMe(node, x, y) { - var rows = node.rows, cols = node.cols; - if ((x >= cols.offset) && (x < cols.offset + cols.n) - && (y >= rows.offset) && (y < rows.offset + rows.n)) { - return true; - } else { - return false; - } - } - if (node === undefined) - node = hmat.tree; - if (node.isLeaf) { - return node; - } else { - for (var i = 0; i < node.children.length; i++) { - if (!isEmpty(node.children[i]) && isInMe(node.children[i], x, y)) { - return findNodeAtCoords(x, y, node.children[i]); - } - } - return null; - } - } - - var svgGroup = null; - // For the highlight - var currentNode = null; - var highlight = null; - var highlightText = null; - - function zoom() { - svgGroup.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); - } - var zoomListener = d3.behavior.zoom().on("zoom", zoom); - var scale = null; - - /** - * Draw the HMatrix to a given element. - * The HMatrix is zoomable. - * @param elementId - * @param onMouseMove - */ - function drawHMatrix(elementId, onMouseMove, nodeStyle) { - var xSize = $(elementId).width(), ySize = $(elementId).height(); - var svg = d3.select(elementId).append("svg") - .attr("width", xSize) - .attr("height", ySize) - .call(zoomListener); - if (onMouseMove) { - svg.on("click", onMouseMove); - } - svgGroup = svg.append("g"); - var dofCount = hmat.tree.rows.n; - scale = .95 * Math.min(xSize, ySize) / dofCount; - - svgGroup.append("rect").attr("x", 0).attr("y", 0) - .attr("width", dofCount * scale) - .attr("height", dofCount * scale) - .attr("stroke-width", 1) - .attr("stroke", "black") - .attr("fill", "none"); - highlight = svgGroup.append("rect").attr("x", 0).attr("y", 0) - .attr("width", 0) - .attr("height", 0) - .attr("fill", "green") - .attr("opacity", .8); - highlightText = svgGroup.append("text") - .attr('x', 0) - .attr('y', 0) - .attr('fill', 'black') - .attr('font-size', 0.); - function cross(startX, startY, middleX, middleY, xLength, yLength) { - svgGroup.append("line") - .attr("x1", scale * startX) - .attr("y1", scale * middleY) - .attr("x2", scale * (startX + xLength)) - .attr("y2", scale * middleY) - .attr("stroke-width", 1) - .attr("stroke", "black"); - svgGroup.append("line") - .attr("x1", scale * middleX) - .attr("y1", scale * startY) - .attr("x2", scale * middleX) - .attr("y2", scale * (startY + yLength)) - .attr("stroke-width", 1) - .attr("stroke", "black"); - } - function recursiveDraw(node) { - if (!node || isEmpty(node)) return; - if (node.isLeaf) { - var rect = svgGroup.append("rect"); - if (node.leaf_type == "Full") { - rect.attr("x", scale * node.cols.offset) - .attr("y", scale * node.rows.offset) - .attr("width", scale * node.cols.n) - .attr("height", scale * node.rows.n) - .attr("stroke", "black") - .attr("fill", "red"); - } else { - rect.attr("x", scale * node.cols.offset) - .attr("y", scale * node.rows.offset) - .attr("width", scale * node.cols.n) - .attr("height", scale * node.rows.n) - .attr("stroke", "black") - .attr("fill", "gray") - .attr("fill-opacity", node.method ? 0.2 + 0.15 * node.method : 0) - } - if(nodeStyle) - nodeStyle(hmat, node, rect); - return; - } - var startX = node.cols.offset; - var xLength = node.cols.n; - var startY = node.rows.offset; - var yLength = node.rows.n; - if (node.children.length > 2 && !isEmpty(node.children[1]) && !isEmpty(node.children[2])) { - var middleX = node.children[2].cols.offset; - var middleY = node.children[1].rows.offset; - cross(startX, startY, middleX, middleY, xLength, yLength); - } - for (var i = 0; i < node.children.length; i++) { - recursiveDraw(node.children[i]); - } - } - recursiveDraw(hmat.tree); - return svgGroup; - } - - /** - * Convert the coordinates of a mouse event to the DOF space. - * @param x - * @param y - * @return - */ - function toDofCoords(x, y) { - var displayTranslation = zoomListener.translate(); - var displayScale = zoomListener.scale(); - return [ - (x - displayTranslation[0]) / displayScale / scale, - (y - displayTranslation[1]) / displayScale / scale]; - } - - /** Convert the coordinated from the DOF space to the figure. */ - function fromDofCoords(x, y) { - return [x * scale, y * scale]; - } - - var firstTime = true; - function highlightNode(d, i, callback) { - var coords = d3.mouse(this); - var dofCoords = toDofCoords(coords[0], coords[1]); - var node = findNodeAtCoords(dofCoords[0], dofCoords[1]); - if (!node || (node == currentNode)) { - return; - } - currentNode = node; - figureCoords = fromDofCoords(node.cols.offset, node.rows.offset); - highlight.transition(1000) - .attr("x", figureCoords[0]) - .attr("y", figureCoords[1]) - .attr("width", scale * node.cols.n) - .attr("height", scale * node.rows.n) - .attr("text", "Hello"); - highlightText.transition(1000).text(node.leaf_type == "Rk" ? node.k : "") - .attr('x', figureCoords[0]) - .attr('y', figureCoords[1] + .9 * scale * node.rows.n) - .attr('fill', 'black') - .attr('font-size', .9 * scale * node.rows.n + "px"); - if (callback) { - callback(node); - } - $('#leaf-type').text(node.leaf_type); - $('#rows-count').text(node.rows.n+" ["+node.rows.offset+","+(node.rows.offset+node.rows.n-1)+"]"); - $('#cols-count').text(node.cols.n+" ["+node.cols.offset+","+(node.cols.offset+node.cols.n-1)+"]"); - var methodNames = ["SVD", "Aca Full", "ACA Partial", "ACA+", "None"]; - if (node.leaf_type == "Rk") { - $('#rank').text(node.k); - var compressionRatio = (node.k * (node.cols.n + node.rows.n)) / ((node.cols.n * node.rows.n)); - $('#compression-ratio').text((100 * compressionRatio).toFixed(3) + "%"); - $('#compression-method').text(node.method ? methodNames[node.method] : "N/A"); - } else { - $('#rank').text("N/A"); - $('#compression-ratio').text("N/A"); - $('#compression-method').text("N/A"); - } - if (firstTime) { - firstTime = false; - $('#legend').show(); - $('#legend').animate({opacity: 0.8}, 700, function() {}); - } - } - - // Public functions - return { - parseHmatJson: parseHmatJson, - findNodeAtCoords: findNodeAtCoords, - drawHMatrix: drawHMatrix, - toDofCoords: toDofCoords, - fromDofCoords: fromDofCoords, - highlightNode: highlightNode, - setHMat: setHMat - } -}()); - diff --git a/tools/js-perf/index.html b/tools/js-perf/index.html deleted file mode 100644 index c687a37..0000000 --- a/tools/js-perf/index.html +++ /dev/null @@ -1,139 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<style type="text/css"> - .node { - cursor: pointer; - } - - .node circle { - fill: #fff; - stroke: steelblue; - stroke-width: 1.5px; - } - - .node text { - font-size:10px; - font-family:sans-serif; - font-weight: bold; - } - - .link { - fill: none; - stroke: #ccc; - stroke-width: 1.5px; - } - - .templink { - fill: none; - stroke: red; - stroke-width: 3px; - } - - .box { - background-color: #000; - color: #ffffff; - opacity: .8; - padding:10px; - box-shadow: rgba(0,0,0,0.2) 0px 2px 3px, inset rgba(0,0,0,0.2) 0px -1px 2px; - border-radius: 5px; - padding:10px; - font-family: Helvetica; - font-size: 14pt; - } - - #legend { - position: absolute; - left: 10px; - top: 40px; - opacity: .0; - display: none; - max-width: 30%; - min-width: 250px; - } - - #report-selector-box { - position: absolute; - right: 10px; - top: 40px; - opacity: .0; - display: none; - } - - #node-name { - position: fixed; - top: 0; - left: 0; - width: 100%; - padding: 5px; - text-align: center; - border-radius: 0px; - } - - #file-selector-box { - position: absolute; - left: 10px; - top: 40px; - } -</style> - -<body> - <div id="node-name" class="box">Report Visualizer</div> - <div id="tree-container" style="float:left"></div> - <div id="legend" class="box"> - <table style="font-size: 12pt"> - <tr> - <td>Total Time (s)</td> - <td><b id="node-total-time"></b></td> - </tr> - <tr> - <td>Spent in children (s)</td> - <td><b id="node-children-time"></b><b> (</b><b id="node-children-percentage"></b><b>)</b></td> - </tr> - <tr> - <td>Of parent time</td> - <td><b id="node-parent-percentage"></b></td> - </tr> - <tr> - <td>Calls count</td> - <td><b id="node-calls-count"></b></td> - </tr> - <tr> - <td>Flops (/s)</td> - <td><b id="node-flops"></b></td> - </tr> - <tr> - <td>Bytes Received</td> - <td><b id="node-bytes-received"></b></td> - </tr> - <tr> - <td>Bytes Sent</b></td> - <td><b id="node-bytes-sent"></b></td> - </tr> - <tr> - <td>Communications (% of total)</td> - <td><b id="node-comm-time"></b></td> - </tr> - </table> - </div> - <div id="file-selector-box" class="box"> - Fichier: - <input type="file" id="file-input"/> - </div> - - <div id="report-selector-box" class="box"> - Choix du rapport: - <select id="report-selector" onChange="Reports.selectReport()"></select> - <button onClick="PerfTree.toggleFirstLevel()">Hide/Show</button> - </div> - - <script src="../js/lib/jquery-1.10.2.min.js"></script> - <script src="../js/lib/d3.v3.min.js"></script> - <script src="../js/draggable.js"></script> - <script src="parse_spido_perf_reports.js"></script> - <script src="tree.js"></script> - - <script> - $('#legend').drags(); - </script> -</body> -</html> diff --git a/tools/js-perf/parse_spido_perf_reports.js b/tools/js-perf/parse_spido_perf_reports.js deleted file mode 100644 index a032e7e..0000000 --- a/tools/js-perf/parse_spido_perf_reports.js +++ /dev/null @@ -1,86 +0,0 @@ -function computeSums(node) { - var children = node.children; - if (node.childrenSums == null) { - node.childrenSums = {totalTime: 0, flops: node.totalFlops, - bytesSent: node.totalBytesSent, - bytesReceived: node.totalBytesReceived, - commTime: node.totalCommTime}; - for (var i = 0; i < children.length; i++) { - var childSum = computeSums(children[i]); - node.childrenSums.totalTime += childSum.totalTime; - node.childrenSums.flops += childSum.flops; - node.childrenSums.bytesSent += childSum.bytesSent; - node.childrenSums.bytesReceived += childSum.bytesReceived; - node.childrenSums.commTime += childSum.commTime; - } - } - return node.childrenSums; -} - - -/* Compute various stats for a given node */ -function computeData(node) { - node.childrenSums = null; - var children = node.children; - - if (!node.parent) { - node.totalTime = 0; - for (var i = 0; i < node.children.length; i++) { - node.totalTime += node.children[i].totalTime; - } - } - - for (var i = 0; i < children.length; i++) { - computeData(children[i]); - } - computeSums(node); - - // Percentage of time of the parent - if (node.parent) { - node.percentageOfParentTime = 100 * node.totalTime / node.parent.totalTime; - } else { - node.percentageOfParentTime = 100; - } - node.percentageOfTimeInChildren = 100 * node.childrenSums.totalTime / node.totalTime; - node.percentageOfSelfTime = 100 - node.percentageOfTimeInChildren; -} - -/* Parse a single JSON report */ -function parseReport(report) { - function addParent(node, parent) { - node.parent = parent; - node.children.forEach(function(child) {addParent(child, node)}); - } - if (!report.parent) { - addParent(report); - } - computeData(report); - return report; -} - -/* Parse an array of JSON reports */ -function parseReports(reports) { - var result = []; - for (var i = 0; i < reports.length; i++) { - result.push(parseReport(reports[i])); - } - return result; -} - -function prettyPrintValue(value, precision) { - var suffix = ""; - if (value > 1e12) { - value /= 1e12; - suffix = "T"; - } else if (value > 1e9) { - value /= 1e9; - suffix = "G"; - } else if (value > 1e6) { - value /= 1e6; - suffix = "M"; - } else if (value > 1e3) { - value /= 1e3; - suffix = "k"; - } - return value.toFixed(precision) + suffix; -} diff --git a/tools/js-perf/tree.js b/tools/js-perf/tree.js deleted file mode 100644 index 7e806c5..0000000 --- a/tools/js-perf/tree.js +++ /dev/null @@ -1,379 +0,0 @@ -var PerfTree = function(){ - var highlightedNode = null; - // Calculate total nodes, max label length - var totalNodes = 0; - var maxLabelLength = 0; - // Misc. variables - var i = 0; - var duration = 750; - var root; - - // size of the diagram - var viewerWidth = $(document).width(); - var viewerHeight = $(document).height(); - - var tree = d3.layout.tree() - .separation(function(a, b) { return 3; }); - //.size([viewerHeight, viewerWidth]); - - // define a d3 diagonal projection for use by the node paths later on. - var diagonal = d3.svg.diagonal() - .projection(function(d) { - return [d.x, d.y]; - }); - - // A recursive helper function for performing some setup by walking through all nodes - function visit(parent, visitFn, childrenFn) { - if (!parent) return; - - visitFn(parent); - - var children = childrenFn(parent); - if (children) { - var count = children.length; - for (var i = 0; i < count; i++) { - visit(children[i], visitFn, childrenFn); - } - } - } - - // Define the zoom function for the zoomable tree - - function zoom() { - svgGroup.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); - } - - - // define the zoomListener which calls the zoom function on the "zoom" event constrained within the scaleExtents - var zoomListener = d3.behavior.zoom().scaleExtent([0.1, 3]).on("zoom", zoom); - - // define the baseSvg, attaching a class for styling and the zoomListener - var baseSvg = d3.select("#tree-container").append("svg") - .attr("width", viewerWidth) - .attr("height", viewerHeight) - .attr("class", "overlay") - .call(zoomListener); - - // Helper functions for collapsing and expanding nodes. - function collapse(d) { - if (d.children) { - d._children = d.children; - d._children.forEach(collapse); - d.children = null; - } - } - - function expand(d) { - if (d._children) { - d.children = d._children; - d.children.forEach(expand); - d._children = null; - } - } - - // Function to center node when clicked/dropped so node doesn't get lost when collapsing/moving with large amount of children. - function centerNode(source) { - scale = zoomListener.scale(); - x = -source.x0; - y = -source.y0; - x = x * scale + viewerWidth / 2; - y = y * scale + viewerHeight / 2; - d3.select('g').transition() - .duration(duration) - .attr("transform", "translate(" + x + "," + y + ")scale(" + scale + ")"); - zoomListener.scale(scale); - zoomListener.translate([x, y]); - } - - // Toggle children function - function toggleChildren(d) { - if (d.children) { - d._children = d.children; - d.children = null; - } else if (d._children) { - d.children = d._children; - d._children = null; - } - return d; - } - - function recursivelyHideChildren(d) { - if (d.children) { - d._children = d.children; - d.children = null; - for (var i = 0; i < d._children.length; i++) { - recursivelyHideChildren(d._children[i]); - } - } - return d; - } - - // Toggle children on click. - function click(d) { - if (d3.event.defaultPrevented) return; // click suppressed - d = toggleChildren(d); - update(d); - } - - function update(source) { - // Color range for the nodes. - var color = d3.scale.linear().domain([0, 100]).range(["blue", "red"]); - // Compute the new height, function counts total children of root node and sets tree height accordingly. - // This prevents the layout looking squashed when new nodes are made visible or looking sparse when nodes are removed - // This makes the layout more consistent. - radius = 20; - var levelWidth = [1]; - var childCount = function(level, n) { - - if (n.children && n.children.length > 0) { - if (levelWidth.length <= level + 1) levelWidth.push(0); - - levelWidth[level + 1] += n.children.length; - n.children.forEach(function(d) { - childCount(level + 1, d); - }); - } - }; - childCount(0, root); - var newWidth = Math.min(d3.max(levelWidth) * radius * 4, 20 * viewerWidth); - var newHeight = Math.min(levelWidth.length * 100, 3 * viewerHeight); - tree = tree.size([newWidth, newHeight]).separation(function(a, b) {return 3;}); - - // Compute the new tree layout. - var nodes = tree.nodes(root).reverse(), - links = tree.links(nodes); - - // Update the nodes… - node = svgGroup.selectAll("g.node") - .data(nodes, function(d) { - return d.id || (d.id = ++i); - }); - - // Enter any new nodes at the parent's previous position. - var nodeEnter = node.enter().append("g") - .attr("class", "node") - .attr("transform", function(d) { - return "translate(" + source.x0 + "," + source.y0 + ")"; - }) - .on('click', click); - - nodeEnter.append("circle") - .attr('class', 'nodeCircle') - .attr("r", 0) - .style("fill", function(d) { - // return d._children ? "lightsteelblue" : "#fff"; - return color(d.percentageOfParentTime); - }); - nodeEnter.append("svg:title").text(function(d) {return d["name"]}); - nodeEnter.append("text") - .attr("x", function(d) { - return 0; //d.children || d._children ? -20 : 20; - }) - .attr("dy", ".35em") - .attr('class', 'nodeText') - .attr("text-anchor", function(d) { - return "middle"; - }) - .text(function(d) { - return d.totalTime.toFixed(2); - }) - .style("fill-opacity", 0); - - // phantom node to give us mouseover in a radius around it - nodeEnter.append("circle") - // .attr('class', 'ghostCircle') - .attr("r", radius * 1.5) - .attr("opacity", 0) // change this to zero to hide the target area - .style("fill", function(node) { - return color(node.percentageOfParentTime); - }) - .on("mouseover", function(node) { - var firstTime = false; - if (highlightedNode) { - highlightedNode.transition().duration(300).style("opacity", 0); - } else { - firstTime = true; - } - highlightedNode = d3.select(this); - d3.select(this).transition().duration(300).style("opacity", .5); - - $('#node-name').text(node.name); - $('#node-total-time').text(node.totalTime.toFixed(3)); - $('#node-children-time').text(node.childrenSums.totalTime.toFixed(3)); - $('#node-children-percentage').text(node.percentageOfTimeInChildren.toFixed(2) + "%"); - $('#node-parent-percentage').text(node.percentageOfParentTime.toFixed(2) + "%"); - $('#node-calls-count').text(node.n); - $('#node-flops').text(prettyPrintValue(node.childrenSums.flops, 2) + " (" + prettyPrintValue(node.childrenSums.flops / node.totalTime, 2) + "Flops)"); - $('#node-bytes-sent').text(node.childrenSums.bytesSent); - $('#node-bytes-received').text(node.childrenSums.bytesReceived); - $('#node-comm-time').text(node.childrenSums.commTime); - - if (firstTime) { - $('#legend').show(); - $('#legend').animate({opacity: 0.8}, 700, function() {}); - } - }); - - // Change the circle fill depending on whether it has children and is collapsed - node.select("circle.nodeCircle") - .attr("r", 20) - .style("fill", function(d) { - return color(node.percentageOfParentTime); - // return d._children ? "lightsteelblue" : "#fff"; - }) - .style("stroke", function(node) { - return node._children ? "red" : "black"; - }); - - // Transition nodes to their new position. - var nodeUpdate = node.transition() - .duration(duration) - .attr("transform", function(d) { - return "translate(" + d.x + "," + d.y + ")"; - }); - - // Fade the text in - nodeUpdate.select("text") - .style("fill-opacity", 1); - - // Transition exiting nodes to the parent's new position. - var nodeExit = node.exit().transition() - .duration(duration) - .attr("transform", function(d) { - return "translate(" + source.x + "," + source.y + ")"; - }) - .remove(); - - nodeExit.select("circle") - .attr("r", 0); - - nodeExit.select("text") - .style("fill-opacity", 0); - - // Update the links… - var link = svgGroup.selectAll("path.link") - .data(links, function(d) { - return d.target.id; - }); - - // Enter any new links at the parent's previous position. - link.enter().insert("path", "g") - .attr("class", "link") - .attr("d", function(d) { - var o = { - x: source.x0, - y: source.y0 - }; - return diagonal({ - source: o, - target: o - }); - }); - - // Transition links to their new position. - link.transition() - .duration(duration) - .attr("d", diagonal); - - // Transition exiting nodes to the parent's new position. - link.exit().transition() - .duration(duration) - .attr("d", function(d) { - var o = { - x: source.x, - y: source.y - }; - return diagonal({ - source: o, - target: o - }); - }) - .remove(); - - // Stash the old positions for transition. - nodes.forEach(function(d) { - d.x0 = d.x; - d.y0 = d.y; - }); - - if (newWidth > viewerWidth || newHeight > viewerHeight) { - var newScale = Math.min(viewerWidth / newWidth, viewerHeight / newHeight); - d3.select('g').transition() - .duration(1500) - .attr("transform", "scale(" + newScale + ")"); - zoomListener.scale(newScale); - centerNode(source); - } - if (newWidth < .1 * viewerWidth || newHeight < .1 * viewerHeight) { - var newScale = Math.min(.5 * viewerWidth / newWidth, .5 * viewerHeight / newHeight); - d3.select('g').transition() - .duration(1500) - .attr("transform", "scale(" + newScale + ")"); - zoomListener.scale(newScale); - centerNode(source); - } - } - - // Append a group which holds all nodes and which the zoom Listener can act upon. - var svgGroup = baseSvg.append("g"); - - // Public functions - return { - showReport: function(report) { - root = report; - root.x0 = viewerHeight / 2; - root.y0 = 0; - // Layout the tree initially and center on the root node. - update(root); - }, - toggleFirstLevel: function() { - root.children.forEach(function(child) { - recursivelyHideChildren(child); - // toggleChildren(child); - }); - update(root); - } - } -}(); - - -var Reports = function() { - var reports = null; - - function loadReports(fileContent) { - var jsonData = JSON.parse(fileContent); - reports = parseReports(jsonData); - var selectMenu = document.getElementById("report-selector"); - for (var i = 0; i < reports.length; i++) { - var option = document.createElement("option"); - option.text = reports[i].name; - selectMenu.add(option); - } - $('#report-selector-box').show().animate({opacity: 0.8}, 700, function() {}); - PerfTree.showReport(reports[0]); - } - - function openReportsFile(e) { - var file = e.target.files[0]; - if (!file) { - return; - } - var reader = new FileReader(); - reader.onload = function (e) { - var contents = e.target.result; - loadReports(contents); - $('#file-selector-box').animate({opacity: 0}, 700, - function() {$('#file-selector-box').hide()}); - } - reader.readAsText(file); - } - document.getElementById('file-input') - .addEventListener('change', openReportsFile, false); - - return { - selectReport: function(index) { - var selectBox = document.getElementById("report-selector"); - PerfTree.showReport(reports[selectBox.selectedIndex]); - } - } -}() -- GitLab