Skip to content

rollacaster/hiccup-d3

Repository files navigation

hiccup-d3 provides D3 charts written in ClojureScript.

Usage

This is not a library. Just copy one of the examples as a starting point for your chart: https://rollacaster.github.io/hiccup-d3/.

The example code assumes D3 is already required.

Rationale

Transforming a D3 example from Observable to ClojureScript is repetitive work

D3 can only process JavaScript data structures but to use the result you need to transform it into Clojure data structures. A common solution is to transform them into hiccup. Every time I start a new chart I repeat this task, to avoid this I created hiccup-d3 to have a common starting point for D3 charts.

hiccup-d3 is no wrapper library

Interop between ClojureScript and JavaScript works well. Therefore, I did not want to create a wrapper which would add additional abstractions. Parts of D3 are written in an idiomatic Clojure style and focus on transforming data. Only those parts are part of hiccup-d3. Maybe I’ll try to write a library for the other parts in the future.