Mermaid
Generates gantt charts and other diagrams from a Markdown-like text syntax.
- Downloads / mo
- 98.9M
- Stars
- 91.2K
- Last release
- 12.3.0
- License
- MIT
Strengths
- Exports SVG, PNG, or Markdown. Render a schedule as SVG, PNG, or a Markdown link for docs.
Limitations
- Excluded dates stretch tasks. Excluding a date extends the task to the right instead of leaving a gap.
Quickstart
<script type="module"> import mermaid from './mermaid.esm.mjs'; mermaid.initialize({ startOnLoad: false }); // Example of using the render function const drawDiagram = async function () { element = document.querySelector('#graphDiv'); const graphDefinition = 'graph TB\na-->b'; const { svg } = await mermaid.render('graphDiv', graphDefinition); element.innerHTML = svg; }; await drawDiagram(); </script>
Mermaid examples
async (definition, mermaidConfig) => { window.mermaid.initialize(mermaidConfig) try { let { svg } = await window.mermaid.render('container', definition) // workaround: https://github.com/yuzutech/kroki/issues/1632 // upstream issue: https://github.com/mermaid-js/mermaid/issues/1766 // taken from: https://github.com/mermaid-js/mermaid-live-editor/blob/83382901cd7e15414b6f18b48b7dd9c4775f3a21/src/lib/components/Actions.svelte#L23-L26 svg = svg .replaceAll('<br>', '<br/>') .replaceAll(/<img([^>]*)>/g, (_m, g) => `<img ${g} />`) return { svg, error: null } } catch (err) { return { svg: null, error: { name: 'name' in err && err.name, message: 'message' in err && err.message, stack: 'stack' in err && err.stack } } } }