 
 (defn visualize []
   (clear-svg)
-  (-> (vis/visual (@state :points))
-      (vis/elem data-point)
-      (vis/enter (partial dom/append (dom/query "svg"))))
-  (-> (vis/visual (keys (@state :means)))
-      (vis/elem mean)
-      (vis/enter (partial dom/append (dom/query "svg")))))
+  (visualize-group (@state :points) (partial data-point "#fff"))
+  (visualize-group (@state :means) mean))
 
 (defn add-random-cluster []
   (swap! state (fn [{points :points :as state}]


(def colors ["#b58900" "#cb4b16" "#dc322f" "#d33682" "#6c71c4" "#268bd2" "#2aa198" "#859900"])

(pm/defpartial data-point [[x y]]
  [:svg:circle {:r 4 :cx x :cy y :stroke "#333" :fill "#fff"}])

(pm/defpartial mean [[x y]]
  [:svg:circle {:r 6 :cx x :cy y :stroke "#333" :fill (colors 1)}])

(def points (atom []))

(def initial-state {:next-step :init
                    :k 3
                    :points []})
(def state (atom initial-state))


        data (mapcat random-cluster (repeat k N))
        means (clustering/k-means k data)]
    (-> (vis/visual @points)
        (vis/elem (partial data-point "#fff"))
        (vis/enter (partial dom/append (dom/query "svg"))))
    (-> (vis/visual means)
        (vis/elem mean)
