Question

I'd like to learn how to run JavaScript through Clojure and in particular implement this D3 graph in Clojure.

In my attempt to implement the above graphing method I encountered ClojureScript. However, I have been unsuccessful in its usage for the problem at hand.

Is ClojureScript the right way to go? If so, how would I implement the above D3 graph?

Was it helpful?

Solution

Yes, you will need to use ClojureScript. D3 is a JavaScript library, not a Java one, so to use it you'll need to be running in a browser environment, which is what ClojureScript is for.

Then all you need to do is call the D3 api via ClojureScript's interoperability forms. Explaining how to do that at length is beyond the scope of this question.

Some resources to get you started:

Introduction to ClojureScript <-> JavaScript interoperability: https://lambdaisland.com/episodes/clojurescript-interop

David Nolen's excellent blog series on ClojureScript: http://swannodette.github.io/2013/11/07/clojurescript-101

ClojureScript: Up and Running: http://www.amazon.com/ClojureScript-Up-Running-Stuart-Sierra/dp/1449327435/ (disclaimer, I am one of the authors)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top