# Obsidian Dynamic Mermaid Relationship Charts ![[images/Obsidian-Dynamic-Mermaid-Relationship-Charts.webp]] [Watch on YouTube](https://www.youtube.com/watch?v=Tqm-l0R5erc) · 13:55 · Josh Plunkett · 2024-11-17 *Built from the video's English captions.* ## Outline ### 00:00 Introduction to NPC templates - Josh has been reworking the **character/NPC template** from his Patreon vault. It's still unfinished, but it now uses **Meta Bind** dropdowns so you can fill in a character sheet quickly. - He admits he probably won't use that much detail himself, since he runs characters from books, but world builders and story-heavy GMs will. - While building it, he wished it had a **relationship chart**. ### 01:01 The need for a better chart - In his view, relationships and family trees have always been a gap in Obsidian plugins. He wants something that visualizes family trees from note properties. - What he tried before: - **Mermaid**: too much of its own language, and he kept forgetting the syntax. - **Breadcrumbs**: he didn't like how it looked or worked. - **Excalidraw** and **Canvas**: easy, but you drag every box out by hand. ### 02:36 Developing a dynamic solution - His idea: JavaScript writes Mermaid text, and Obsidian renders it. Googling turned up someone's dynamic Mermaid chart built from properties. - He doesn't know JavaScript, so he worked with AI. **Google's AI** wasn't up to the job, but **ChatGPT** got there after 4 to 6 hours of back and forth. ![[images/Obsidian-Dynamic-Mermaid-Relationship-Charts-t0300.webp]] - The first version was hardcoded (parent 1, parent 2, children 1 to 3), which breaks as soon as a character has a fourth child. Adding conditional logic got too complex. - The fix was to switch to **list properties**. The property icon shows whether a property is text or a list, and a list can hold any number of entries. - Demo: he adds "Frank the Tank" as a parent and "Mistake Number Two" as a child, and the chart updates instantly. ### 05:22 How the relationship chart works - The script reads six list properties: **parents, children, enemies, allies, siblings, partner**. Anything added to a list shows up in the chart, so a character can have several partners. ![[images/Obsidian-Dynamic-Mermaid-Relationship-Charts-t0530.webp]] ### 06:58 Linking notes for interactivity - If a name matches an existing note (for example "Jasmine"), the node becomes a link. Hovering previews her note, and you can click through to it. - Linked nodes show in a different color, so you can see which names have notes. ![[images/Obsidian-Dynamic-Mermaid-Relationship-Charts-t0730.webp]] ### 08:31 Installing and customizing code - The code is on his website as **"DataviewJS - Dynamic Mermaid Relationship Chart"**, listed under recently added. - **Requirements:** the **Dataview** plugin with **Enable JavaScript queries** turned on. He also recommends turning on inline JavaScript queries. - Paste the code into your note with **Ctrl+Shift+V**. Plain Ctrl+V breaks the formatting and the chart won't work. ![[images/Obsidian-Dynamic-Mermaid-Relationship-Charts-t0915.webp]] - To customize it, paste the code into ChatGPT and ask for the change you want. The pattern is readable: variables are set at the top, then values are checked and copied in, links are added, and nodes are joined. - Change **LR** (left to right) to **TD** (top down) to change the layout. LR uses less vertical space, and TD may suit the table better. He hasn't found a way to make the chart more compact. ### 10:45 Where to find the template - Search for "Dataview" on obsidianttrpgtutorials.com. The script is linked at the bottom of the Dataview page with the other DataviewJS snippets. - The Patreon vault template will be updated to include it. ### 12:15 Final demonstration and wrap-up - He adds the block to your NPC template, so every new NPC gets a chart and you just type in relationship names. - With the block in every NPC note (he adds it to Jasmine's), you can jump between characters and build a full web of family and allies. - "I don't know how to write the code, but it does work." ![[images/Obsidian-Dynamic-Mermaid-Relationship-Charts-t1310.webp]] ## Things mentioned ### Obsidian plugins and features - **Dataview / DataviewJS**: free community plugin. JavaScript queries must be enabled. - **Mermaid**: diagram syntax built into Obsidian (free). Uses flowchart LR/TD. - **Meta Bind**: free community plugin, used for the template's dropdowns. - **Breadcrumbs**: free community plugin, tried and rejected. - **Excalidraw**: free community plugin for drawing relationship maps by hand. - **Canvas**: Obsidian core feature (free). - **Properties**: text vs list property types. ### AI tools - **ChatGPT**: wrote the script for him (has a free tier). - **Google's AI** (Gemini): tried first, but not up to the job. ### Josh's resources - [DataviewJS - Dynamic Mermaid Relationship Chart](https://obsidianttrpgtutorials.com/Obsidian+TTRPG+Tutorials/Plugin+Tutorials/Community+Plugins/Dataview/DataviewJS+-+Dynamic+Mermaid+Relationship+Chart): free code and tutorial. - [Obsidian TTRPG Tutorials](https://obsidianttrpgtutorials.com/): his free tutorial and community site. - [TTRPG Foundation Vault on Patreon](https://www.patreon.com/JPlunkett) (paid). Its character template (Template_WB_Character in the World Builder vault) is getting the chart. ### TTRPG context - NPC/character sheets for world building and story-heavy campaigns, including family trees, allies, enemies and partners. ## Bios - **Josh Plunkett**: Australian Dungeon Master and YouTuber behind Obsidian TTRPG Tutorials. He teaches how to run tabletop games in Obsidian and runs a Patreon with vault templates. By his own account he can't code JavaScript, so he relies on the community and AI. - **Unnamed online author**: the person whose dynamic, property-driven Mermaid chart Josh found and used as his starting point.