parent
377955daa3
commit
15b5fe3bb5
@ -0,0 +1,26 @@
|
|||||||
|
(ns wanijo.instance.viz
|
||||||
|
(:require [dorothy
|
||||||
|
[core :as dot]
|
||||||
|
[jvm :as doro-jvm]]))
|
||||||
|
|
||||||
|
(defn as-svg [instance]
|
||||||
|
(let [out-nodes (map #(vector (-> % :target :uuid)
|
||||||
|
{:label (-> % :target :name)})
|
||||||
|
(:links-out instance))
|
||||||
|
in-nodes (map #(vector (-> % :source :uuid)
|
||||||
|
{:label (-> % :source :name)})
|
||||||
|
(:links-in instance))
|
||||||
|
relationships-out (map (fn [{:keys [link target schema]}]
|
||||||
|
[(:uuid instance) :> (:uuid target)])
|
||||||
|
(:links-out instance))
|
||||||
|
relationships-in (map (fn [{:keys [link source schema]}]
|
||||||
|
[(:uuid source) :> (:uuid instance)])
|
||||||
|
(:links-in instance))]
|
||||||
|
(-> [[(:uuid instance) {:label (:name instance)}]]
|
||||||
|
(into out-nodes)
|
||||||
|
(into in-nodes)
|
||||||
|
(into relationships-out)
|
||||||
|
(into relationships-in)
|
||||||
|
dot/digraph
|
||||||
|
dot/dot
|
||||||
|
(doro-jvm/render {:format :svg}))))
|
Loading…
Reference in new issue