metasoarous / oz

Data visualizations in Clojure and ClojureScript using Vega and Vega-lite
Eclipse Public License 1.0
828 stars 74 forks source link

Compile list/sexpr values to Veg(Lite) expressions #161

Open metasoarous opened 3 years ago

metasoarous commented 3 years ago

See #119

It would be nice if Oz users could use quotes list sexprs to represent their calculations and filters (etc?) instead of having to write psuedo-JS strings. This may not actually be too hard to support.

The list of operations we have to support are here: https://github.com/vega/vega/blob/master/packages/vega-expression/src/parser.js#L359-L453

Those can be specifically handled, with variadic arity handled by recursively nesting calls to the corresponding operation in the produced JS strings.

if expressions actually translate pretty naturally as with other "function" (ahem) like calls, since there's an if(cond, this, that) expression supported.

Using a keyword in function position can translate to object lookup: (:some-attr datum) => datum["some-attr"].