Database Reference
In-Depth Information
weight-total (sum-by #(.-weight %) items)]
(webviz/Point. diet weight-total 1)))
(defn get-diet-weights [diet-groups]
(apply array (map weight-point diet-groups)))
6.
Here's the function that will transform the JSON input into JavaScript objects for
NVD3:
(defn json->nv-groups [json]
(let [diet-groups (group-by #(.-diet %) json)]
(array (webviz/Group.
"Chick Counts"
(get-diet-counts diet-groups))
(webviz/Group.
"Chick Weights"
(get-diet-weights diet-groups)))))
7.
Finally, here's the function that ties it all together and creates the chart (with the help
of create-chart ):
(defn ^:export bar-chart []
(webviz/create-chart "/barchart/data.json"
"#barchart svg"
#(.multiBarChart js/nv.models)
json->nv-groups))
When we visit http://localhost:3000/barchart , here's what we will get:
 
Search WWH ::




Custom Search