clerk

jumar 2024-06-13T07:24:11.845149Z

I'm generating about a hundred of small histograms and would like to show them all at once. My code looks basically like this

(mapv (fn [[data]] (histogram! data))
      datas)

(defn histogram! [data]
  (clerk/html
   {::clerk/width :full}
   [:div
    [:h3 "Histogram"]
    (clerk/vl
     {::clerk/width :full}
     :data {:values data}
     :mark "bar"
     :encoding {,,,})]))
WHen it's rendered it shows some of them but the rest is hidden under "76 more..." Is there a way to expand it automatically?

Andrea 2024-06-14T09:41:59.242669Z

Iirc you might want to try something like:

^{::clerk/page-size nil}
(repeat 100 histogram)

Andrea 2024-06-14T09:43:46.929369Z

But in all above examples, you’d still see the histograms inside a collection viewer. Maybe clerk/fragment is what you need instead:

(apply clerk/fragment (repeat 100 histogram))

teodorlu 2024-06-13T08:37:22.211829Z

I think maybe you’re looking for

^{:nextjournal.clerk/auto-expand-results? true}
, something like
^{:nextjournal.clerk/auto-expand-results? true}
(mapv (fn [[data]] (histogram! data))
      datas)

(defn histogram! [data]
  (clerk/html
   {::clerk/width :full}
   [:div
    [:h3 "Histogram"]
    (clerk/vl
     {::clerk/width :full}
     :data {:values data}
     :mark "bar"
     :encoding {,,,})]))
in your context.

teodorlu 2024-06-13T08:37:56.983869Z

More info in the book https://book.clerk.vision/#presentation

teodorlu 2024-06-13T08:40:03.081299Z

Looks like you need to set the viewer budget to infinite (`nil`) too.

^{::clerk/budget nil ::clerk/auto-expand-results? true}
https://book.clerk.vision/#viewer-budget

2024-06-13T09:07:18.312769Z

@teodorlu 🙏 for helping 😊

❤️ 1
jumar 2024-06-13T13:16:42.140809Z

@teodorlu thanks a lot for the advice. I've tried this but for some reason it's not working

^{::clerk/budget nil ::clerk/auto-expand-results? true}
(mapv (fn [...]
        (histogram! ...
It still hides the results on the more... button. I also tried to put it into ns meta
(ns notebooks
  {:nextjournal.clerk/visibility {:code :hide :result :show}
   :nextjournal.clerk/budget nil :nextjournal.clerk/auto-expand-results? true}
...)

🤔 1
teodorlu 2024-06-13T13:38:39.722159Z

I don’t have any good ideas off the top of my head. Perhaps can a screenshot of your document as rendered by Clerk?

jumar 2024-06-13T14:50:56.221629Z

I’ll try to create a minimal reproducer since this is sensitive data and the actual code is a bit more complicated

👍 1
jumar 2024-06-16T07:51:36.489869Z

@andrea712 thanks for the tips - page-size nil finally solved my problem 🙂