Thanks @Jay_Lefebvre. The demo is just a proof of concept showing that a valid SVG can be rendered in Coda — but the SVGs themselves are copied from wherever I found those samples (Wikipedia etc).
Now, the way you compose that SVG is up to you.
You can make a <g><rect ... /><text ...>...</text></g> for a bubble for each task, for example, and calculate X/Y positions of each bubble with some algorithm to position those on the mind map. Then append all groups together inside the <svg> tag and feed to the URL encoder and to Image().
If I’m sober enough tomorrow after the New Year, maybe I’ll compose some rudimentary mind map impl myself.
What’s important here is that virtually any report output is now available in Coda. Not just images, but custom styled tables too (as a vector image).
This is exciting. Very exciting. For the sake of this community, please be sober enough tomorrow Happy new year to you, your help has been very precious and lots of our projects were inspired by your templates & ideas. Thank you
Well, here’s one working example / proof of concept:
Here I’m using the table of tasks to calculate the X/Y coordinates of each node, then generating SVG for individual nodes and connector lines to parents (as simple as center X/Y of one node to center X/Y of another), and finally combining that all together into something that can be fed to Image(). I had to figure out the algorithm to calculate node position myself (and it’s a pretty naive one, although it gives good-enough results). You can do something similar for your needs. This said, you either need to know how to compose SVG code, or use an editor and then strip out all the bloat that editors usually put inside exported SVG.
To put shortly, I’m simply leveraging standard browser functionality.
Coda translates function Image(url) directly into <img src="url" … />. Well, it removes whitespaces, but nothing beyond that.
Browsers support Data URI — i.e. capability where instead of resource link (URL) you’re providing the data encoded right there. You may have encountered this with Base64 mostly.
So the task was ultimately to compose data URI to feed to the Image tag that would be rendered as a valid image. SVG is a text format (i.e. easy to compose by simply concatenating strings and filling in parameters with Format(), so it was an obvious first choice.
Since Coda strips out spaces from the data URI and SVG needs them, I went with URI encoded format. Since Coda’s own EncodeForUrl() was far too eager and encoded more than it should have (and the output wasn’t rendering at all), I kinda implemented my own.
In the very end, I’m composing SVG elements out of data rows, concatenating them together, URI encoding, prepending with data:image/svg+xml;, and feeding to Image()