From fbf14e0c713592e30ecaae1cabfe494b5b4424d5 Mon Sep 17 00:00:00 2001 From: Angelos Chatzimparmpas Date: Sun, 9 Aug 2020 14:54:20 +0200 Subject: [PATCH] new collapsible --- __pycache__/run.cpython-37.pyc | Bin 18569 -> 18497 bytes .../src/components/FeatureSpace1 copy.vue | 659 ++++++++++++++++++ frontend/src/components/FeatureSpace1.vue | 138 +++- frontend/src/components/FeatureSpace2.vue | 11 - frontend/src/components/FeatureSpace3.vue | 11 - frontend/src/components/FeatureSpace4.vue | 11 - run.py | 6 +- 7 files changed, 772 insertions(+), 64 deletions(-) create mode 100644 frontend/src/components/FeatureSpace1 copy.vue diff --git a/__pycache__/run.cpython-37.pyc b/__pycache__/run.cpython-37.pyc index a8d727869f7e770ab5ab835360e0f5b35b82929d..f6f80ee809710f0693d7c6f40e3c0cbba89ef98a 100644 GIT binary patch delta 143 zcmeC2$aru9Bd-%LFBbz4%yiR@m)po&sl@bveRGErkXWI0pPeyea);47MyAQ-#u=NR z8|!j1icJ=^ZDA5;p1e>ynMndnF-lHOvFl*epZwOYn$c}?rhPtR?Btt3vShQT!*V9Z r$D2Poi7+wlpUmbuneoKrS*|^d7dNZBg)?#c@iEHOGsH-7N^t@J&a5q- delta 205 zcmX>&fw6NUBd-%LFBbz4T>GIN|7;^~r4o|@$L0>D2kaILBubDIAim4V^dB>smW(;T9~AnCnstrGs%D{M%l?S zb{$N{%#(NNq)q0r7h&|8tZ1Llm^gVNkgV9u=&+oL@%iSJP9jWKS6BIHfoNC4oNc diff --git a/frontend/src/components/FeatureSpace1 copy.vue b/frontend/src/components/FeatureSpace1 copy.vue new file mode 100644 index 0000000..2a39d61 --- /dev/null +++ b/frontend/src/components/FeatureSpace1 copy.vue @@ -0,0 +1,659 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/FeatureSpace1.vue b/frontend/src/components/FeatureSpace1.vue index 4cce411..6bd91df 100644 --- a/frontend/src/components/FeatureSpace1.vue +++ b/frontend/src/components/FeatureSpace1.vue @@ -19,6 +19,10 @@ export default { dataFS1: [], dataFS1Trans: [], jsonData: [], + corrMatrixComb: [], + corrMatrixCombTotal: [], + VIFRemaining: [], + MIRemaining: [], } }, methods: { @@ -33,8 +37,17 @@ export default { var outcome var countLoc + var corrMatrixCombLoc =[] + var corrMatrixCombTotalLoc = [] + var VIFRemainingLoc = [] + var MIRemainingLoc = [] + this.dataFS1Trans.forEach(function(element, index) { var round = element.round + corrMatrixCombLoc.push(Object.values(JSON.parse(round[4]))) + corrMatrixCombTotalLoc.push(Object.values(JSON.parse(round[8]))[0] * 100) + VIFRemainingLoc.push(Object.values(JSON.parse(round[12]))[0]) + MIRemainingLoc.push(JSON.parse(round[16])) round = JSON.parse(round[0]) oldVal = 0 newVal = 0 @@ -55,6 +68,10 @@ export default { pushEach.push({keyIns: "round", valueIns: outcome}) var roundLogE = element.roundLogE + corrMatrixCombLoc.push(Object.values(JSON.parse(roundLogE[4]))) + corrMatrixCombTotalLoc.push(Object.values(JSON.parse(roundLogE[8]))[0] * 100) + VIFRemainingLoc.push(Object.values(JSON.parse(roundLogE[12]))[0]) + MIRemainingLoc.push(JSON.parse(roundLogE[16])) roundLogE = JSON.parse(roundLogE[0]) oldVal = 0 newVal = 0 @@ -74,6 +91,10 @@ export default { pushEach.push({keyIns: "roundLogE", valueIns: outcome}) var roundLog2 = element.roundLog2 + corrMatrixCombLoc.push(Object.values(JSON.parse(roundLog2[4]))) + corrMatrixCombTotalLoc.push(Object.values(JSON.parse(roundLog2[8]))[0] * 100) + VIFRemainingLoc.push(Object.values(JSON.parse(roundLog2[12]))[0]) + MIRemainingLoc.push(JSON.parse(roundLog2[16])) roundLog2 = JSON.parse(roundLog2[0]) oldVal = 0 newVal = 0 @@ -93,6 +114,10 @@ export default { pushEach.push({keyIns: "roundLog2", valueIns: outcome}) var roundLog10 = element.roundLog10 + corrMatrixCombLoc.push(Object.values(JSON.parse(roundLog10[4]))) + corrMatrixCombTotalLoc.push(Object.values(JSON.parse(roundLog10[8]))[0] * 100) + VIFRemainingLoc.push(Object.values(JSON.parse(roundLog10[12]))[0]) + MIRemainingLoc.push(JSON.parse(roundLog10[16])) roundLog10 = JSON.parse(roundLog10[0]) oldVal = 0 newVal = 0 @@ -113,14 +138,16 @@ export default { pushEachFinal.push({key: listofNodes[index], value: pushEach}) }) + this.corrMatrixComb = [...corrMatrixCombLoc] + this.corrMatrixCombTotal = [...corrMatrixCombTotalLoc] + this.VIFRemaining = [...VIFRemainingLoc] + this.MIRemaining = [...MIRemainingLoc] + var nodes = [] + var groupID = 0 listofNodes.forEach( function(element) { - nodes.push({"name": element, "children": [ - {"name": element+"_round"}, - {"name": element+"_roundLogE"}, - {"name": element+"_roundLog2"}, - {"name": element+"_roundLog10"}, - ]}) + groupID++ + nodes.push({"name": element, "group": groupID+"_root"}) }) var links = [] @@ -130,12 +157,35 @@ export default { Object.entries(value).forEach( function ([featureInside, value]) { if (feature != featureInside) { if (value >= 0) { - links.push({"source": listofNodes.indexOf(feature), "target": listofNodes.indexOf(featureInside), "value": Math.abs(value) * 30}) + links.push({"source": listofNodes.indexOf(feature), "target": listofNodes.indexOf(featureInside), "value": Math.abs(value) * 30, "lin_color": "#D3D3D3"}) } } }) }) + groupID = 0 + listofNodes.forEach( function(element) { + groupID++ + nodes.push( + {"name": element+"_r", "group": groupID}, + {"name": element+"_r_E", "group": groupID}, + {"name": element+"_r_2", "group": groupID}, + {"name": element+"_r_10", "group": groupID}, + ) + }) + + Object.entries(pushEachFinal).forEach( + function ([index, feature]) { + feature.value.forEach(function (element, indexIns) { + if (element.valueIns > 0) { + links.push({"source": index, "target": index*feature.value.length+feature.value.length+indexIns, "value": Math.abs(element.valueIns) * 30, "lin_color": "#4393c3"}) + } + else { + links.push({"source": index, "target": index*feature.value.length+feature.value.length+indexIns, "value": Math.abs(element.valueIns) * 30, "lin_color": "#d6604d"}) + } + }) + }) + this.jsonData = {"nodes": nodes, "links": links}; this.graphVizualization() @@ -149,7 +199,7 @@ export default { var corrGlob = JSON.parse(this.dataFS1[10]) var VIFVar = JSON.parse(this.dataFS1[18]) var MIVar = JSON.parse(this.dataFS1[22]) - + MIVar = MIVar.concat(this.MIRemaining) var colorCateg = d3.scaleOrdinal(d3.schemeAccent) var corrTargetFormatted = [] @@ -163,6 +213,16 @@ export default { corrTargetFormatted.push(corrTargetFormattedLoc) } + for (let j = 0; j < uniqueTarget.length; j++) { + for (let i = 0; i < Object.keys(this.corrMatrixComb).length; i++) { + if (Math.round(Object.values((Object.values(this.corrMatrixComb[i])[j]))[0] * 100) == null) { + corrTargetFormatted[j].push(0) + } else { + corrTargetFormatted[j].push(Math.round(Object.values((Object.values(this.corrMatrixComb[i])[j]))[0] * 100)) + } + } + } + var corrGlobFormatted = [] for (let i = 0; i < Object.keys(corrGlob).length; i++) { if (i != 0) { @@ -170,6 +230,10 @@ export default { } } + for (let i = 0; i < this.corrMatrixCombTotal.length; i++) { + corrGlobFormatted.push(Math.round(this.corrMatrixCombTotal[i])) + } + var VIFVarFormatted = [] for (let i = 0; i < Object.keys(VIFVar).length; i++) { if (i != 0) { @@ -183,6 +247,16 @@ export default { } } + for (let i = 0; i < this.VIFRemaining.length; i++) { + if (this.VIFRemaining[i] > 10) { + VIFVarFormatted.push(4) + } else if (this.VIFRemaining[i] > 5) { + VIFVarFormatted.push(2) + } else { + VIFVarFormatted.push(0) + } + } + function min(input) { if (toString.call(input) !== "[object Array]") return false; @@ -207,14 +281,14 @@ export default { MIVar = MIVar.map(normalize(MIMin, MIMax)) - var colorsScaleNodes = d3.scaleLinear() - .domain([MIMin, MIMax]) - .range(['#a6bddb','#74a9cf','#3690c0','#0570b0','#045a8d','#023858']); + var colorsScaleNodes = d3.scaleOrdinal() + .domain(d3.ticks([MIMin, MIMax, 10])) + .range(['#67001f','#b2182b','#d6604d','#f4a582','#fddbc7','#d1e5f0','#92c5de','#4393c3','#2166ac','#053061']); var svg = d3.select("#FeatureGraph1"); svg.selectAll("*").remove(); - var width = 800; + var width = 1000; var height = 500; var numTicks = 200; @@ -235,13 +309,26 @@ export default { .selectAll('line') .data(graph.links) .enter().append('line') + .attr("stroke", function(d) { return d.lin_color; }) .attr("stroke-width", function(d) { return Math.sqrt(d.value); }); + var node = svg.append('g') .attr('class', 'nodes') .selectAll('g') .data(graph.nodes) .enter().append('g') + .on("click", function(id, index) { + var groupLoc = index + 1 + var items = document.getElementsByClassName(groupLoc) + items.forEach( function (it) { + if (it.style.visibility == "hidden") { + it.style.visibility = "visible"; + } else { + it.style.visibility = "hidden"; + } + }) + }); var paramGroups = [ {name: 'chargeStrength', values: [-30, -80]}, @@ -307,24 +394,21 @@ export default { var arcSize = (6 * widthLoc / 100); var innerRadius = arcSize * 2; - var svgLoc = node.append('svg').attr('width', widthLoc).attr('height', widthLoc) + var svgLoc = node.append('svg').attr('width', widthLoc).attr('height', widthLoc).attr("class", function(d, i) { return d.group; }) .attr("id", function(d, i) { return "svg" + (i); }) graph.nodes.forEach(function(itemVal, indexNode) { - - // var data = [[ - // {value: 70, label: "", color: '#ff0000', lcolor: ''}, - // {value: 33, label: "", color: '#00ff00', lcolor: ''}, - // {value: 100, label: "44.5", color: '#000000', lcolor: 'black'} - // ];] var data = [] for(let k = 0; k < uniqueTarget.length; k++) { data.push({value: corrTargetFormatted[k][indexNode], label: '', color: colorCateg(uniqueTarget[k]), lcolor: ''}) } + var length = data.length data.push({value: 100, label: corrGlobFormatted[indexNode], color: '#000000', lcolor: colorsScaleNodes(MIVar[indexNode])}) + + var border = VIFVarFormatted[indexNode] var arcs = data.map(function (obj, i) { @@ -436,6 +520,15 @@ export default { drawGraph(); + for (let i = 0; i < listofNodes.length; i++) { + var numb = graph.nodes[i]['group'].match(/\d/g) + numb = parseInt(numb.join("")) + var items = document.getElementsByClassName(numb) + items.forEach( function (it) { + it.style.visibility = "hidden"; + }) + } + //Zoom functions function zoom_actions(){ svg.attr("transform", d3.event.transform) @@ -575,16 +668,9 @@ svg { } .links line { - stroke: #D3D3D3; stroke-opacity: 0.6; } -.nodes circle { - fill: #000000; - stroke: #fff; - stroke-width: 1px; -} - .column { float: left; margin: 0 10px; diff --git a/frontend/src/components/FeatureSpace2.vue b/frontend/src/components/FeatureSpace2.vue index c38b6c4..35329be 100644 --- a/frontend/src/components/FeatureSpace2.vue +++ b/frontend/src/components/FeatureSpace2.vue @@ -481,17 +481,6 @@ svg { display: block; } -.links line { - stroke: #D3D3D3; - stroke-opacity: 0.6; -} - -.nodes circle { - fill: #000000; - stroke: #fff; - stroke-width: 1px; -} - .column { float: left; margin: 0 10px; diff --git a/frontend/src/components/FeatureSpace3.vue b/frontend/src/components/FeatureSpace3.vue index 20a1a0b..3570a9a 100644 --- a/frontend/src/components/FeatureSpace3.vue +++ b/frontend/src/components/FeatureSpace3.vue @@ -483,17 +483,6 @@ svg { display: block; } -.links line { - stroke: #D3D3D3; - stroke-opacity: 0.6; -} - -.nodes circle { - fill: #000000; - stroke: #fff; - stroke-width: 1px; -} - .column { float: left; margin: 0 10px; diff --git a/frontend/src/components/FeatureSpace4.vue b/frontend/src/components/FeatureSpace4.vue index 665d786..923505f 100644 --- a/frontend/src/components/FeatureSpace4.vue +++ b/frontend/src/components/FeatureSpace4.vue @@ -483,17 +483,6 @@ svg { display: block; } -.links line { - stroke: #D3D3D3; - stroke-opacity: 0.6; -} - -.nodes circle { - fill: #000000; - stroke: #fff; - stroke-width: 1px; -} - .column { float: left; margin: 0 10px; diff --git a/run.py b/run.py index 83a8083..0a4dc4d 100644 --- a/run.py +++ b/run.py @@ -669,6 +669,7 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1, MI4List = [] corrMatrixComb1 = corrMatrixComb1.loc[[feature]] + corrMatrixComb2 = corrMatrixComb2.loc[[feature]] corrMatrixComb3 = corrMatrixComb3.loc[[feature]] corrMatrixComb4 = corrMatrixComb4.loc[[feature]] @@ -733,11 +734,6 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1, packCorrLoc.append(json.dumps(MI3List)) packCorrLoc.append(json.dumps(MI4List)) - packCorrLoc.append(json.dumps(uniqueTarget1)) - packCorrLoc.append(json.dumps(uniqueTarget2)) - packCorrLoc.append(json.dumps(uniqueTarget3)) - packCorrLoc.append(json.dumps(uniqueTarget4)) - return packCorrLoc @cross_origin(origin='localhost',headers=['Content-Type','Authorization'])