mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-13 20:39:38 +02:00
Fix for issue #129 - Possibility to set the width of the generated flowchart
This commit is contained in:
@@ -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(){
|
||||
|
Reference in New Issue
Block a user