mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-11 11:29:42 +02:00
Prevent un-labelled edges that are left of the left-most vertex from being cut off the diagram
This commit is contained in:
@@ -640,4 +640,16 @@ describe('Flowchart', () => {
|
|||||||
{ flowchart: { htmlLabels: false } }
|
{ flowchart: { htmlLabels: false } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('31: should not slice off edges that are to the left of the left-most vertex', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`graph TD
|
||||||
|
work --> sleep
|
||||||
|
sleep --> work
|
||||||
|
eat --> sleep
|
||||||
|
work --> eat
|
||||||
|
`,
|
||||||
|
{ flowchart: { htmlLabels: false } }
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -380,10 +380,6 @@ export const draw = function(text, id) {
|
|||||||
const svgBounds = svg.node().getBBox();
|
const svgBounds = svg.node().getBBox();
|
||||||
const width = svgBounds.width + padding * 2;
|
const width = svgBounds.width + padding * 2;
|
||||||
const height = svgBounds.height + padding * 2;
|
const height = svgBounds.height + padding * 2;
|
||||||
logger.debug(
|
|
||||||
`new ViewBox 0 0 ${width} ${height}`,
|
|
||||||
`translate(${padding - g._label.marginx}, ${padding - g._label.marginy})`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (conf.useMaxWidth) {
|
if (conf.useMaxWidth) {
|
||||||
svg.attr('width', '100%');
|
svg.attr('width', '100%');
|
||||||
@@ -393,10 +389,10 @@ export const draw = function(text, id) {
|
|||||||
svg.attr('width', width);
|
svg.attr('width', width);
|
||||||
}
|
}
|
||||||
|
|
||||||
svg.attr('viewBox', `0 0 ${width} ${height}`);
|
// Ensure the viewBox includes the whole svgBounds area with extra space for padding
|
||||||
svg
|
const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`;
|
||||||
.select('g')
|
logger.debug(`viewBox ${vBox}`);
|
||||||
.attr('transform', `translate(${padding - g._label.marginx}, ${padding - svgBounds.y})`);
|
svg.attr('viewBox', vBox);
|
||||||
|
|
||||||
// Index nodes
|
// Index nodes
|
||||||
flowDb.indexNodes('subGraph' + i);
|
flowDb.indexNodes('subGraph' + i);
|
||||||
|
Reference in New Issue
Block a user