Permalink
Browse files

Update VREPL dependencies and samples.

  • Loading branch information...
1 parent 2b5791f commit d307c778dcdc71a417b4c95efac01c1199f9973d @lynaghk committed May 11, 2012
View
@@ -11,8 +11,8 @@ Serves up the final form of the most recently changed file in `resources/samples
If you don't have Leiningen installed, you can download the pre-built JAR file:
- wget http://keminglabs.com/c2/vrepl-1.1.0-standalone.jar
- java -jar vrepl-1.1.0-standalone.jar --extract
+ wget http://keminglabs.com/c2/vrepl-1.1.1-standalone.jar
+ java -jar vrepl-1.1.1-standalone.jar --extract
which will extract pre-built sample visualizations to the default `samples/` directory and start watching.
Change any files in there (or add a new ones) to update the web server visualization.
View
@@ -1,14 +1,14 @@
-(defproject vrepl "1.1.0"
+(defproject vrepl "1.1.1"
:description "Standalone C2 Visual REPL / webserver."
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/data.json "0.1.2"]
[org.clojure/tools.cli "0.2.1"]
[org.apache.commons/commons-vfs2 "2.0"]
- [compojure "1.0.1"]
+ [compojure "1.0.3"]
[hiccup "1.0.0"]
[aleph "0.2.1-beta2"]
- [com.keminglabs/vomnibus "0.1.0"]
- [com.keminglabs/c2 "0.1.0-beta2"]]
+ [com.keminglabs/vomnibus "0.3.0"]
+ [com.keminglabs/c2 "0.1.0"]]
:min-lein-version "2.0.0"
:main vrepl.main)
@@ -1,5 +1,5 @@
(ns bars
- (:use [c2.core :only [unify style]])
+ (:use [c2.core :only [unify]])
(:require [c2.scale :as scale]))
@@ -10,7 +10,7 @@
[:div#bars
(unify data (fn [[label val]]
- [:div {:style (style {:height bar-height
- :width (s val)
- :background-color "gray"})}
+ [:div.bar {:style (str "height: " bar-height ";"
+ "width: " (s val) ";"
+ "background-color: gray;")}
[:span {:style "color: white;"} label]]))])
@@ -1,7 +1,6 @@
(ns boxplot
- (:use [c2.core :only [unify style]]
+ (:use [c2.core :only [unify]]
[c2.maths :only [sin cos Tau extent]]
- [c2.util :only [half]]
[c2.svg :only [translate]]
[clojure.string :only [join]])
(:require [c2.scale :as scale]))
@@ -11,42 +10,42 @@
group-width 30
box-width 20
data (repeatedly (/ width group-width)
- #(into {} (map vector
- [:min :q5 :q10 :q25 :median :q75 :q90 :q95 :max]
- (sort (take 9 (repeatedly rand))))))
+ #(into {} (map vector
+ [:min :q5 :q10 :q25 :median :q75 :q90 :q95 :max]
+ (sort (take 9 (repeatedly rand))))))
s (scale/linear :domain (extent (flatten (map vals data)))
;;Note the range is [height, 0]; since in SVG the origin is at the top of the element.
:range [height 0])]
(defn box-width-line [y-position]
[:line {:x1 0 :x2 box-width
:y1 y-position :y2 y-position}])
-
- [:svg#main {:style (style {:display "block"
- :margin "auto"
- :height height
- :width width})}
+
+ [:svg#main {:style (str "display: block;"
+ "margin: auto;"
+ "height:" height ";"
+ "width:" width ";")}
[:style {:type "text/css"}
(join "\n" [ "<![CDATA["
".box {fill: #222222; stroke: white; }"
"line {stroke: white;}"
"line.range {stroke-dasharray: 5,5;}"
"]]>"])]
-
+
(unify (map-indexed vector data)
(fn [[idx {:keys [min q10 q25 median q75 q90 max]}]]
[:g.boxplot {:transform (translate [(* idx group-width) 0])}
;;line spanning the 10th and 90th percentile
[:g.range
- [:line.range {:x1 (half box-width) :x2 (half box-width)
- :y1 (s q10) :y2 (s q90)}]
+ [:line.range {:x1 (* 0.5 box-width) :x2 (* 0.5 box-width)
+ :y1 (s q10) :y2 (s q90)}]
(box-width-line (s q10))
(box-width-line (s q90))]
;;box from the 25th to 75th percentile
[:rect.box {:x 0 :y (s q75)
:height (- (s q25) (s q75)) :width box-width}]
-
+
(box-width-line (s median))]))])
@@ -1,6 +1,5 @@
(ns bullet
- (:use [c2.core :only [unify style]]
- [c2.util :only [half]])
+ (:use [c2.core :only [unify]])
(:require [c2.scale :as scale]
[vomnibus.color-brewer :as color-brewer]))
@@ -57,13 +56,13 @@
(map (fn [[idx m]]
[:rect {:class (str "measure s" idx)
:height measure-height, :width (s m)
- :y (half (- range-height measure-height))}])
+ :y (* 0.5 (- range-height measure-height))}])
(map-indexed vector (sort > measures)))
;;Markers
(map (fn [[idx m]]
[:rect.marker {:height marker-height, :width 2
- :x (s m), :y (half (- range-height marker-height))}])
+ :x (s m), :y (* 0.5 (- range-height marker-height))}])
(map-indexed vector (sort > markers)))]
]))))
@@ -1,18 +1,22 @@
(ns choropleth
- (:use [c2.core :only [unify style]]
+ (:use [c2.core :only [unify]]
[c2.maths :only [extent floor]]
[c2.geo.core :only [geo->svg]]
[c2.geo.projection :only [albers-usa]]
- [vomnibus.geo.us :only [states]])
+ [vomnibus.geo.us.states :only [states]])
(:require [c2.scale :as scale]
[vomnibus.color-brewer :as color-brewer]))
-(let [data (into {} (map vector (keys states) (repeatedly rand)))
+(let [data (map (fn [[state geo]]
+ {:state state
+ :geo geo
+ :value (rand)})
+ states)
color-scheme color-brewer/Greens-9
- color-scale (let [s (scale/linear :domain (extent (vals data))
+ color-scale (let [s (scale/linear :domain (extent (map :value data))
:range [0 (dec (count color-scheme))])]
;;todo: build interpolators so scales handle non-numeric ranges
(fn [d] (nth color-scheme (floor (s d)))))
@@ -26,8 +30,9 @@
[:g.states
(unify data
- (fn [[state-name val]]
- [:path.state {:d (geo->svg (get states state-name)
+ (fn [{:keys [state geo value]}]
+ [:path.state {:name state
+ :d (geo->svg geo
:projection proj)
:stroke "black"
- :fill (color-scale val)}]))]])
+ :fill (color-scale value)}]))]])
@@ -1,44 +1,44 @@
(ns pie
(:refer-clojure :exclude [partition]) ;;avoid name conflict with base "partition" function
- (:use [c2.core :only [unify style]]
+ (:use [c2.core :only [unify]]
[c2.maths :only [sin cos Tau]] ;;Life's short, don't waste it writing 2*Pi
[c2.svg :only [arc]]
[c2.layout.partition :only [partition]]))
(let [data {:name "Delicious Pie"
- :children [{:name "Eaten" :bites 11}
- {:name "Not Eaten" :bites 39}
- {:name "Silverware" :bites 8}]}
+ :children [{:name "Eaten" :bites 11}
+ {:name "Not Eaten" :bites 39}
+ {:name "Silverware" :bites 8}]}
;;Partition will give us entries for every node, but we only want slices.
- slices (filter #(-> % :partition :depth (= 1))
+ slices (filter #(-> % :partition :depth (= 1))
(partition data :value :bites, :size [Tau 1]))
radius 170]
-
+
[:svg
[:g {:transform "translate(200,200)"}
(unify slices
- (fn [{name :name, bites :bites
- {:keys [x dx]} :partition}]
- [:g.slice
- [:path {:d (arc :outer-radius radius
- :start-angle x
- :end-angle (+ x dx))
-
- ;;Style inline if you want, or use classes+CSS
- :style (style {:stroke "black"
- :fill (case name
- "Eaten" "yellow"
- "Not Eaten" "tan"
- "Silverware" "silver")})}]
- ;;Make a label.
- ;;SVG doesn't support radial coordinates, so this is a bit ugly...
- (let [label-angle (+ x (/ dx 2))]
- [:text {:x (* 0.5 radius (cos label-angle))
- :y (* 0.5 radius (sin label-angle))
- :text-anchor (condp > (mod label-angle Tau)
- (* Tau 0.25) "start"
- (* Tau 0.75) "end"
- Tau "start")}
- (str name)])]))]])
+ (fn [{name :name, bites :bites
+ {:keys [x dx]} :partition}]
+ [:g.slice
+ [:path {:d (arc :outer-radius radius
+ :start-angle x
+ :end-angle (+ x dx))
+
+ ;;Style inline if you want, or use classes+CSS
+ :style (str "stroke: black;"
+ "fill: " (case name
+ "Eaten" "gray"
+ "Not Eaten" "tan"
+ "Silverware" "silver") ";")}]
+ ;;Make a label.
+ ;;SVG doesn't support radial coordinates, so this is a bit ugly...
+ (let [label-angle (+ x (/ dx 2))]
+ [:text {:x (* 0.5 radius (cos label-angle))
+ :y (* 0.5 radius (sin label-angle))
+ :text-anchor (condp > (mod label-angle Tau)
+ (* Tau 0.25) "start"
+ (* Tau 0.75) "end"
+ Tau "start")}
+ (str name)])]))]])
@@ -1,6 +1,6 @@
(ns sunburst
(:refer-clojure :exclude [partition]) ;;avoid name conflict with base "partition" function
- (:use [c2.core :only [unify style]]
+ (:use [c2.core :only [unify]]
[c2.maths :only [sqrt sin cos Tau]] ;;Life's short, don't waste it writing 2*Pi
[c2.svg :only [arc]]
[c2.layout.partition :only [partition]]

0 comments on commit d307c77

Please sign in to comment.