 
 ;;;;;;;;;;; Data ;;;;;;;;;;;
 
-(def mock-data {"01"     [{"device_id" "01" "month" "01/01/2011" "reading" 0.8}
-                          {"device_id" "01" "month" "01/02/2011" "reading" 0.9}
-                          {"device_id" "01" "month" "01/03/2011" "reading" 0.8}
-                          {"device_id" "01" "month" "01/04/2011" "reading" 0.75}
-                          {"device_id" "01" "month" "01/05/2011" "reading" 0.65}
-                          {"device_id" "01" "month" "01/06/2011" "reading" 0.50}
-                          {"device_id" "01" "month" "01/07/2011" "reading" 0.55}
-                          {"device_id" "01" "month" "01/08/2011" "reading" 0.6}
-                          {"device_id" "01" "month" "01/09/2011" "reading" 0.66}
-                          {"device_id" "01" "month" "01/10/2011" "reading" 0.68}
-                          {"device_id" "01" "month" "01/11/2011" "reading" 0.71}
-                          {"device_id" "01" "month" "01/12/2011" "reading" 0.9}]
-                "02"     [{"device_id" "02" "month" "01/01/2011" "reading" 6}
-                          {"device_id" "02" "month" "01/02/2011" "reading" 10}
-                          {"device_id" "02" "month" "01/03/2011" "reading" 12}
-                          {"device_id" "02" "month" "01/04/2011" "reading" 15}
-                          {"device_id" "02" "month" "01/05/2011" "reading" 18}
-                          {"device_id" "02" "month" "01/06/2011" "reading" 20}
-                          {"device_id" "02" "month" "01/07/2011" "reading" 25}
-                          {"device_id" "02" "month" "01/08/2011" "reading" 31}
-                          {"device_id" "02" "month" "01/09/2011" "reading" 20}
-                          {"device_id" "02" "month" "01/10/2011" "reading" 17}
-                          {"device_id" "02" "month" "01/11/2011" "reading" 12}
-                          {"device_id" "02" "month" "01/12/2011" "reading" 9}]})
+(def mock-data {"01"     [{"device_id" "01" "device_name" "External temperature" "month" "01/01/2011" "reading" 0.8}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/02/2011" "reading" 0.9}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/03/2011" "reading" 0.8}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/04/2011" "reading" 0.75}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/05/2011" "reading" 0.65}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/06/2011" "reading" 0.50}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/07/2011" "reading" 0.55}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/08/2011" "reading" 0.6}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/09/2011" "reading" 0.66}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/10/2011" "reading" 0.68}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/11/2011" "reading" 0.71}
+                          {"device_id" "01" "device_name" "External temperature" "month" "01/12/2011" "reading" 0.9}]
+                "02"     [{"device_id" "02" "device_name" "External humidity" "month" "01/01/2011" "reading" 6}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/02/2011" "reading" 10}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/03/2011" "reading" 12}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/04/2011" "reading" 15}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/05/2011" "reading" 18}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/06/2011" "reading" 20}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/07/2011" "reading" 25}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/08/2011" "reading" 31}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/09/2011" "reading" 20}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/10/2011" "reading" 17}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/11/2011" "reading" 12}
+                          {"device_id" "02" "device_name" "External humidity" "month" "01/12/2011" "reading" 9}]})
 
 ;;;;;;;;; Utils ;;;;;;;;;;;;;;;;;;;;;;
 

               (.removeChild n (.-lastChild n))))
         (let [Chart        (.-chart dimple)
               svg          (.newSvg dimple "#chart" 500 450)
               measurements (apply concat (vals (select-keys mock-data (:selected cursor)))) 
               dimple-chart (Chart. svg (clj->js measurements))]
          (.setBounds dimple-chart 60 30 400 300) 
          (.addCategoryAxis dimple-chart "x" "month")
          (.addMeasureAxis dimple-chart "y" "reading")
          (.addSeries dimple-chart "device_id" js/dimple.plot.line)
          (.addLegend dimple-chart 60 10 300 20 "right")
          (.draw dimple-chart))))))


        (dom/div nil
                 (dom/div #js {:id "chart" :width 500 :height 450})
                 (dom/table #js {:id "form-table" :cellSpacing "10"}
                            (let [cols {:left "Left axis plots" :right "Right axis plots"}]
                               (dom/tr nil
                                       (for [col cols]
                                         (dom/td nil
                                                 (dom/h4 nil (val col))
                                                 (dom/form nil
                                                           (for [device (get cursor :devices)]
                                                             (let [device-id   (str (:hecuba/name device))
                                                                   device-name (str (:name device))
                                                                   device-ref  (str (:red device))]
                                                               (dom/div nil
                                                                        (dom/input #js {:type "checkbox"
                                                                                        :ref device-ref
                                                                                        :value device-id
                                                                                        :onChange (fn [e]
                                                                                                   (om/update! cursor update-in [:selected (key col)] (if (.. e -target -checked) conj disj) device-id))})
                                                                        (dom/label #js {:htmlFor device-id} device-name)
                                                                        (dom/br #js {}))))))))))))
      om/IDidUpdate
