Created
July 20, 2016 18:55
-
-
Save err/c8be7d0fea3dc228b4ece5309ef5cf61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn render-squares | |
[component props] | |
(let [svg (-> js/d3 (.select (dom/node component))) | |
data (clj->js (:squares props)) | |
selection (-> svg | |
(.selectAll "rect") | |
(.data data (fn [d] (.-id d))))] | |
(-> (.enter selection) | |
(.append "rect") | |
(.style "fill" (fn [d] (.-color d))) | |
(.attr "x" "0") | |
(.attr "y" "0") | |
.transition | |
(.attr "x" (fn [d] (.-x d))) | |
(.attr "y" (fn [d] (.-y d))) | |
(.attr "width" (fn [d] (.-size d))) | |
(.attr "height" (fn [d] (.-size d)))) | |
(-> selection | |
.exit | |
.transition | |
(.style "opacity" "0") | |
.remove) | |
false)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment