Skip to content
Snippets Groups Projects
Commit 14348435 authored by baigner's avatar baigner
Browse files

New data structure try 6: Continued interpretation of new tree data in the...

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
parent 0b9e1fbb
No related branches found
No related tags found
No related merge requests found
......@@ -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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment