Created
November 17, 2015 11:48
-
-
Save wmealing/fa8270804e3492d19969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns testing.ns | |
(:require [reagent.core :as reagent :refer atom] | |
[cljsjs.chartist :as ch) | |
(def overview-yearly-data (clj->js | |
{:series [ [10 1 13 2 5 3 7 4 9 12 2 3]] | |
:labels ['Jan' 'Feb' 'Mar' 'Apr' 'May' | |
'Jun' 'Jul' 'Aug' 'Sep' 'Oct' | |
'Nov' 'Dec']} | |
)) | |
(def overview-yearly-options (clj->js {:seriesBarDistance true | |
:axisY {:onlyInteger "true"} | |
:high 18})) | |
(defn yearly-overview-chart [year threshold] | |
(let [chart (js/Chartist.Bar (js/document.getElementById "yearly-overview-div") | |
overview-yearly-data | |
overview-yearly-options)] | |
(do | |
(.on chart "draw" (fn [context] | |
(if (is-bar? context) | |
(do | |
(choose-color? ((js->clj(aget context "value")) "y") ; extract the "y".. | |
threshold ; threshold | |
context ; context to modify. | |
)) | |
(comment "nothing") | |
))) | |
))) | |
(defn overview [] | |
(paper-box "overview" menu-cursor | |
[:div | |
[:h3 "Water usage"] | |
[:div {:class "year-data"} "Year 2015"] | |
[:div {:id "yearly-overview-div" :class "ct-chart ct-perfect-fourth"}]]) | |
(yearly-overview-chart 2015 5) | |
(reagent/render-component [main-app] (. js/document (getElementById "app"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment