Skip to content
Snippets Groups Projects
Commit a2d58ee1 authored by AndiMajore's avatar AndiMajore
Browse files

added option for physics control via config

parent 8964349f
No related branches found
No related tags found
1 merge request!1Arenal production settings
...@@ -190,7 +190,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -190,7 +190,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
this.nodeData.edges = new vis.DataSet(edges); this.nodeData.edges = new vis.DataSet(edges);
const container = this.networkEl.nativeElement; const container = this.networkEl.nativeElement;
const isBig = nodes.length > 100 || edges.length > 100; const isBig = nodes.length > 100 || edges.length > 100;
const options = NetworkSettings.getOptions(isBig ? 'analysis-big' : 'analysis'); const options = NetworkSettings.getOptions(isBig ? 'analysis-big' : 'analysis', this.myConfig.physicsOn);
this.physicsEnabled = !isBig; this.physicsEnabled = !isBig;
this.network = new vis.Network(container, this.nodeData, options); this.network = new vis.Network(container, this.nodeData, options);
......
...@@ -59,6 +59,7 @@ export interface IConfig { ...@@ -59,6 +59,7 @@ export interface IConfig {
autofillEdges: boolean; autofillEdges: boolean;
sidebarPos: 'left' | 'right'; sidebarPos: 'left' | 'right';
interactions?: InteractionDatabase; interactions?: InteractionDatabase;
physicsOn?: boolean;
identifier?: Identifier; identifier?: Identifier;
nodeShadow?: boolean; nodeShadow?: boolean;
edgeShadow?: boolean; edgeShadow?: boolean;
...@@ -95,6 +96,7 @@ export const defaultConfig: IConfig = { ...@@ -95,6 +96,7 @@ export const defaultConfig: IConfig = {
nodeShadow: true, nodeShadow: true,
edgeShadow: true, edgeShadow: true,
autofillEdges: true, autofillEdges: true,
physicsOn: false,
sidebarPos: 'left', sidebarPos: 'left',
nodeGroups: { nodeGroups: {
// all NodeGroups but the default group must be set, if not provided by the user, they will be taken from here // all NodeGroups but the default group must be set, if not provided by the user, they will be taken from here
......
...@@ -8,7 +8,7 @@ import * as merge from 'lodash/fp/merge'; ...@@ -8,7 +8,7 @@ import * as merge from 'lodash/fp/merge';
export class NetworkSettings { export class NetworkSettings {
// colors // colors
private static Grey = '#A0A0A0' private static Grey = '#A0A0A0';
private static White = '#FFFFFF'; private static White = '#FFFFFF';
private static Black = '#000000'; private static Black = '#000000';
...@@ -68,24 +68,24 @@ export class NetworkSettings { ...@@ -68,24 +68,24 @@ export class NetworkSettings {
private static drugNotInTrialShape = 'box'; private static drugNotInTrialShape = 'box';
private static drugInTrialShape = 'triangle'; private static drugInTrialShape = 'triangle';
static getOptions(network: 'main' | 'analysis' | 'analysis-big') { static getOptions(network: 'main' | 'analysis' | 'analysis-big', physicsOn) {
if (network === 'main') { if (network === 'main') {
return { return {
layout: this.mainLayout, layout: this.mainLayout,
edges: this.mainEdges, edges: this.mainEdges,
physics: this.mainPhysics, physics: physicsOn || this.mainPhysics ,
}; };
} else if (network === 'analysis') { } else if (network === 'analysis') {
return { return {
layout: this.analysisLayout, layout: this.analysisLayout,
edges: this.analysisEdges, edges: this.analysisEdges,
physics: this.analysisPhysics, physics: physicsOn || this.analysisPhysics,
}; };
} else if (network === 'analysis-big') { } else if (network === 'analysis-big') {
return { return {
layout: this.analysisLayout, layout: this.analysisLayout,
edges: this.analysisEdges, edges: this.analysisEdges,
physics: this.analysisBigPhysics, physics: physicsOn || this.analysisBigPhysics,
}; };
} }
} }
......
...@@ -89,7 +89,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -89,7 +89,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
// a network exists, save node positions // a network exists, save node positions
this.networkPositions = this.networkInternal.getPositions(); this.networkPositions = this.networkInternal.getPositions();
} }
this.createNetwork(); this.createNetwork().then(() => {
if(this.myConfig.physicsOn) {
this.updatePhysicsEnabled(true);
}
});
} }
} }
...@@ -400,7 +405,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -400,7 +405,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this.nodeData.edges = new vis.DataSet(edges); this.nodeData.edges = new vis.DataSet(edges);
const container = this.networkEl.nativeElement; const container = this.networkEl.nativeElement;
const options = NetworkSettings.getOptions('main'); const options = NetworkSettings.getOptions('main',this.myConfig.physicsOn);
this.networkInternal = new vis.Network(container, this.nodeData, options); this.networkInternal = new vis.Network(container, this.nodeData, options);
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<network-expander id="netexp1" <network-expander id="netexp1"
pluginId="2" pluginId="2"
config='{"showLeftSidebar": true, "showSimpleAnalysis":true, "nodeGroups":{"patient":{"type":"patient","color":"black","font":{"color":"#ffffff"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"black","font":{"color":"black"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#ffffff"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":{"border":"#F12590","background":"#F12590"},"font":{"color":"#f0f0f0"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"black","groupName":"Relevant Gene"},"has-condition":{"color":"#000000","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}},"identifier":"symbol","title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":false,"showLegend":true}' config='{"physicsOn":true, "showLeftSidebar": true, "showSimpleAnalysis":true, "nodeGroups":{"patient":{"type":"patient","color":"black","font":{"color":"#ffffff"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"black","font":{"color":"black"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#ffffff"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":{"border":"#F12590","background":"#F12590"},"font":{"color":"#f0f0f0"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"black","groupName":"Relevant Gene"},"has-condition":{"color":"#000000","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}},"identifier":"symbol","title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":false,"showLegend":true}'
network='{"nodes":[{"id":"patient-1","group":"patient","x":592,"y":446},{"id":"patient-2","group":"patient","x":235,"y":87},{"id":"patient-3","group":"patient","x":105,"y":369},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316},{"id":"subtype-1","label":"Subtype 1","group":"condition","x":556,"y":171},{"id":"subtype-2","label":"Subtype 2","group":"condition","x":-87,"y":221}],"edges":[{"from":"BRCA1","to":"BRCA2","group":"ggi"},{"from":"ATM","to":"BARD1","group":"ggi"},{"from":"BRCA1","to":"CHEK2","group":"ggi"},{"from":"RAD51C","to":"RAD51D","group":"ggi"},{"from":"STK11","to":"TP53","group":"ggi"},{"from":"TP53","to":"PALB2","group":"ggi"},{"from":"TP53","to":"RAD51D","group":"ggi"},{"from":"TP53","to":"NF1","group":"ggi"},{"from":"TP53","to":"BRCA1","group":"ggi"},{"from":"TP53","to":"BRCA2","group":"ggi"},{"from":"PTEN","to":"BRCA1","group":"ggi"},{"from":"PTEN","to":"BRCA2","group":"ggi"},{"from":"TP53","to":"PTEN","group":"ggi"},{"from":"ATM","to":"PTEN","group":"ggi"},{"from":"CDH1","to":"RAD51D","group":"ggi"},{"from":"CDH1","to":"PALB2","group":"ggi"},{"from":"NBN","to":"BRIP1","group":"ggi"},{"from":"BRIP1","to":"PTEN","group":"ggi"},{"from":"patient-1","to":"BRCA1","group":"genotype"},{"from":"patient-1","to":"TP53","group":"genotype"},{"from":"patient-1","to":"BRCA2","group":"genotype"},{"from":"patient-1","to":"PTEN","group":"genotype"},{"from":"patient-2","to":"TP53","group":"genotype"},{"from":"patient-2","to":"NF1","group":"genotype"},{"from":"patient-2","to":"BARD1","group":"genotype"},{"from":"patient-3","to":"TP53","group":"genotype"},{"from":"patient-3","to":"PTEN","group":"genotype"},{"from":"patient-3","to":"NBN","group":"genotype"},{"from":"patient-1","to":"subtype-1","group":"has-condition"},{"from":"patient-2","to":"subtype-1","group":"has-condition"},{"from":"patient-3","to":"subtype-2","group":"has-condition"}]}'> network='{"nodes":[{"id":"patient-1","group":"patient","x":592,"y":446},{"id":"patient-2","group":"patient","x":235,"y":87},{"id":"patient-3","group":"patient","x":105,"y":369},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316},{"id":"subtype-1","label":"Subtype 1","group":"condition","x":556,"y":171},{"id":"subtype-2","label":"Subtype 2","group":"condition","x":-87,"y":221}],"edges":[{"from":"BRCA1","to":"BRCA2","group":"ggi"},{"from":"ATM","to":"BARD1","group":"ggi"},{"from":"BRCA1","to":"CHEK2","group":"ggi"},{"from":"RAD51C","to":"RAD51D","group":"ggi"},{"from":"STK11","to":"TP53","group":"ggi"},{"from":"TP53","to":"PALB2","group":"ggi"},{"from":"TP53","to":"RAD51D","group":"ggi"},{"from":"TP53","to":"NF1","group":"ggi"},{"from":"TP53","to":"BRCA1","group":"ggi"},{"from":"TP53","to":"BRCA2","group":"ggi"},{"from":"PTEN","to":"BRCA1","group":"ggi"},{"from":"PTEN","to":"BRCA2","group":"ggi"},{"from":"TP53","to":"PTEN","group":"ggi"},{"from":"ATM","to":"PTEN","group":"ggi"},{"from":"CDH1","to":"RAD51D","group":"ggi"},{"from":"CDH1","to":"PALB2","group":"ggi"},{"from":"NBN","to":"BRIP1","group":"ggi"},{"from":"BRIP1","to":"PTEN","group":"ggi"},{"from":"patient-1","to":"BRCA1","group":"genotype"},{"from":"patient-1","to":"TP53","group":"genotype"},{"from":"patient-1","to":"BRCA2","group":"genotype"},{"from":"patient-1","to":"PTEN","group":"genotype"},{"from":"patient-2","to":"TP53","group":"genotype"},{"from":"patient-2","to":"NF1","group":"genotype"},{"from":"patient-2","to":"BARD1","group":"genotype"},{"from":"patient-3","to":"TP53","group":"genotype"},{"from":"patient-3","to":"PTEN","group":"genotype"},{"from":"patient-3","to":"NBN","group":"genotype"},{"from":"patient-1","to":"subtype-1","group":"has-condition"},{"from":"patient-2","to":"subtype-1","group":"has-condition"},{"from":"patient-3","to":"subtype-2","group":"has-condition"}]}'>
}'></network-expander> }'></network-expander>
</div> </div>
......
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