cytoscape
Advanced tools
Comparing version 2.2.7 to 2.2.8
{ | ||
"name": "cytoscape", | ||
"version": "2.2.7", | ||
"version": "2.2.8", | ||
"main": "dist/cytoscape.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -109,3 +109,3 @@ require(['cytoscape'], function(rjsCy){ | ||
edges: [ | ||
{ data: { id: 'a"e', weight: 1, source: 'a', target: 'e' } }, | ||
{ data: { id: 'ae', weight: 1, source: 'a', target: 'e' } }, | ||
{ data: { id: 'ab', weight: 3, source: 'a', target: 'b' } }, | ||
@@ -112,0 +112,0 @@ { data: { id: 'be', weight: 4, source: 'b', target: 'e' } }, |
@@ -16,3 +16,3 @@ var fs = require('fs'); | ||
} catch(e){ | ||
throw '`' + configFile + '` could not be read; check the JSON is formatted correctly http://pro.jsonlint.com/'; | ||
throw '`' + configFile + '` could not be read; check the JSON is formatted correctly http://pro.jsonlint.com/ : ' + e; | ||
} | ||
@@ -24,5 +24,7 @@ | ||
config.demojs = config.demojs.match(/\/\/\<demo\>\s*((?:\s|.)+?)\s*\/\/\<\/demo\>/)[1]; | ||
config.demojs = hljs.highlight('js', config.demojs).value; | ||
} catch(e){ | ||
throw '`' + demoFile + '` could not be read'; | ||
throw '`' + demoFile + '` could not be read and parsed: ' + e; | ||
} | ||
@@ -120,2 +122,13 @@ | ||
if( section.demos ){ | ||
var demos = section.demos; | ||
for( var j = 0; j < demos.length; j++ ){ | ||
var demo = demos[j]; | ||
demo.embedUrl = 'http://jsbin.com/' + demo.id + '/latest'; | ||
demo.srcUrl = 'http://jsbin.com/' + demo.id + '/latest/edit?js,output'; | ||
} | ||
} | ||
if( section.fns ){ | ||
@@ -122,0 +135,0 @@ var fns = section.fns; |
@@ -1,78 +0,83 @@ | ||
$(loadCy = function(){ | ||
$( loadCy = function(){ | ||
options = { | ||
showOverlay: false, | ||
minZoom: 0.5, | ||
maxZoom: 2, | ||
//<demo> | ||
style: cytoscape.stylesheet() | ||
.selector('node') | ||
.css({ | ||
'content': 'data(name)', | ||
'font-family': 'helvetica', | ||
'font-size': 14, | ||
'text-outline-width': 3, | ||
'text-outline-color': '#888', | ||
'text-valign': 'center', | ||
'color': '#fff', | ||
'width': 'mapData(weight, 30, 80, 20, 50)', | ||
'height': 'mapData(height, 0, 200, 10, 45)', | ||
'border-color': '#fff' | ||
}) | ||
.selector(':selected') | ||
.css({ | ||
'background-color': '#000', | ||
'line-color': '#000', | ||
'target-arrow-color': '#000', | ||
'text-outline-color': '#000' | ||
}) | ||
.selector('edge') | ||
.css({ | ||
'width': 2, | ||
'target-arrow-shape': 'triangle' | ||
}) | ||
, | ||
// initialise cytoscape.js on a html dom element with some options: | ||
cytoscape( options = { | ||
container: document.getElementById('cy'), | ||
elements: { | ||
nodes: [ | ||
{ | ||
data: { id: 'j', name: 'Jerry', weight: 65, height: 174 } | ||
}, | ||
minZoom: 0.5, | ||
maxZoom: 2, | ||
{ | ||
data: { id: 'e', name: 'Elaine', weight: 48, height: 160 } | ||
}, | ||
// style can be specified as plain JSON, a stylesheet string (probably a CSS-like | ||
// file pulled from the server), or in a functional format | ||
style: [ | ||
{ | ||
selector: 'node', | ||
css: { | ||
'content': 'data(name)', | ||
'font-family': 'helvetica', | ||
'font-size': 14, | ||
'text-outline-width': 3, | ||
'text-outline-color': '#888', | ||
'text-valign': 'center', | ||
'color': '#fff', | ||
'width': 'mapData(weight, 30, 80, 20, 50)', | ||
'height': 'mapData(height, 0, 200, 10, 45)', | ||
'border-color': '#fff' | ||
} | ||
}, | ||
{ | ||
data: { id: 'k', name: 'Kramer', weight: 75, height: 185 } | ||
}, | ||
{ | ||
selector: ':selected', | ||
css: { | ||
'background-color': '#000', | ||
'line-color': '#000', | ||
'target-arrow-color': '#000', | ||
'text-outline-color': '#000' | ||
} | ||
}, | ||
{ | ||
data: { id: 'g', name: 'George', weight: 70, height: 150 } | ||
} | ||
], | ||
{ | ||
selector: 'edge', | ||
css: { | ||
'width': 2, | ||
'target-arrow-shape': 'triangle' | ||
} | ||
} | ||
], | ||
edges: [ | ||
{ data: { source: 'j', target: 'e' } }, | ||
{ data: { source: 'j', target: 'k' } }, | ||
{ data: { source: 'j', target: 'g' } }, | ||
// specify the elements in the graph | ||
elements: { | ||
nodes: [ | ||
{ data: { id: 'j', name: 'Jerry', weight: 65, height: 174 } }, | ||
{ data: { id: 'e', name: 'Elaine', weight: 48, height: 160 } }, | ||
{ data: { id: 'k', name: 'Kramer', weight: 75, height: 185 } }, | ||
{ data: { id: 'g', name: 'George', weight: 70, height: 150 } } | ||
], | ||
{ data: { source: 'e', target: 'j' } }, | ||
{ data: { source: 'e', target: 'k' } }, | ||
edges: [ | ||
{ data: { source: 'j', target: 'e' } }, | ||
{ data: { source: 'j', target: 'k' } }, | ||
{ data: { source: 'j', target: 'g' } }, | ||
{ data: { source: 'k', target: 'j' } }, | ||
{ data: { source: 'k', target: 'e' } }, | ||
{ data: { source: 'k', target: 'g' } }, | ||
{ data: { source: 'e', target: 'j' } }, | ||
{ data: { source: 'e', target: 'k' } }, | ||
{ data: { source: 'g', target: 'j' } } | ||
], | ||
}, | ||
{ data: { source: 'k', target: 'j' } }, | ||
{ data: { source: 'k', target: 'e' } }, | ||
{ data: { source: 'k', target: 'g' } }, | ||
ready: function(){ | ||
cy = this; | ||
} | ||
}; | ||
{ data: { source: 'g', target: 'j' } } | ||
], | ||
}, | ||
$('#cy').cytoscape(options); | ||
// wait for the data to load & the layout to run before using the api... | ||
ready: function(){ | ||
cy = this; | ||
} | ||
} ); | ||
}); | ||
//</demo> | ||
} ); |
@@ -28,2 +28,15 @@ $(function(){ | ||
$(document).on('click', '.gallery-refresh', function(){ | ||
var embedId = $(this).attr('data-embed-id'); | ||
var embed = document.getElementById(embedId); | ||
embed.classList.remove('loaded'); | ||
embed.src = embed.src; | ||
}); | ||
$('.gallery-embed').on('load', function(){ | ||
$(this).addClass('loaded'); | ||
}); | ||
$('#cy-refresh').on('click', function(){ | ||
@@ -30,0 +43,0 @@ loadCy(); |
@@ -14,9 +14,9 @@ ## Architecture & API | ||
| ------------- | ------------------------------------------------------- | | ||
| cy | the core | | ||
| eles | a collection of one or more elements (nodes and edges) | | ||
| ele | a collection of a single element (node or edge) | | ||
| nodes | a collection of one or more nodes | | ||
| node | a collection of a single node | | ||
| edges | a collection of one or more edges | | ||
| edge | a collection of a single edge | | ||
| `cy` | the core | | ||
| `eles` | a collection of one or more elements (nodes and edges) | | ||
| `ele` | a collection of a single element (node or edge) | | ||
| `nodes` | a collection of one or more nodes | | ||
| `node` | a collection of a single node | | ||
| `edges` | a collection of one or more edges | | ||
| `edge` | a collection of a single edge | | ||
@@ -23,0 +23,0 @@ By default, a function returns a reference back to the calling object to allow for jQuery-like chaining (e.g. `obj.fn1().fn2().fn3()`). Unless otherwise indicated in this documentation, a function is chainable in this manner unless a different return value is specified. This applies both to the core and to collections. |
{ | ||
"name": "cytoscape", | ||
"description": "A JavaScript graph library for analysis and visualisation", | ||
"version": "2.2.7", | ||
"version": "2.2.8", | ||
"license": "LGPL", | ||
@@ -6,0 +6,0 @@ "engines": { |
@@ -9,3 +9,3 @@ ;(function($$){ 'use strict'; | ||
breadthFirstSearch: function( roots, fn, directed ){ | ||
directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed; | ||
directed = arguments.length === 2 && !$$.is.fn(fn) ? fn : directed; | ||
fn = $$.is.fn(fn) ? fn : function(){}; | ||
@@ -15,3 +15,4 @@ var cy = this._private.cy; | ||
var Q = []; | ||
var connectedEles = []; | ||
var connectedNodes = []; | ||
var connectedBy = {}; | ||
var id2depth = {}; | ||
@@ -30,3 +31,3 @@ var V = {}; | ||
connectedEles.push( v[i] ); | ||
connectedNodes.push( v[i] ); | ||
id2depth[ v[i].id() ] = 0; | ||
@@ -63,4 +64,4 @@ } | ||
connectedEles.push( w ); | ||
connectedEles.push( e ); | ||
connectedNodes.push( w ); | ||
connectedBy[ w.id() ] = e; | ||
} | ||
@@ -71,2 +72,15 @@ } | ||
var connectedEles = []; | ||
for( var i = 0; i < connectedNodes.length; i++ ){ | ||
var node = connectedNodes[i]; | ||
var edge = connectedBy[ node.id() ]; | ||
if( edge ){ | ||
connectedEles.push( edge ); | ||
} | ||
connectedEles.push( node ); | ||
} | ||
return { | ||
@@ -81,3 +95,3 @@ path: new $$.Collection( cy, connectedEles ), | ||
depthFirstSearch: function( roots, fn, directed ){ | ||
directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed; | ||
directed = arguments.length === 2 && !$$.is.fn(fn) ? fn : directed; | ||
fn = $$.is.fn(fn) ? fn : function(){}; | ||
@@ -84,0 +98,0 @@ var cy = this._private.cy; |
@@ -771,18 +771,14 @@ ;(function($$){ 'use strict'; | ||
if ( cy.boxSelectionEnabled() && Math.pow(select[2] - select[0], 2) + Math.pow(select[3] - select[1], 2) > 7 && select[4] ) { | ||
// console.log('box selection'); | ||
if ( cy.boxSelectionEnabled() && Math.pow(select[2] - select[0], 2) + Math.pow(select[3] - select[1], 2) > 7 && select[4] ) { | ||
var newlySelected = []; | ||
var box = r.getAllInBox(select[0], select[1], select[2], select[3]); | ||
var box = r.getAllInBox( select[0], select[1], select[2], select[3] ); | ||
r.data.canvasNeedsRedraw[CanvasRenderer.SELECT_BOX] = true; | ||
if (box.length > 0) { | ||
if( box.length > 0 ) { | ||
r.data.canvasNeedsRedraw[CanvasRenderer.NODE] = true; | ||
} | ||
// console.log(box); | ||
for (var i=0;i<box.length;i++) { | ||
if (box[i]._private.selectable) { | ||
draggedElements.push( box[i] ); | ||
for( var i = 0; i < box.length; i++ ){ | ||
if( box[i]._private.selectable ){ | ||
newlySelected.push( box[i] ); | ||
@@ -804,3 +800,3 @@ } | ||
if (box.length === 0) { | ||
if( newlySelected.length === 0 ){ | ||
r.redraw(); | ||
@@ -1643,3 +1639,3 @@ } | ||
var newlySelected = []; | ||
var box = r.getAllInBox(select[0], select[1], select[2], select[3]); | ||
var box = r.getAllInBox( select[0], select[1], select[2], select[3] ); | ||
@@ -1655,4 +1651,4 @@ select[0] = undefined; | ||
// console.log(box); | ||
for (var i=0;i<box.length;i++) { | ||
if (box[i]._private.selectable) { | ||
for( var i = 0; i< box.length; i++ ) { | ||
if( box[i]._private.selectable ){ | ||
newlySelected.push( box[i] ); | ||
@@ -1662,3 +1658,3 @@ } | ||
var newlySelCol = (new $$.Collection( cy, newlySelected )); | ||
var newlySelCol = new $$.Collection( cy, newlySelected ); | ||
@@ -1671,4 +1667,6 @@ if( cy.selectionType() === 'single' ){ | ||
if (box.length > 0) { | ||
if( newlySelCol.length > 0 ) { | ||
r.data.canvasNeedsRedraw[CanvasRenderer.NODE] = true; | ||
} else { | ||
r.redraw(); | ||
} | ||
@@ -1675,0 +1673,0 @@ |
@@ -224,2 +224,9 @@ ;(function($$){ 'use strict'; | ||
// make sure to bound percent value | ||
if( percent < 0 ){ | ||
percent = 0; | ||
} else if( percent > 1 ){ | ||
percent = 1; | ||
} | ||
if( type.color ){ | ||
@@ -226,0 +233,0 @@ var r1 = prop.valueMin[0]; |
@@ -83,2 +83,10 @@ var expect = require('chai').expect; | ||
expect( bfs.path.edges().length ).to.equal( 4 ); | ||
for( var i = 0; i < bfs.path.length; i++ ){ | ||
if( i % 2 === 0 ){ | ||
expect( bfs.path[i].isNode() ).to.be.true; | ||
} else { | ||
expect( bfs.path[i].isEdge() ).to.be.true; | ||
} | ||
} | ||
}); | ||
@@ -104,2 +112,10 @@ | ||
expect( bfs.path.edges().length ).to.equal( 4 ); | ||
for( var i = 0; i < bfs.path.length; i++ ){ | ||
if( i % 2 === 0 ){ | ||
expect( bfs.path[i].isNode() ).to.be.true; | ||
} else { | ||
expect( bfs.path[i].isEdge() ).to.be.true; | ||
} | ||
} | ||
}); | ||
@@ -112,2 +128,10 @@ | ||
expect( dfs.path.edges().length ).to.equal( 4 ); | ||
for( var i = 0; i < dfs.path.length; i++ ){ | ||
if( i % 2 === 0 ){ | ||
expect( dfs.path[i].isNode() ).to.be.true; | ||
} else { | ||
expect( dfs.path[i].isEdge() ).to.be.true; | ||
} | ||
} | ||
}); | ||
@@ -120,2 +144,10 @@ | ||
expect( dfs.path.edges().length ).to.equal( 4 ); | ||
for( var i = 0; i < dfs.path.length; i++ ){ | ||
if( i % 2 === 0 ){ | ||
expect( dfs.path[i].isNode() ).to.be.true; | ||
} else { | ||
expect( dfs.path[i].isEdge() ).to.be.true; | ||
} | ||
} | ||
}); | ||
@@ -139,2 +171,11 @@ | ||
expect( di.pathTo(d).same( eles(a, ae, e, de, d) ) ).to.be.true; | ||
var adPath = di.pathTo(d); | ||
for( var i = 0; i < adPath.length; i++ ){ | ||
if( i % 2 === 0 ){ | ||
expect( adPath[i].isNode() ).to.be.true; | ||
} else { | ||
expect( adPath[i].isEdge() ).to.be.true; | ||
} | ||
} | ||
}); | ||
@@ -159,2 +200,10 @@ | ||
var adPath = di.pathTo(d); | ||
for( var i = 0; i < adPath.length; i++ ){ | ||
if( i % 2 === 0 ){ | ||
expect( adPath[i].isNode() ).to.be.true; | ||
} else { | ||
expect( adPath[i].isEdge() ).to.be.true; | ||
} | ||
} | ||
}); | ||
@@ -161,0 +210,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24019939
414
378132