vega-viewer is an experimental Om component that accepts a vega specification parsed into a Clojure data structure and renders the resulting chart.
(def vega-spec
(atom {:width 200
:height 200
:data [{:name "fruits"
:values [{"name" "apple"
"number" 23}
{"name" "oranges"
"number" 42}]}]
:scales [{:name "category"
:type "ordinal"
:domain {:data "fruits" :field "name"}
:range "width"}
{:name "frequency"
:type "linear"
:range "height"
:domain {:data "fruits" :field "number"}}]
:axes [{:scale "frequency" :type "y"}
{:scale "category" :type "x"}]
:marks [{:from {:data "fruits"}
:type "rect"
:properties {:enter {:x {:scale "category" :field "name"}
:width {:scale "category"
:band true
:offset -1}
:y {:scale "frequency" :field "number"}
:y2 {:scale "frequency" :value 0}}
:update {:fill {:value "steelblue"}}}}]}))
(om/build vega-viewer vega-spec)
Run lein-figwheel
in the project root to explore the included devcard
Copyright © 2018 Ona
Distributed under the MIT License.
Can you improve this documentation? These fine people already did:
Peter Lubell-Doughtie, Okal Otieno & pldEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close