In my previous blog post Vega-Lite Experimentation Bench, I described building an experimentation bench in which I can use Clojure/script to study and learn to use various chart types provided by Vega. In this second part, I describe the backend of the system and some first experiments with the visualization bench.
I implemented a simple backend for the Vega-Lite Experimentation Bench. You can find the backend in the clj directory of that project. The backend comprises of the routes, integrant state (
main.clj), and the data package in which I add data sets. In the data package you can find the cars.clj data set which I downloaded from the Vega github repository (cars.json), and processed a bit (removed nil values). I also cache the data set in the backend (using simple atom) so that I’m not downloading it allover again when hitting my Integrant hotkey. I also created another data set seattle_weather.clj (original data set in seattle-weather.csv) for experimentation purposes.
Cars Data Set Exercises
Using my Vega-Lite Experimentation Bench, I decided to do the exercises demonstrated in the excellent Observable: Vega-Lite: A Crash Course video tutorial. The first exercise is a scatter diagram using the cars data set. You can see the simple scatter chart on the left and a more complex scatter chart on the right (see here the original Vega spec). The second row shows a column-based diagram, and then some statistical functions applied (
Seattle Weather Data Set Exercises
After the cars data set, the lecturer uses weather data. I found the data set in Vega github repo: seattle-weather.csv. I did some simple transforming in seattle_weather.clj. Then I experimented with the same charts as the lecturer did (with some of my modifications):
It was fun to create the Vega Experimentation Bench and then use it for experimenting with Vega. The Vega visualization library is really expressive, but the power comes with some complexity. The best way to learn the Vega library is to experiment with it.
The writer is working at Metosin using Clojure in cloud projects. If you are interested to start a cloud or Clojure project in Finland or you are interested getting cloud or Clojure training in Finland you can contact me by sending an email to my Metosin email address or contact me via LinkedIn.
- Kari Marttila’s Home Page in LinkedIn: https://www.linkedin.com/in/karimarttila/