Created
January 18, 2014 20:26
-
-
Save msgodf/8495781 to your computer and use it in GitHub Desktop.
Full Rickshaw Example in Clojurescript
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
;; Original example (in Javascript) at: http://code.shutterstock.com/rickshaw/examples/lines.html | |
(def graph-with-legend | |
(let [series-data (array (array) (array) (array)) | |
random (Rickshaw.Fixtures.RandomData. 150)] | |
(dotimes [i 150] | |
(.addData random series-data)) | |
(doto | |
(Rickshaw.Graph. (clj->js {:element (.getElementById js/document "chart") | |
:renderer "line" | |
:width 960 | |
:height 500 | |
:series [{:color "#c05020" | |
:data (nth series-data 0) | |
:name "Tokyo"} | |
{:color "#30c020" | |
:data (nth series-data 1) | |
:name "London"} | |
{:color "#6060c0" | |
:data (nth series-data 2) | |
:name "New York"}]})) | |
(.render)))) | |
(def hover-detail | |
(Rickshaw.Graph.HoverDetail. (clj->js {:graph graph-with-legend}))) | |
(def legend | |
(Rickshaw.Graph.Legend. (clj->js {:graph graph-with-legend | |
:element (.getElementById js/document "legend")}))) | |
(def shelving | |
(Rickshaw.Graph.Behavior.Series.Toggle. (clj->js {:graph graph-with-legend | |
:legend legend}))) | |
(def highlight | |
(Rickshaw.Graph.Behavior.Series.Highlight. (clj->js {:graph graph-with-legend | |
:legend legend}))) | |
;; Behaviour.Series.Order requires jQuery UI | |
#_(def order (Rickshaw.Graph.Behavior.Series.Order (clj->js {:graph graph-with-legend | |
:legend legend}))) | |
(def axes | |
(doto | |
(Rickshaw.Graph.Axis.Time. (clj->js {:graph graph-with-legend})) | |
(.render))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment