       [:input {:value (:text @state)
                :onChange #(swap! state assoc :text (.. % -target -value))
                :onKeyDown #(do
-                             (watch [:on-key-down (.-key %)])
                              (when (= (.-key %) "Enter")
                                  (on-enter (:text @state))))} ])))
 
 (defn header [ ]
-  (watch :render-header)
   [:div.header
    [:span.left
     "Metlog"
     [input-field #(end-edit % dashboard-state)]]])
 
 (defn dashboard [ ]
-  (watch :render-dashboard)
   [:div
    [header]
    [:div.content
     [series-list]]])
 
+
+(defn on-window-resize [ evt ]
+  (reset! window-width (.-innerWidth js/window)))
+
 (defn ^:export run []
   (reagent/render [dashboard]
                   (js/document.getElementById "metlog"))
+  (.addEventListener js/window "resize" on-window-resize)
+  (on-window-resize nil)
   (go
     (swap! dashboard-state assoc :series
            (vec (map (fn [ series-name ] {:name series-name})

              (watch [:response series-name])
              (cb data))))

(defn tsplot-fetch-and-draw [ canvas series-name ]
  (let [ ctx (.getContext canvas "2d")]
    (go
      (tsplot/draw ctx 1024 180 [])
      (tsplot/draw ctx 1024 180 (<! (<<< fetch-series-data
                                         series-name
                                         @query-window-secs))))))

(defn series-tsplot [ series ]
  (let [ series-state (atom { :series-name (:name series)} ) ]
    (reagent/create-class
     {:display-name (str "series-tsplot-" (:name series))
      :component-did-update
      (fn [ this ]
        (watch :component-did-update)
        (tsplot-fetch-and-draw (reagent/dom-node this) (:name series)))
      
      :component-did-mount
      (fn [ this ]
        (watch :component-did-mount)
        (tsplot-fetch-and-draw (reagent/dom-node this) (:name series)))

      :reagent-render
      (fn []
        @query-window-secs
        @series-state
        [:canvas { :width 1024 :height 180}])})))

(defn series-pane [ series ]
  (watch :render-series-pane)
  [:div.series-pane
   [:div.series-pane-header
    [:span.series-name (:name series)]]
   [series-tsplot series]])

(defn series-list [ ]
  [:div


(defonce query-window-secs (atom (* 3600 24)))

(def dashboard-state (atom {:series [] :text ""}))

(def window-width (atom 1024))

(defn <<< [f & args]
  (let [c (chan)]
