Merge pull request #1371 from jgreywolf/1234-RefactorClassDiagramScaling
1234 refactor class diagram scaling
This commit is contained in:
commit
0933268e61
|
@ -9,6 +9,7 @@ import svgDraw from './svgDraw';
|
|||
parser.yy = classDb;
|
||||
|
||||
let idCache = {};
|
||||
const padding = 20;
|
||||
|
||||
const conf = {
|
||||
dividerMargin: 10,
|
||||
|
@ -225,9 +226,22 @@ export const draw = function(text, id) {
|
|||
}
|
||||
});
|
||||
|
||||
diagram.attr('height', g.graph().height + 40);
|
||||
diagram.attr('width', g.graph().width * 1.5 + 20);
|
||||
diagram.attr('viewBox', '-10 -10 ' + (g.graph().width + 20) + ' ' + (g.graph().height + 20));
|
||||
const svgBounds = diagram.node().getBBox();
|
||||
const width = svgBounds.width + padding * 2;
|
||||
const height = svgBounds.height + padding * 2;
|
||||
|
||||
if (conf.useMaxWidth) {
|
||||
diagram.attr('width', '100%');
|
||||
diagram.attr('style', `max-width: ${width}px;`);
|
||||
} else {
|
||||
diagram.attr('height', height);
|
||||
diagram.attr('width', width);
|
||||
}
|
||||
|
||||
// Ensure the viewBox includes the whole svgBounds area with extra space for padding
|
||||
const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`;
|
||||
logger.debug(`viewBox ${vBox}`);
|
||||
diagram.attr('viewBox', vBox);
|
||||
};
|
||||
|
||||
export default {
|
||||
|
|
Loading…
Reference in New Issue