Generate Mermaid.js Diagrams with AL Code (2026 Edition)
Eric demonstrates an open-source AL app that brings Pele, a lightweight MIT-licensed Mermaid-to-SVG renderer, into AL. AL code can then render Mermaid diagrams to SVG directly and embed them in generated HTML, instead of loading Mermaid in the browser at runtime. The Business Central playground demo shows flowcharts with click events returned to AL, many diagram types, CSS theming with dark mode, and render times of 4 to 5 milliseconds.
- Introduction and Background
- Previous Approach and Limitations
- Introducing Pele Library
- New App Overview and Demo Setup
- Flowchart Example and Interactive Features
- Diagram Type Samples
- Performance and Rendering Discussion
- Benefits and Conclusion
Overview
Erik Hougaard describes how his earlier Mermaid approach in Business Central worked and its limitations. He then presents a new app built on the Pele library, an open-source, MIT-licensed, lightweight library that renders Mermaid diagrams to SVG inside AL code, so diagrams can be embedded in HTML that AL already generates.
The demo covers a flowchart with interactive elements, samples of other diagram types, CSS theming including dark mode, and a discussion of performance. A complex diagram rendered in 4 milliseconds. He notes that some Mermaid diagram types are not yet ported because he did not need them.
Key points
- Pele is a lightweight, open-source, MIT-licensed library that renders Mermaid diagrams to SVG. The author brought it into AL as an open-source app with codeunits, tests and a playground.
- The previous approach ran Mermaid in a control add-in to render at runtime. Now AL generates the SVG directly and can embed it in HTML it already builds.
- Click events can be set on all diagram elements or only on elements configured as clickable. The click is passed back to AL code, for example a callback to open job 001.
- Demoed diagram types include flowcharts, sequence, entity relationship, state, Gantt, pie, git graph, mind map, journey and timeline.
- Some Mermaid capabilities have not been ported yet, because the author did not need them.
- Diagrams are CSS themed, so dark mode is possible.
- A complex flowchart rendered in 4 milliseconds and a mind map in 5 milliseconds. The hard part is the layout, not the drawing.
Features
Every feature below: status not stated, demoed.
| Feature | At |
|---|---|
| Mermaid Diagram Generation in AL | 2:05 |
| Interactive Diagram Elements | 4:59 |
| Multiple Diagram Types Support | 5:47 |
| CSS Theming Support | 5:54 |
| Fast Rendering Performance | 4:46 |
AL objects mentioned
As heard in the captions. A name that matches one object page by exact type and name links to it; the others stay as named.
- codeunit “Mermaid diagram codeunits” at 3:44
Not found in BC28-30: codeunit “Mermaid diagram codeunits”.
Quotes
- 0:45 “I have used that many times already. But the approach at that time was you created um your your mermaid thing, and then you”
- 2:05 “this is a lightweight open-source library that renders mermaid diagrams to SVGs.”
- 3:08 “this is open-source, this is MIT licensed, there’s beautiful documentation and it just works.”
- 4:46 “this took 4 milliseconds to render, which is interesting also that even these complex things are running pretty good in AL code.”
- 5:12 “I can click on this, and we actually get an event back to to AL code. So, so it’s possible to have interactions uh”
Presenters (as heard): Eric.
