Adding graph resize property for window resize

This commit is contained in:
anuprulez
2017-03-10 20:27:38 +01:00
parent b437be2c56
commit 2275d098ee
5 changed files with 38 additions and 26 deletions
@@ -50,7 +50,8 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
var chart = options.chart,
dataset = options.dataset,
settings = options.chart.settings,
data_content = null;
data_content = null,
cytoscape = null;
Utils.get( {
url : dataset.download_url,
success : function( content ) {
@@ -61,7 +62,7 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
data_content = content;
}
try {
var cytoscape = Cytoscape({
cytoscape = Cytoscape({
container: document.getElementById( options.targets[ 0 ] ),
boxSelectionEnabled: false,
autounselectify: true,
@@ -90,6 +91,8 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
});
chart.state( 'ok', 'Chart drawn.' );
// Re-renders the graph view when window is resized
$( window ).resize( function() { cytoscape.layout(); } );
} catch( err ) {
chart.state( 'failed', err );
}
@@ -238,29 +241,32 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
/***/ function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** SIF to JSON */
/** Inspired from https://www.npmjs.com/package/sif.js */
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
//public
function SIFJS() {};
//private members
var nodes = {}, links = {}, content = [];
var _getNode = function(id) {
if(!nodes[id]) nodes[id] = {id:id};
var _getNode = function( id ) {
if(!nodes[id]) nodes[id] = {id: id};
return nodes[id];
};
var _parse = function(line, i) {
var _parse = function( line, i ) {
line = (line.split('\t').length > 1) ? line.split('\t') : line.split(' ');
if( line.length > 2 ) {
if( line.length && line.length > 1 ) {
var source = _getNode(line[0]), intType = line[1], j, length;
for (j = 2, length = line.length; j < length; j++) {
var target = _getNode(line[j]);
if(source < target){
links[source.id + target.id + intType] = {target: target.id, source: source.id, id: source.id + target.id};
var target = _getNode(line[j]),
relObj = {target: target.id,
source: source.id,
id: source.id + target.id,
relation: intType.replace(/[''""]+/g, '') };
if(source < target) {
links[source.id + target.id + intType] = relObj;
} else {
links[target.id + source.id + intType] = {target: target.id, source: source.id, id: source.id + target.id};
links[target.id + source.id + intType] = relObj;
}
}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,27 +1,30 @@
/** SIF to JSON */
/** Inspired from https://www.npmjs.com/package/sif.js */
define( [], function() {
//public
function SIFJS() {};
//private members
var nodes = {}, links = {}, content = [];
var _getNode = function(id) {
if(!nodes[id]) nodes[id] = {id:id};
var _getNode = function( id ) {
if(!nodes[id]) nodes[id] = {id: id};
return nodes[id];
};
var _parse = function(line, i) {
var _parse = function( line, i ) {
line = (line.split('\t').length > 1) ? line.split('\t') : line.split(' ');
if( line.length > 2 ) {
if( line.length && line.length > 1 ) {
var source = _getNode(line[0]), intType = line[1], j, length;
for (j = 2, length = line.length; j < length; j++) {
var target = _getNode(line[j]);
if(source < target){
links[source.id + target.id + intType] = {target: target.id, source: source.id, id: source.id + target.id};
var target = _getNode(line[j]),
relObj = {target: target.id,
source: source.id,
id: source.id + target.id,
relation: intType.replace(/[''""]+/g, '') };
if(source < target) {
links[source.id + target.id + intType] = relObj;
} else {
links[target.id + source.id + intType] = {target: target.id, source: source.id, id: source.id + target.id};
links[target.id + source.id + intType] = relObj;
}
}
}
@@ -4,7 +4,8 @@ define( [ 'utilities/utils', 'utilities/sifjson', 'plugins/cytoscape/cytoscape'
var chart = options.chart,
dataset = options.dataset,
settings = options.chart.settings,
data_content = null;
data_content = null,
cytoscape = null;
Utils.get( {
url : dataset.download_url,
success : function( content ) {
@@ -15,7 +16,7 @@ define( [ 'utilities/utils', 'utilities/sifjson', 'plugins/cytoscape/cytoscape'
data_content = content;
}
try {
var cytoscape = Cytoscape({
cytoscape = Cytoscape({
container: document.getElementById( options.targets[ 0 ] ),
boxSelectionEnabled: false,
autounselectify: true,
@@ -44,6 +45,8 @@ define( [ 'utilities/utils', 'utilities/sifjson', 'plugins/cytoscape/cytoscape'
});
chart.state( 'ok', 'Chart drawn.' );
// Re-renders the graph view when window is resized
$( window ).resize( function() { cytoscape.layout(); } );
} catch( err ) {
chart.state( 'failed', err );
}