   (/ (- val (:min range))
      (- (:max range) (:min range))))
 
-(defn draw-tsplot [ ctx w h sinfo ]
-  (let [data (:data sinfo)
-        x-range (s-xrange data)
+(defn draw-tsplot-xlabel [ ctx text x y ]
+  (let [mt (.measureText ctx text)
+        w (.-width mt)]
+    (.log js/console (str [ w h]))
+    (.fillText ctx text (- x (/ w 2)) (+ 16 y))))
+
+(defn draw-tsplot-series [ ctx w h data ]
+  (.save ctx)
+  (.beginPath ctx)
+  (aset ctx "strokeStyle" "#0000FF")
+  (let [x-range (s-xrange data)
         y-range (s-yrange data)]
-;    (.fillRect ctx 0 0 w h)
     (when (> (count data) 0)
       (.moveTo ctx
                (* w (range-scale x-range (:t (first data))))

        (.lineTo ctx
                 (* w (range-scale x-range (:t pt)))
                 (- h (* h (range-scale y-range (:val pt))))))
      (.stroke ctx))))

(defn series-tsplot [ app-state owner ]
  (reify
    om/IInitState
    (init-state [_]
      
      {:width 800 :height 150})
    
    om/IDidMount
    (did-mount [_]


      (go
        (draw-tsplot (.getContext dom-element "2d")
                     1024 150
                     (<! (<<< fetch-series-data (:name app-state)))))))
    
    om/IRenderState
