   (fn [cursor owner]
     (reify
       om/IRender
-      (render [_]
+      (render [this]
         (dom/div #js {:className "devices"}
                  (dom/h3 nil (str "Metering data - " (get-in cursor [:property])))
                  (dom/h4 nil "Select devices to be plotted on the chart:")


;;;;;;;;; Utils ;;;;;;;;;;;;;;;;;;;;;;

(defn- fetch-data
  "The data need to be a vector."
  [cursor opts]
  (om/update!
   cursor #(assoc % :data (get mock-data (:selected cursor)))))

(defn- remove-chart []
  (.remove (first (nodelist-to-seq (.getElementsByTagName js/document "svg")))))

(defn- select-device!
  [cursor device-id]
  (.log js/console device-id)
 ; (remove-chart)
  (om/update!
   cursor #(assoc % :selected (vector device-id))))

;;;;;;;;;; Components ;;;;;;;;;;;;;;;;;

(def chart-state
  (atom {:selected ["01"]
         :property "rad003"
         :devices [{:hecuba/name "01"
                    :name "External temperature"}
                   {:hecuba/name "02"
                    :name "External humidity"}
                   {:hecuba/name "03"
                    :name "Ambient temperature"}]
         :data (get mock-data "01")}))

;;;;;;;;;;; Component 1:  List of devices for axis plots ;;;;;;;;;;


  (fn [cursor opts]
    (reify
      om/IInitState
      (init-state [this]
        (om/update! cursor #(assoc % :selected (vector "01"))) ; TOFIX this does not update :selected
        (.log js/console (get cursor :selected)))
      om/IWillMount
      (will-mount [this]
        (fetch-data! cursor opts)) ;; TOFIX This does not update :data
      om/IRender
      (render [this]
        (dom/div #js {:id "chart"}))
      om/IDidMount
      (did-mount [this owner]
        (let [Chart        (.-chart dimple)
              svg          (.newSvg dimple "#chart" 400 350)
              measurements (:data cursor)
