gyptis.core
Core Gyptis functions for generating declarative vega.js plot specifications
choropleth
(choropleth [datum & more :as data] & [{fill :fill, geopath :geopath, {:keys [type projection center translate scale precision clipAngle], :or {type "geopath", projection "albersUsa"}} :geopath-transform, :or {fill :fill, geopath :geopath}, :as opts}])
Returns a vega.js map choropleth. Each datum should have a
`geopath` key that maps to a GeoJson object val and a `fill` val
that can be represented by a quantitative scale. The
`:geopath-transform` option is passed directly to vega.
dodged-bar
(dodged-bar [datum & more :as data] & [{:keys [x y fill], :or {x :x, y :y, fill :fill}, :as opts}])
Like `stacked-bar`, except returns a vega bar plot that dodges bars
with the same y position.
facet-grid
(facet-grid {:keys [scales axes marks legends], [{data :values} & more] :data, :as vega-spec} & [{:keys [facet_x facet_y], :or {facet_x :facet_x, facet_y :facet_y}}])
Plots data with differing facet_x and facet_y values in separate
subplots. Scales are the same for each subplot.
line
(line [datum & more :as data] & [{:keys [x y stroke], :or {x :x, y :y, stroke :stroke}, :as opts}])
Returns a vega.js symbol plot. Each datum should have the `x`
and `y` keys, and optionally, `stroke`.
point
(point [datum & more :as data] & [{:keys [x y fill size], :or {x :x, y :y, fill :fill, size :size}, :as opts}])
Returns a vega.js symbol plot. Each datum should have `x` and `y`
keys, and optionally, `fill` and `size`. These keys are set in the
opts hashmap.
stacked-bar
(stacked-bar [datum & more :as data] & [{:keys [x y fill], :or {x :x, y :y, fill :fill}, :as opts}])
Given a coll of hashmaps or vectors, returns a vega bar plot that
stacks bars with the same x position. For a `stacked-bar`, each
hashmap (or vector) in data should have `x` and `y` keys as set in
the `opts` map. `fill` is optional. The `x` values are treated as
categorical and `y` values are treated as quantitative.
The following example code returns a (clojure) vega.js specification
for a bar chart with letters on the x-axis and numbers on the
y-axis:
(stacked-bar [{:my-x "a" :my-y 1}, {:my-x "b" :my-y 2}]
{:x :my-x :y :my-y})title
(title spec title-text)
Adds data and a text mark to the given spec to display the title-text.