Skip to content

Commit

Permalink
added cose-bilkent extension for correct node layout placement
Browse files Browse the repository at this point in the history
Sakshisrivastava413 committed May 19, 2020
1 parent a9d21aa commit a0c1250
Showing 8 changed files with 138 additions and 7 deletions.
73 changes: 73 additions & 0 deletions dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
"license": "MIT",
"dependencies": {
"cytoscape": "^3.15.0",
"cytoscape-cose-bilkent": "^4.1.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
11 changes: 10 additions & 1 deletion src/RootContainer.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,16 @@ const RootContainer = ({ serviceUrl, entity }) => {

return (
<div className="rootContainer">
{data.length ? <GenePathwayNetwork data={data} /> : <h1>Loading...</h1>}
<div className="innerContainer">
<div className="graph">
<span className="chart-title">Pathway Network</span>
{data.length ? (
<GenePathwayNetwork data={data} />
) : (
<h1>Loading...</h1>
)}
</div>
</div>
</div>
);
};
3 changes: 3 additions & 0 deletions src/components/GenePathwayNetwork.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { useEffect } from 'react';
import cytoscape from 'cytoscape';
import coseBilkent from 'cytoscape-cose-bilkent';
import { getGraphData, createCytoscapeConfig } from '../utils';

cytoscape.use(coseBilkent);

function GenePathwayNetwork({ data }) {
useEffect(() => {
cytoscape(createCytoscapeConfig(getGraphData(data || [])));
25 changes: 21 additions & 4 deletions src/style.less
Original file line number Diff line number Diff line change
@@ -13,10 +13,27 @@
.rootContainer {
border: 1px solid black;
padding: 20px;

.cyContainer {
position: relative !important;
height: 500px !important;

.innerContainer {
display: flex;

.graph {
width: calc(100vw - 15rem);

.chart-title {
font-weight: 300;
font-size: 24px;
font-family: sans-serif;
display: flex;
justify-content: center;
margin: 12px;
}

.cyContainer {
position: relative !important;
height: 500px !important;
}
}
}
}
}
9 changes: 8 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -59,7 +59,14 @@ function createCytoscapeConfig(elements) {
'line-color': '#ccc'
}
}
]
],
layout: {
name: 'cose-bilkent',
quality: 'draft',
fit: true,
padding: 20,
idealEdgeLength: 150
}
};
}

0 comments on commit a0c1250

Please sign in to comment.