001 (ns org.clojars.punit-naik.vega-clj
002 (:require [clojure.string :as str]
003 [clojure.walk :as walk]
004 [oz.core :as oz]))
005
006 (defn hex->rgb
007 [colour]
008 (->> (rest colour)
009 (partition-all 2)
010 (map (comp read-string str/join #(conj % "0x")))))
011
012 (defn convert-colours-to-rgb
013 "Coverts HEX colour strings to RGB values"
014 [vl-spec]
015 (walk/postwalk
016 (fn [x]
017 (if (and (map? x)
018 (contains? x :range))
019 (update x :range (partial map hex->rgb)) x))
020 vl-spec))
021
022 (defn plot
023 [spec]
024 (-> spec
025 convert-colours-to-rgb
026 oz/view!))