Fork me on GitHub

@carsten.behring don’t see why not but also not likely that I will spend time on. OTOH search and column sorting is something we planned (and spent some time on in the past) already.

Carsten Behring11:02:39

I see that. I am completely new to Clojurescript, and I was just wondering if the "viewer API" of Clerk is powerful enough to even included rather easely a complex java script package such as datatables. Or ask the other way around. The R community has developed over time and this has let to the creation of many powerful wrappers of existing java script libraries. Would you see that the "viewer" component of Clerk could go in this direction ?


if it’s not working yet it’s just a matter of exposing a few more vars to Clerk’s viewer api via sci, a tiny thing. And then there’s improving the docs and making it more obvious how to actually do it.

👍 1

I tried it, it works today but will get easier when we expose this stuff properly:


(ns d3-require
  (:require [nextjournal.clerk :as clerk]))

(clerk/with-viewer {:fetch-fn (fn [_ x] x)
                    :render-fn '(fn [value]
                                   (when value
                                     [js/nextjournal.ui.components.d3_require.with$ {:package ["[email protected]"]}
                                      (fn [vega]
                                        (let [embed (.-embed vega)]
                                          [:div {:style {:overflow-x "auto"}} ;; TODO: figure out how to make options customizable
                                           [:div.vega-lite {:ref #(when % (embed % (clj->js value) (clj->js {:actions false})))}]]))])))}
  {:width 650 :height 400 :data {:url ""
                                 :format {:type "topojson" :feature "counties"}}
   :transform [{:lookup "id" :from {:data {:url ""}
                                    :key "id" :fields ["rate"]}}]
   :projection {:type "albersUsa"} :mark "geoshape" :encoding {:color {:field "rate" :type "quantitative"}}})


the upside of Clerk’s table is that it works with Clerk’s viewer api, here’s an example of a table with a sparkline vega plot in one of the columns (,

👍 1