Clojure(Script) bindings to C2PO
JavaScript Clojure
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


C2PO Clojure language bindings

C2PO is a grammar of graphics implementation inspired by Hadley Wickham's ggplot2 library. This Clojure package uses the free online C2PO compiler and is limited to 1 MB of data. Plot specifications are compiled directly to an SVG string, which is returned:

(require '[c2po.core :refer [c2po]]
         '[c2po.geom :as geom])

(def scatterplot {:data (repeatedly 20 #(hash-map :this (rand) :that (rand)))
                  :mapping {:x :this :y :that}
                  :geom (geom/point :opacity 0.5)})

;;The C2PO server returns an SVG string with embedded CSS.
;;You can view it by saving it to disk and opening in a browser:
(spit "rad_scatterplot.svg" (c2po scatterplot))

;;Alternatively, you can use the built-in livereload web server:
(require '[c2po.core :refer [render!]])
(render! scatterplot)
;;which puts your plot at http://localhost:8987
;;Additional calls to `render!` will automatically refresh the browser.

Clone this repository, start a swank or nrepl server against /project.clj, and walk through examples/1-usage.clj for a more detailed tutorial.

This is an experimental package; the package API, plot specification syntax, and remote server may change or disappear at any time.


Add to your project.clj:

[com.keminglabs/c2po "0.1.0-SNAPSHOT"]

If you don't want any of the livereload bits, you can use

[com.keminglabs/c2po-core "0.1.0-SNAPSHOT"]