Does anyone know of any DSLs or similar that are specific to graph/chart drawing? I.e. a language that defines a function from data to image, specialised toward visualising data?
If not, what’s the closest thing? E.g. is there a JS chart-drawing library with an API that feels close to a DSL?
vega.github.io and vega.github.io/vega-lite count?
📝 Vega: A Visualization Grammar
Vega is a declarative format for creating, saving, and sharing visualization designs. With Vega, visualizations are described in JSON, and generate interactive views using either HTML5 Canvas or SVG.
📝 A High-Level Grammar of Interactive Graphics
Vega-Lite - a high-level grammar for statistical graphics. Vega-Lite provides a higher-level grammar for visual analysis, comparable to ggplot or Tableau, that generates complete Vega specifications. Vega-Lite specifications consist of simple mappings of variables in a data set to visual encoding channels such as x, y, color, and size. These mappings are then translated into detailed visualization specifications in the form of Vega specification language. Vega-Lite produces default values for visualization components (e.g., scales, axes, and legends) in the output Vega specification using a rule-based approach, but users can explicit specify these properties to override default values.
vega has json-schemas for its configs, but those are huge
vega.github.io/schema/vega-lite/v4.json
so if you fancy some clojure, I got draft lib github.com/akovantsev/json-schema-to-clojure-spec
specifically to explore those schemas in repl
(I don't remember if it handled schemas of such size though :))
vega, plot, ggplot, all based off "grammar of graphics" which defines a conceptual toolbox for data -> pixel space.
📝 Graphviz
Please join the Graphviz forum to ask questions and discuss Graphviz. What is Graphviz? Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics, software engineering, database and web design, machine learning, and in visual interfaces for other technical domains.
📝 Penrose
Create beautiful diagrams just by typing math notation in plain text.
I've done a thing some time ago that may be relevant: compostjs.github.io/compost
It is fairly small composable DSL for composing visualizations - unlike grammar of graphics libraries (vega), it is more low-level and you construct graphical primitives yourself - but it handles mapping of units from "domain units" to pixels (where domain units can be continuous or categorical) - so the idea is to have something that is a sweet spot between low level drawing and high-level (Vega, D3, etc) libraries...
📝 Compost.js: Composable data visualization library
Compost is a data visualization library that lets you compose rich interactive data visualizations from a small number of basic primitives. The library is based on the functional programming idea of composable domain-specific languages. Compost is simple (implemented in just 700 lines of code) and easy to understand. Compost is a plain JavaScript library. You use it by writing JavaScript code that generates a chart using some 15 basic Compost primitives.
Thank you, Vega does look pretty close to what I’m describing, if one considers that giant JSON schemas like this are standing in for what could probably be a nice and tidy special-purpose language. I will investigate further.
schemas are "grammar of a language", not a "message written in a language".