Skip to content

Commit

Permalink
Update demos to use fcose layout and resolve #122
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanbalci committed Mar 5, 2021
1 parent 69c2825 commit 680aaca
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
2 changes: 1 addition & 1 deletion demo/demo-compounds-collapsed.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!--<script src="../cytoscape.js/build/cytoscape.js"></script>-->
<script src="https://unpkg.com/layout-base/layout-base.js"></script>
<script src="https://unpkg.com/cose-base/cose-base.js"></script>
<script src="https://unpkg.com/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js"></script>
<script src="https://unpkg.com/cytoscape-fcose/cytoscape-fcose.js"></script>
<script src="https://unpkg.com/cytoscape-graphml/cytoscape-graphml.js"></script>
<script src="../cytoscape-expand-collapse.js"></script>
<script src="demo-compounds.js"></script>
Expand Down
47 changes: 30 additions & 17 deletions demo/demo-compounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,21 @@ function main() {
container: document.getElementById('cy'),

ready: function () {
var api = this.expandCollapse({
this.layout({
name: 'fcose',
randomize: true,
fit: true,
animate: false
}).run();
var api = this.expandCollapse({
layoutBy: {
name: "cose-bilkent",
animate: "end",
name: "fcose",
animate: true,
randomize: false,
fit: true
},
fisheye: true,
animate: false,
animate: true,
undoable: false
});
api.collapseAll();
Expand Down Expand Up @@ -371,19 +377,24 @@ function main() {
if (clusteringDepth < 1)
return;
var createdNodeIds = [];
cy.startBatch();
//cy.startBatch();

for (var i = 0; i < clusteringDepth; i++) {
//get clusters for this depth level
let clusters = cy.elements().markovClustering();

for (var j = 0; j < clusters.length; j++) {
let parentId = "p_" + i + "_" + j;

cy.add({

let clusterBoundingBox = clusters[j].bb();
let parentPos = {x: clusterBoundingBox.x1 + clusterBoundingBox.w / 2, y: clusterBoundingBox.y1 + clusterBoundingBox.h / 2};

var newNode = cy.add({
group: 'nodes',
data: {
id: parentId
}
},
position: parentPos
});
createdNodeIds.push(parentId);
clusters[j].move({
Expand All @@ -397,16 +408,11 @@ function main() {
}
});
cy.remove(nodesToRemove);
api.collapseAll();
cy.makeLayout({
name: 'cose-bilkent',
randomize: true,
fit: true,
animate: false
}).run();

api.collapseAll();
}
cy.endBatch();

//cy.endBatch();
setClusterBtn(false);
}

Expand All @@ -421,10 +427,17 @@ function main() {

cy.startBatch();
cy.elements().remove();
cy.graphml({ layoutBy: 'cose-bilkent' });
cy.graphml({ layoutBy: 'preset'});
cy.graphml(contents);
cy.endBatch();

cy.makeLayout({
name: 'fcose',
randomize: true,
fit: true,
animate: false
}).run();

//to be able to open the same file again
document.getElementById("graphml-input").value = "";
//avoid adding the same listener multiple times
Expand Down
8 changes: 4 additions & 4 deletions demo/demo-undoable.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!--<script src="../cytoscape.js/build/cytoscape.js"></script>-->
<script src="https://unpkg.com/layout-base/layout-base.js"></script>
<script src="https://unpkg.com/cose-base/cose-base.js"></script>
<script src="https://unpkg.com/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js"></script>
<script src="https://unpkg.com/cytoscape-fcose/cytoscape-fcose.js"></script>
<script src="https://unpkg.com/cytoscape-undo-redo/cytoscape-undo-redo.js"></script>
<script src="../cytoscape-expand-collapse.js"></script>

Expand All @@ -23,7 +23,7 @@
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
layout: {
name: 'cose-bilkent'
name: 'fcose'
},
style: [
{
Expand Down Expand Up @@ -77,8 +77,8 @@

cy.expandCollapse({
layoutBy: {
name: "cose-bilkent",
animate: "end",
name: "fcose",
animate: true,
randomize: false,
fit: true
},
Expand Down
8 changes: 4 additions & 4 deletions demo/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!--<script src="../cytoscape.js/build/cytoscape.js"></script>-->
<script src="https://unpkg.com/layout-base/layout-base.js"></script>
<script src="https://unpkg.com/cose-base/cose-base.js"></script>
<script src="https://unpkg.com/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js"></script>
<script src="https://unpkg.com/cytoscape-fcose/cytoscape-fcose.js"></script>
<script src="../cytoscape-expand-collapse.js"></script>

<script>
Expand All @@ -23,7 +23,7 @@
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
layout: {
name: 'cose-bilkent'
name: 'fcose'
},
style: [
{
Expand Down Expand Up @@ -75,8 +75,8 @@

var api = cy.expandCollapse({
layoutBy: {
name: "cose-bilkent",
animate: "end",
name: "fcose",
animate: true,
randomize: false,
fit: true
},
Expand Down

0 comments on commit 680aaca

Please sign in to comment.