Skip to content

Commit a499296

Browse files
committed
Set SVG viewBox
1 parent 44ff608 commit a499296

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mermaid",
3-
"version": "8.0.0-rc.7",
3+
"version": "8.0.0-rc.8",
44
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
55
"main": "dist/mermaid.core.js",
66
"keywords": [

src/diagrams/flowchart/flowRenderer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,11 @@ export const draw = function (text, id) {
406406
})
407407

408408
const padding = 8
409-
svg.attr('width', g.maxX - g.minX + padding * 2)
410-
svg.attr('height', g.maxY - g.minY + padding * 2)
409+
const width = g.maxX - g.minX + padding * 2
410+
const height = g.maxY - g.minY + padding * 2
411+
svg.attr('width', '100%')
412+
svg.attr('style', `max-width: ${width}px;`)
413+
svg.attr('viewBox', `0 0 ${width} ${height}`)
411414
svg.select('g').attr('transform', `translate(${padding - g.minX}, ${padding - g.minY})`)
412415

413416
// Index nodes

0 commit comments

Comments
 (0)