     "ordinal" (vary-meta data assoc field "ordinal")
     "geojson"  (let [raise-geopath (fn [datum] (-> datum
                                                (dissoc *geopath*)
-                                               (merge (get datum *geopath*))))]
-                 (vary-meta (map raise-geopath data) assoc field "geojson"))))
+                                               (merge (get datum *geopath*))))
+                     flattened-data (map raise-geopath data)]
+                 (vary-meta flattened-data assoc field "geojson"))))
 
 (defn ->vg-data
-  "Converts class types into data that vega.js understands."
+  "Converts objects like Date into data that vega.js understands."
   [data]
   (let [fields (-> data first keys)]
     (reduce (fn [acc, field]

                :properties
                {:update {:path {:field "layout_path"}
                          :fill {:scale "fill" :field *fill*}}
                 :hover {:fill {:value "red"}}}}]]
    {:data data
     :scales scales
     :marks marks
     :legends []}))

(ns gyptis.vega-templates
  "Helper functions that produce and manipulate vega.js plot declarations."
  (:require [gyptis.util :refer [merge-spec] :as u]))

(def ^:dynamic *table* "table")
(def ^:dynamic *x* :x)
(def ^:dynamic *y* :y)
