stathissideris / dali

dali is a Clojure library for representing, exporting and manipulating the SVG graphics format.
295 stars 16 forks source link

No method in multimethod 'layout-nodes' for dispatch value: :dali/stack #11

Closed ILoveHubGit closed 6 years ago

ILoveHubGit commented 6 years ago

In attempting to build my own document I ran into this error

IllegalArgumentException No method in multimethod 'layout-nodes' for dispatch value: :dali/stack clojure.lang.MultiFn.getFn (MultiFn.java:156)

After I did not succeded in solving this I copied the complete content of the page (architecture.clj) except the namespace part. And tried to render the document.

(dali.io/render-svg document "testfile.svg"

This also resulted in the same error. I noticed in my own trials that if I used the following code it worked:

(defn testpict 
   [id text class]
     [:circle {:id id :class class} :_ 50])

(defn picture []
   [:dali/page
     (testpict :testid "Some\ntext" :testclass)])

If I change the testpict function to this I get the same error as above

(defn testpict 
   [id text class]
     [:dali/align {:axis :center}
        [:circle {:id id :class class} :_ 50]
        (text-stack (string/split-lines text))

Since there are multiple private function in the dali library it is difficult for me to pinpoint the exact location of the error. But in the function (dali.layout/resolve-layout doc) I could continue till (resolve-layout (batik/context) doc)

stathissideris commented 6 years ago

You are missing the require for the stack layout. It's documented here:

https://github.com/stathissideris/dali/blob/master/doc/layout.md

IMPORTANT: In order to use the built-in layouts you need to require the relevant namespace (dali.layout.stack, dali.layout.align etc) despite the fact that you are not using any of the functions directly.

So you need dali.layout.stack in your requires to render stack nodes.

ILoveHubGit commented 6 years ago

Thanks for the quick reply. I added all the dali.layout.aaa to my requires and now it works fine. Does this mean also that the architecture.clj example must be changed? Since in the source code for this example there is no dali.layout.syntax or other in the require list.