Skip to content

Commit

Permalink
Add fix for er markers when using elk layout
Browse files Browse the repository at this point in the history
  • Loading branch information
yari-dewalt committed Oct 16, 2024
1 parent 5be5aa3 commit 5d2b0f7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/mermaid/src/diagrams/er/erRenderer-unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export const draw = async function (text: string, id: string, _version: string,
data4Layout.markers = ['only_one', 'zero_or_one', 'one_or_more', 'zero_or_more'];
data4Layout.diagramId = id;
await render(data4Layout, svg);
// Elk layout algorithm displays markers above nodes, so cut off the half that covers the node for the larger markers.
if (data4Layout.layoutAlgorithm === 'elk') {
svg.selectAll('*[id*="oneOrMoreStart"]').attr('viewBox', '18 0 38.5 36');
svg.selectAll('*[id*="oneOrMoreEnd"]').attr('viewBox', '0 0 27 36');
svg.selectAll('*[id*="zeroOrMoreStart"]').attr('viewBox', '18 0 38.5 36');
svg.selectAll('*[id*="zeroOrMoreEnd"]').attr('viewBox', '0 0 38.5 36');
}
const padding = 8;
utils.insertTitle(
svg,
Expand Down

0 comments on commit 5d2b0f7

Please sign in to comment.