Fix for issue #175

This commit is contained in:
knsv
2015-06-16 10:40:08 +02:00
parent 342b83a010
commit e5a701d04d
12 changed files with 324 additions and 169 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
};