Clojurescript, JavaScript, SVG, Graphics, Graphics

I am writing a client-side application. I want to use ClojureScript. I would like to generate vector graphics (graphics, charts, line graphs).

What should i read?

[The only strict requirement is ClojureScript - (1) I like Clojure, and I would like to make this entire application in Clojure (2) it needs to be run in a browser]

Thanks!

+8
javascript clojure svg clojurescript
source share
4 answers

Shameless plugin. You can use C2 , the Clojure / ClojureScript data visualization library. (Github here .) The basic idea is the same as D3 --- mapping data to DOM elements --- but since you have Clojure's more powerful semantics and data structures, it gets a lot more complicated than D3 / JavaScript.

Documents can use some love, but if you are creating traditional charts in SVG, look at the axis and tick generation helpers:

https://github.com/lynaghk/c2/blob/master/src/cljx/c2/svg.cljx

https://github.com/lynaghk/c2/blob/master/src/cljx/c2/ticks.cljx

While there is no official version 0.1.0 yet, we used it in Keming Labs in several large projects on the Internet and iOS.

If you have a specific visualization that you don’t know how to approach, feel free to ping me @lynaghk or open the Github issue.

+12
source share

Since regular javascript libraries can be used in clojurescript, I think you can use something like Raphael or d3 to work with svg. d3 is probably better suited for what you need, although it's a little harder to use.

There is always an alternative to working with the DOM directly, for this you do not need tutorials. the SVG standard is pretty well structured and easy to understand.

+3
source share

This is an old question, but for those who find it now, another option is to use the touches of a library that was not available when the question was asked. Strokes - Clojure wrapper around d3.js.

+1
source share

I would recommend getting to know Vega-Lite and Vega, which are based on the ideas of grammar graphics (the power behind the popular ggplot2 R library). The main idea of ​​GG is that data visualizations are defined as declarative descriptions of how data properties correspond to the aesthetics of dataviz. Vega-Lite and Vega take it one step further by providing an interaction grammar that allows you to create interactive data visualizations and complex explorer views. Moreover, he raises the emphasis on the declarative nature of GG in the sense that the specifications of Vega-Lite and Vega are described as pure data (JSON), which makes it very consistent with the data-based philosophy in the Clojure world, and paves the way for seamless interaction with different languages ​​and the like.

Vega-Lite is a more or less high-tech data analysis tool focused on providing high leverage and automation based on highly Spartan specifications. It compiles into Vega, which is a slightly lower level and more powerful but less automated version of Vega-Lite. Usually it’s enough to start with Vega-Lite and switch to Vega only as needed.

For more information about Vega and Vega-Lite, see: https://vega.imtqy.com .

If you want to use Vega-Lite or Vega from Clojure or ClojureScript, you can use the small but flexible wrapper library that I wrote and called Oz:

https://github.com/metasoarous/oz

0
source share

All Articles