Get access to Mermaid's generated SVG code #4035
-
QuestionWondering if some already-existing function(s) can allow me to extract the svg code. Or would we need to add custom methods within mermaid.js |
Beta Was this translation helpful? Give feedback.
Answered by
falkoschindler
Nov 25, 2024
Replies: 1 comment 1 reply
-
Hi @groucho86, Even though there is no explicit function for doing that, you might be able to create a workaround using @ui.page('/')
def index():
m = ui.mermaid('''
graph TD
A --> B
B --> C
''')
async def get_svg():
svg = await ui.run_javascript(f'getElement({m.id}).$el.querySelector("svg").outerHTML')
print(svg)
ui.button('Get SVG', on_click=get_svg) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
groucho86
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @groucho86,
Even though there is no explicit function for doing that, you might be able to create a workaround using
ui.run_javascript
: