Skip to content

Incorrect iframe height on some diagrams like pie #4289

Open
@silverwind

Description

@silverwind

Description

With securityLevel: "sandbox", mermaid will output an iframe, but it appears that on some charts like pie, this iframe's height does not match the SVG element. In the example below, svg height is 254px, but iframe height is 450px.

The iframe height does match the height value in viewBox but does not take into account that the SVG is scaled down, so its viewbox height does not match the rendered height. I think the fix will be to take into account the scaling of the SVG when calculating iframe height.

Steps to reproduce

https://mermaid.live/edit#pako:eNp1T7sOwjAM_BXLcwcYyQxISMBCB4YspnHBokmq1OUh1H8nbcXITafz3Vn3wSo6RoOtMKhow3DclNv97mwD_GCxFM_QtRwUmhjvEq5QxwQ-PoQtgoHV4p__SVrdxoDo5FwusEDPyZO4_Pcz5izqjX1uMpk6SneLxax3XPVJ9L3nBzfzvaPgLvFl0YYhV1Gv8fQOFRpNPRfYt46U10LXRB5NTU2XVXaiMR3mrdPk4Qsk6lBB

(Click cancel to preserve config)

Screenshots

Screenshot 2023-04-11 at 12 49 54

(color issue in iframe is a separate bug and can be fixed by adding color-scheme:normal to the iframe's CSS).

Setup

  • Mermaid version: 10.1.0
  • Browser and Version: all

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions