   "Renders time series chart consisting of SVG for the bars and a label.
    Appearance is similar to the Rickshaw timeseries chart, which this
    component replaced, except for the CSS."
-  []
+  [bars-atom label]
   (let [bars @bars-atom
         indexed (vec (map-indexed vector bars))
         mx (apply max (map (fn [[k v]] v) bars))
         cnt (count bars)
         w (/ ts-w cnt)]
     [:div.rickshaw_graph
-     [barchart indexed mx cnt w]
-     [labels bars mx cnt w]]))
+     [barchart indexed mx cnt w label]
+     [labels bars mx cnt w label]]))
 
 (defn mount-ts-chart
   "Mount timeseries chart and subscribe to specified pub for state changes.
    The wait time until re-render is specified in the configuration map."
   [state-pub {:keys [every-ms]}]
-  (r/render-component [ts-chart] ts-elem)
-  (let [state-chan (chan (sliding-buffer 1))]
+  (let [state-chan (chan (sliding-buffer 1))
+        bars (atom [])
+        label (atom {})]
     (go-loop []
              (let [[_ state] (<! state-chan)]
-               (reset! bars-atom (ts/ts-data state))
+               (reset! bars (ts/ts-data state))
                (<! (timeout every-ms))
                (recur)))
+    (r/render-component [ts-chart bars label] ts-elem)
     (sub state-pub :app-state state-chan)))
-

(defn barchart
  "Renders a bar chart, making use of the bar function above. Returns
   entire SVG element."
  [indexed mx cnt w]
  (let [gap (/ (/ ts-w 20) cnt)]
    [:svg {:width ts-w :height ts-h}
     [:g
      (for [[idx [k v]] indexed]
        ^{:key k} [bar (* idx w) ts-h (* (/ v mx) ts-h) (- w gap) idx])]]))

(defn labels
  "Renders a label for a bar chart. Makes use of Rickshaw's CSS."
  [bars mx cnt w]
  (when-not (empty? @label)
    (let [idx (:idx @label)
          [k v] (get bars idx)

(defn bar
  "Renders a vertical bar. Enables showing a label when the mouse is
   positioned above the bar."
  [x y h w idx label]
  [:rect {:x x :y (- y h) :fill "steelblue" :width w :height h
          :on-mouse-enter #(reset! label {:idx idx})
          :on-mouse-leave #(reset! label {})}])
