         cols))))
 
 (defn assoc-default-results [query]
-  (assoc query :vc-by-se-result {} :vc-by-ad-result {}))
+  (assoc query :vc-by-se-result {} :vc-by-ad-and-sex-result {}))
 
 (defn prepare-queries [queries]
   (->> (map-indexed index-query queries)


;; ---- Visit Count By Age Decade --------------------------------------------

(defn visit-count-by-age-decade [result]
  (->> (:visit-count-by-age-decade result)
       (map (fn [[age-decade count]]
              {"Age Decade" age-decade "Visits" count}))))

(defn draw-vc-by-ad-result [id result ticks]
  (let [data (visit-count-by-age-decade result)
        svg (.newSvg js/dimple (str "#" id) "100%" "100%")
        chart (new js/dimple.chart svg (clj->js data))]
    (.setMargins chart 60 10 50 40)
    (.addOrderRule (.addCategoryAxis chart "x" "Age Decade") "Age Decade")
    (let [axis (.addMeasureAxis chart "y" "Visits")]
      (set! (.-tickFormat axis) "d")
      (set! (.-ticks axis) ticks))
    (.addSeries chart nil (.-bar (.-plot js/dimple)))
    (.draw chart)))

;; ---- Queries ---------------------------------------------------------------

                {:opts (assoc opts :query-idx idx :collapsed collapsed)})
      (om/build visit-count-by-study-event-result (:vc-by-se-result query)
                {:opts (assoc opts :query-idx idx :collapsed collapsed)})
      (om/build visit-count-by-age-decade-result (:vc-by-ad-and-sex-result query)
                {:opts (assoc opts :query-idx idx :collapsed collapsed)}))))

;; ---- Workbook --------------------------------------------------------------
