001 (ns org.clojars.punit-naik.data-transformations)
002
003 (defn apply-aggregate
004 "Adds a vega aggregate element in the Vega-lite spec"
005 [vl-spec
006 {:keys [fld-name fld-alias grp-by-flds op]
007 :or {fld-alias (str fld-name "_agg")}}]
008 (update vl-spec :transform conj {:aggregate
009 [{:op op :field fld-name :as fld-alias}]
010 :groupby (if (coll? grp-by-flds)
011 grp-by-flds
012 [grp-by-flds])}))
013
014 (defn do-calculation
015 "Does a calculation on some fields in the data in the Vega-lite spec"
016 [vl-spec
017 {:keys [calc-str calc-fld-alias]}]
018 (update vl-spec :transform conj {:calculate calc-str :as calc-fld-alias}))
019
020 (defn apply-filter
021 "Applies filter on the Dataset in the Vega-lite spec"
022 [vl-spec filter-clauses]
023 (update vl-spec :transform conj {:filter filter-clauses}))