Fix for issue #129 - Possibility to set the width of the generated flowchart

This commit is contained in:
knsv
2015-03-07 14:52:18 +01:00
parent cbebf126ce
commit 3ae1b5f1a3
7 changed files with 74 additions and 10 deletions

View File

@@ -5,6 +5,16 @@ var graph = require('./graphDb');
var flow = require('./parser/flow');
var dot = require('./parser/dot');
var dagreD3 = require('./dagre-d3');
var conf = {
};
module.exports.setConf = function(cnf){
var keys = Object.keys(cnf);
var i;
for(i=0;i<keys.length;i++){
conf[keys[i]] = cnf[keys[i]];
}
};
/**
* Function that adds the vertices found in the graph definition to the graph to be rendered.
* @param vert Object containing the vertices.
@@ -401,8 +411,15 @@ exports.draw = function (text, id,isDot) {
*/
// Center the graph
svg.attr("height", g.graph().height );
svg.attr("width", g.graph().width );
svg.attr("viewBox", svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height);
if(typeof conf.width === 'undefined'){
console.log('Undefined it is');
svg.attr("width", g.graph().width );
}else{
console.log('Defined it is'+conf.width);
svg.attr("width", conf.width );
}
//svg.attr("viewBox", svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height);
svg.attr("viewBox", '0 0 '+ g.graph().width+' '+ g.graph().height);
setTimeout(function(){