Set SVG viewBox

This commit is contained in:
Tyler Long 2018-04-12 23:05:08 +08:00
parent 44ff608868
commit a4992963b3
2 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "mermaid",
"version": "8.0.0-rc.7",
"version": "8.0.0-rc.8",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"main": "dist/mermaid.core.js",
"keywords": [

View File

@ -406,8 +406,11 @@ export const draw = function (text, id) {
})
const padding = 8
svg.attr('width', g.maxX - g.minX + padding * 2)
svg.attr('height', g.maxY - g.minY + padding * 2)
const width = g.maxX - g.minX + padding * 2
const height = g.maxY - g.minY + padding * 2
svg.attr('width', '100%')
svg.attr('style', `max-width: ${width}px;`)
svg.attr('viewBox', `0 0 ${width} ${height}`)
svg.select('g').attr('transform', `translate(${padding - g.minX}, ${padding - g.minY})`)
// Index nodes