You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is just that the regex in the mangling needs a slight change. It seems the svglite now produces ids set off with ' rather than ".
The comment in mangle-ids that svglite reuses the ids in each plot still holds, so multi-plot documents might be affected.
Here is the function with the regex changes:
(defn- mangle-ids
"ggplot produces SVGs with elements that have id attributes. These ids are unique within each plot, but are
generated in such a way that they clash when there's more than one plot in a document. This function takes
an SVG string and replaces the ids with globally unique ids. It returns a string.
This is a workaround which could be removed if there was a way to generate better SVG in R. Also: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
"
[svg]
(let [ ;ids (map last (re-seq #"id="([^\"])"" svg))
ids (map last (re-seq #"id='([^'])'" svg))
id-map (zipmap ids (repeatedly (count ids) #(str (UUID/randomUUID))))]
(-> svg
(s/replace #"id='([^'])'" #(str "id='" (get id-map (last %)) "'"))
(s/replace #"'#([^'])'" #(str "'#" (get id-map (last %)) "'"))
(s/replace #"url(#([^']))" #(str "url(#" (get id-map (last %)) ")")))
;(-> svg
; (s/replace #"id="([^\"])"" #(str "id="" (get id-map (last %)) """))
; (s/replace #""#([^\"])"" #(str ""#" (get id-map (last %)) """))
; (s/replace #"url(#([^\"]))" #(str "url(#" (get id-map (last %)) ")")))
; svg
))
I can not get any plots to work.
I believe it has to do with the id mangling, which eventually with the latest version of svglite is broken.
This fork works for me:
https://github.com/tentamen/gg4clj
which basically removes id mangling
The text was updated successfully, but these errors were encountered: