mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-03 04:14:15 +01:00
Fix for issue #175
This commit is contained in:
@@ -408,15 +408,25 @@ exports.draw = function (text, id,isDot) {
|
||||
te.style('text-anchor', 'middle');
|
||||
te.text('Title for cluster');
|
||||
*/
|
||||
// Center the graph
|
||||
svg.attr("height", g.graph().height );
|
||||
if(typeof conf.width === 'undefined'){
|
||||
svg.attr("width", g.graph().width );
|
||||
}else{
|
||||
svg.attr("width", conf.width );
|
||||
if(conf.useMaxWidth) {
|
||||
// Center the graph
|
||||
svg.attr("height", '100%');
|
||||
svg.attr("width", '100%');
|
||||
//svg.attr("viewBox", svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height);
|
||||
svg.attr("viewBox", '0 0 ' + (g.graph().width + 20) + ' ' + (g.graph().height + 20));
|
||||
svg.attr('style', 'max-width:' + (g.graph().width + 20) + 'px;');
|
||||
}
|
||||
//svg.attr("viewBox", svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height);
|
||||
svg.attr("viewBox", '0 0 ' + (g.graph().width+20) + ' ' + (g.graph().height+20));
|
||||
else{
|
||||
// Center the graph
|
||||
svg.attr("height", g.graph().height );
|
||||
if(typeof conf.width === 'undefined'){
|
||||
svg.attr("width", g.graph().width );
|
||||
}else{
|
||||
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+20) + ' ' + (g.graph().height+20)); }
|
||||
|
||||
|
||||
// Index nodes
|
||||
graph.indexNodes('sunGraph'+i);
|
||||
|
||||
@@ -27,7 +27,10 @@ module.exports.draw = function (text, id) {
|
||||
gantt.yy.clear();
|
||||
gantt.parse(text);
|
||||
var elem = document.getElementById(id);
|
||||
w = elem.offsetWidth;
|
||||
w = elem.parentElement.offsetWidth;
|
||||
|
||||
console.log('id='+id,' w='+w);
|
||||
console.log(elem.parentElement);
|
||||
|
||||
if (typeof w === 'undefined') {
|
||||
w = 1200;
|
||||
|
||||
@@ -369,8 +369,13 @@ module.exports.draw = function (text, id) {
|
||||
}
|
||||
|
||||
var width = box.stopx-box.startx+2*conf.diagramMarginX;
|
||||
|
||||
diagram.attr("height",height);
|
||||
diagram.attr("width", width );
|
||||
if(conf.useMaxWidth) {
|
||||
diagram.attr("height", '100%');
|
||||
diagram.attr("width", '100%');
|
||||
diagram.attr('style', 'max-width:' + (width) + 'px;')
|
||||
}else{
|
||||
diagram.attr("height",height);
|
||||
diagram.attr("width", width );
|
||||
}
|
||||
diagram.attr("viewBox", (box.startx-conf.diagramMarginX) + ' -' +conf.diagramMarginY + ' ' + width + ' ' + height);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user