Skip to content

Commit

Permalink
more flexible viz function
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Oct 28, 2021
1 parent f437c6b commit b23d7a6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/scicloj/viz/api.clj
Expand Up @@ -14,8 +14,13 @@
"boxplot" vt/boxplot-chart})

(defn viz
[& options-maps]
(let [options (apply merge options-maps)
[base-options & args]
(let [arg1 (first args)
additional-options (cond (nil? arg1) {}
(map? arg1) (apply merge args)
(keyword? arg1) (apply hash-map args))
options (merge base-options
additional-options)
typ (:type options)]
(-> (apply hc/xform
(if (map? typ) typ
Expand Down Expand Up @@ -59,6 +64,13 @@
{:UDATA (as-url data)}
(instance? tech.v3.dataset.impl.dataset.Dataset data)
{:UDATA (as-url data)}
(or (and (sequential? data)
(every? map? data))
(and (map? data)
(every? sequential? data)))
{:UDATA (-> data
tmd/->dataset
as-url)}
:else {:DATA data}))

(defn type
Expand Down

0 comments on commit b23d7a6

Please sign in to comment.