From 14348435aad5db60e27a9b1c97cd444ca156a43a Mon Sep 17 00:00:00 2001 From: baigner <benedikt.aigner@rwth-aachen.de> Date: Wed, 18 Apr 2018 15:13:48 +0200 Subject: [PATCH] New data structure try 6: Continued interpretation of new tree data in the html file. For edgeBundles and sankeyDiagram still not working Former-commit-id: effcc1bf25edde5c59f2b1c82f80aec979ca23fe --- kadmos/vistoms/templates/VISTOMS.html | 154 +++++++++++++++++++++++--- 1 file changed, 139 insertions(+), 15 deletions(-) diff --git a/kadmos/vistoms/templates/VISTOMS.html b/kadmos/vistoms/templates/VISTOMS.html index 4482a87b2..588e61837 100644 --- a/kadmos/vistoms/templates/VISTOMS.html +++ b/kadmos/vistoms/templates/VISTOMS.html @@ -21328,34 +21328,41 @@ { var treeData = (JSON.parse(JSON.stringify(currentGraph.variableSchemes[aVarCategory]))); //aigner: Here, the minimalized tree is created! - - //aigner: HIER WEITER!!! - //aigner:New implementation start //###################################################################### //Function to prune the tree according to list of xPaths that are actually there - function prune_tree(aPipeData,aTreeData) + function prune_tree(aPipeData,aTreeData,direction="none") { - console.log(aPipeData) - console.log(aTreeData) - var firstEl = aPipeData[0].split("/")[1] + //First, clean up pipeData if necessary + var cleanPipeData = aPipeData.split(",") + var index = cleanPipeData.indexOf(""); + if (index > -1) {cleanPipeData.splice(index, 1);} + var firstEl = cleanPipeData[0].split("/")[1] for (i=0; i < aTreeData.length; ++i) { var treeElement = aTreeData[i]; var relevant_xPath = "/"+firstEl+treeElement.xPath.split(firstEl)[1] - if(aPipeData.indexOf(relevant_xPath)<=-1) + if(cleanPipeData.indexOf(relevant_xPath)<=-1) { aTreeData.splice(i,1); i--; } + else + { + if (direction=="in") + { + aTreeData[i].pipeLineIn = true; + } + else if (direction=="out") + { + aTreeData[i].pipeLineOut = true; + } + } } } //The tree will only be pruned if there is pipeData, such as in an edge or for the input of a tool if (pipeData) { - var cleanPipeData = pipeData.split(",") - var index = cleanPipeData.indexOf(""); - if (index > -1) {cleanPipeData.splice(index, 1);} - prune_tree(cleanPipeData, treeData); + prune_tree(pipeData, treeData); } function childExists(name, children){ @@ -21425,7 +21432,6 @@ buildTree(newTree, treeData) treeData = newTree //###################################################################### - //aigner:New implementation end // Set the dimensions and margins of the diagram var margin = {top: 20, right: 90, bottom: 20, left: 90}, @@ -23616,11 +23622,13 @@ } } - put_xmlPaths_for_all(treeData, "") + //put_xmlPaths_for_all(treeData, "") - if (theLink) + if (false) { + console.log(theLink.name_in) + console.log(theLink.name_out) prune_schema("/"+treeData.name+"/", treeData.children, theLink.name_in, theLink.name_out); //aigner: count all descendants of a node var firstEl = theLink.name.split("/")[1]; @@ -23630,6 +23638,122 @@ for (var i=0; i<cleanOperations; i++){clean_tree(treeData.children);} } } + + ///aigner: HIER WEITER + //aigner: New implementation start + //###################################################################### + var treeData = (JSON.parse(JSON.stringify(schema))); + //aigner: Here, the minimalized tree is created! + + //Function to prune the tree according to list of xPaths that are actually there + function prune_tree(aPipeData,aTreeData,direction="none") + { + //First, clean up pipeData if necessary + var cleanPipeData = aPipeData.split(",") + var index = cleanPipeData.indexOf(""); + if (index > -1) {cleanPipeData.splice(index, 1);} + var firstEl = cleanPipeData[0].split("/")[1] + for (i=0; i < aTreeData.length; ++i) + { + var treeElement = aTreeData[i]; + var relevant_xPath = "/"+firstEl+treeElement.xPath.split(firstEl)[1] + if(cleanPipeData.indexOf(relevant_xPath)<=-1) + { + aTreeData.splice(i,1); + i--; + } + else + { + if (direction=="in") + { + treeElement.pipeLineIn = true; + } + else if (direction=="out") + { + treeElement.pipeLineOut = true; + } + } + } + } + //The tree will only be pruned if there is pipeData, such as in an edge or for the input of a tool + if (theLink) + { + prune_tree(theLink.name_in, treeData, "in"); + prune_tree(theLink.name_in, treeData, "out"); + } + + function childExists(name, children){ + var exists = false + children.forEach(function(child) + { + if (child.name == name) + { + exists = true; + } + }) + return exists; + } + + //Function to create the tree layout by appending children to the layout + function appendChildren(anElement, aParent, xPath_list) + { + if (xPath_list.length > 0) + { + //If element has no children yet, initialize children array + if (!aParent.children){aParent.children = [];} + //Create a new child element, if it does not exist yet + if (!childExists(xPath_list[0], aParent.children)) + { + //Create a new child object + var newChild = {level: aParent.level+1, name: xPath_list[0], type: "variable", xPath: aParent.xPath+"/"+xPath_list[0]}; + aParent.children.push(newChild); + } + aParent.children.forEach(function(aChild) + { + if (xPath_list[0] == aChild.name) + { + let newXPath_list = JSON.parse(JSON.stringify(xPath_list)); + newXPath_list.shift(); + appendChildren(anElement, aChild, newXPath_list) + } + }) + } + else + { + aParent.value = anElement.value; + } + } + + var newTree = {}; + //function builds tree layout from xPaths of the elements + function buildTree(root, aTreeData) + { + aTreeData.forEach(function(treeElement) + { + var xPath_split = treeElement.xPath.split("/"); + var index = xPath_split.indexOf(""); + if (index > -1) {xPath_split.splice(index, 1);} + root.level = 0 + root.name = xPath_split[0] + root.xPath = "/"+xPath_split[0] + <!-- console.log("####################") --> + <!-- console.log(treeElement.xPath) --> + let newXPath_split = JSON.parse(JSON.stringify(xPath_split)); + newXPath_split.shift(); + appendChildren(treeElement, root, newXPath_split) + <!-- console.log("DONE!") --> + <!-- console.log("####################") --> + }) + } + //build tree layout for vistoms + buildTree(newTree, treeData) + treeData = newTree + //###################################################################### + //aigner: New implementation end + + + + var width= 1000; var height= 500; -- GitLab