Error while trying to create svg from cljs file

34 views
Skip to first unread message

Sven Richter

unread,
Dec 10, 2013, 3:58:59 PM12/10/13
to c2-...@googlegroups.com
Hi,

I am trying to create a js file with c2 with some lines inside based on SVG.

This is the code:
    (ns arp-charts.cljs.charts
      (:use-macros [c2.util :only [bind!]])
      (:require [singult.core :as singult]
                [c2.dom :as dom]
                [reflex.core :as reflex]))
     
    (bind! "#bars"
      [:svg [:style {:type "text/css"} (str "<![CDATA[" css "]]>")]
       [:g.plot
        [:g.coordinate-axes
           [:line {:x1 20 :y1 50 :x2 20 :y2 300}]
           [:line {:x1 20 :y1 300 :x2 620 :y2 300}]
         ]
        ]])

Now, when i generate a js file with lein cljsbuild auto and open a html page with the js loaded i get this error:
Error: Cannot merge $e into node of different type

throw De(a), De(b), Error("Cannot merge $e into node of different type");


Any Ideas what is wrong there?

Best Regards,
Sven

Kevin Lynagh

unread,
Dec 10, 2013, 4:29:13 PM12/10/13
to c2-...@googlegroups.com
What's the contents of the page?
The error means that you are trying to merge an element of one type (in your case, an SVG element) into another type.
So make sure that whatever has the "bars" ID on your page is an SVG element.

best,

Kevin


--
You received this message because you are subscribed to the Google Groups "C2-cljs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to c2-cljs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Kevin Lynagh
Keming Labs
http://keminglabs.com
888.502.1042

Sven Richter

unread,
Dec 11, 2013, 3:34:00 AM12/11/13
to c2-...@googlegroups.com
Hi Kevin,

Thank you very much, it seems like i had a wrong assumption about bind!, in my understanding it just binds an SVG element to a div, thats what I was trying.
Now I know that append!/replace! are better options for this and work as expected for me.

Thank you,
Sven
Reply all
Reply to author
Forward
0 new messages