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?
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?
Share Improve this question edited Mar 31, 2014 at 19:11 albusshin 4,0103 gold badges32 silver badges59 bronze badges asked Mar 31, 2014 at 19:04 sunspotssunspots 1,05713 silver badges30 bronze badges 3- Basically anything that can be implemented using JavaScript can be implemented using ClojureScript. Also, you should show us your work before asking such a question here. – albusshin Commented Mar 31, 2014 at 19:12
- FYI: There is also C2, a D3-inspired data visualization library for Clojure and ClojureScript. keminglabs./c2 – leontalbot Commented Mar 31, 2014 at 20:20
- Also strokes, which is intended to make it easier to use d3.js from Clojurescript. – Mars Commented Aug 7, 2014 at 4:54
1 Answer
Reset to default 8Yes, 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./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./ClojureScript-Up-Running-Stuart-Sierra/dp/1449327435/ (disclaimer, I am one of the authors)