clerk

sg-qwt 2023-10-09T06:12:17.888419Z

Does anybody know how to make a single plotly graph take up to full screen? I've set {:nextjournal.clerk/width :full} to make the graph full width, but there isn't any corresponding :nextjournal.clerk/height`` available, how do I make the graph also responsive to full height this case?

2023-10-09T07:29:28.588459Z

would wrapping a vega-lite chart in a (clerk/html {::clerk/width :full}) also make it responsive to the size of the page? I'm wondering if this might solve some of my sizing problems (though fonts are still an issue then I think)

mkvlr 2023-10-09T07:34:57.273929Z

yes, that’s full width then

sg-qwt 2023-10-09T07:55:06.244739Z

I tried to wrap it inside the fullscreen container with the docs example, still no luck. The container is green fullscreen as expected, but not the inside graph, the height is still about half the screen. Am I missing sth obvious here maybe.

(clerk/html {:nextjournal.clerk/width :full}
            [:div.h-screen.bg-green-200
             (clerk/plotly {:data [{:z [[1 2 3] [3 2 1]] :type "surface"}]
                            :layout {:margin {:l 20 :r 0 :b 20 :t 20}}
                            :config {:displayModeBar false
                                     :displayLogo false}})])
Also @otfrom, do you have any luck with vega-lite maybe with this approach?

mkvlr 2023-10-09T07:56:10.884629Z

@snow40479 think you also need to set :responsive true in the plotly config

sg-qwt 2023-10-09T07:59:55.059469Z

I think it's responsive by default. Anyway adding that :responsive true doesn't make any difference. Still only responsive in width's perpective.

2023-10-09T08:02:34.925789Z

@snow40479 I've not had a go yet. I will today and I'll report back

mkvlr 2023-10-09T08:06:26.146399Z

@snow40479 sounds like it’s a plotly issue not a clerk one then

mkvlr 2023-10-09T08:07:15.732479Z

i’d suggest trying to get it to work in https://plotly.com/javascript/responsive-fluid-layout/ first

mkvlr 2023-10-09T08:08:10.682639Z

I skimmed over https://github.com/plotly/plotly.js/issues/106 and https://github.com/plotly/plotly.js/pull/635 but the solution isn’t obvious to me

2023-10-09T08:20:47.601369Z

h-screen ends up being too big (in slide show at least) and I'm not sure how I'd do [:div.h-4/5] as hiccup really doesn't like the slash. I'll figure out how to do that.

2023-10-09T08:27:21.077619Z

I take it the div sizes are from here? https://tailwindcss.com/docs/height

👍 1
sg-qwt 2023-10-09T08:33:29.673769Z

@otfrom you can [:div {:class "h-4/5 balaba bala"}] instead

👍 1
sg-qwt 2023-10-09T08:35:48.747259Z

I guess my case it's indeed plotly issue, I found the height is fixed at 450px as mentioned in that issue, unless clerk has some ways to override that style, I'd have to hard code px height myself.

mkvlr 2023-10-09T08:36:42.354479Z

@otfrom you can use e.g. {:class "h-4/5"}

2023-10-09T09:25:27.432109Z

using (clerk/html {::clerk/width :full} [:div {:class ["h-screen" "bg-green-200"]} "hello"]) in slideshow I get this:

2023-10-09T09:25:36.323069Z

which is a bit too tall

2023-10-09T09:26:11.552659Z

using (clerk/html {::clerk/width :full} [:div {:class ["h-4/5" "bg-green-200"]} "hello"]) I get:

mkvlr 2023-10-09T09:26:54.161209Z

yeah, you probably should do some calc with 100vh

👍 1
mkvlr 2023-10-09T09:28:14.971599Z

or 80vh

sg-qwt 2023-10-09T09:30:10.307969Z

i think his issue is he needs to wrap another inside the full height one to get the actuall 4/5 height

(clerk/html {:nextjournal.clerk/width :full}
            [:div {:class "h-screen"}
             [:div {:class "h-4/5 bg-green-200"} "hello"]])

2023-10-09T09:32:40.879889Z

@snow40479 that is indeed the 🦡

2023-10-09T09:33:18.464299Z

or at least it gets the job done. I'd certainly prefer to set the div to be 80% of the viewport height

2023-10-09T09:33:52.092489Z

and doing the wrap does give me a scroll bar when I'd rather not have one

2023-10-09T09:47:56.047369Z

this works

(clerk/html {:nextjournal.clerk/width :full}
            [:div {:class ["h-[calc(100vh*0.80)]" "bg-green-200"]} "hello"])

2023-10-09T09:48:16.594529Z

2023-10-09T09:48:33.925329Z

now I just have to get vega-lite to work with it. Thx both. I've learned a lot today

sg-qwt 2023-10-09T09:50:39.428809Z

btw @otfrom, how do you make the top index bar ( served from Clerk ) go away?

sg-qwt 2023-10-09T09:52:42.136409Z

I only see {:nextjournal.clerk/visibility {:code :hide :result :show}}, there is no option to hide that bar it seems

2023-10-09T09:57:52.405759Z

@snow40479 I'm using clerk slideshow, so I wonder if that is doing it

sg-qwt 2023-10-09T09:58:39.895849Z

I see, thanks!

mkvlr 2023-10-09T10:04:13.790599Z

can paste this when I’m back at the 🧑‍💻 or maybe @andrea712 has it sooner?

2023-10-09T10:21:56.919349Z

now I'm just trying to find a way to get vega-lite to fill up the whole viewer there

2023-10-09T10:22:07.985959Z

I've never had the responsive stuff working before

2023-10-09T10:27:50.625219Z

now I'm a bit stuck as my vl canvas has a width of 0 and a height of 200. More documentation to read apparently (unless anyone here has a tip)

2023-10-09T10:47:22.662099Z

(clerk/html {:nextjournal.clerk/width :full}
            [:div {:class ["h-[calc(100vh*0.70)]" "bg-green-200"]}
             (clerk/vl
              {:nextjournal.clerk/width :full}
              {:autosize {:type "pad"}
               :data {:url ""},
               :mark "bar",
               :encoding {
                          :x {:field "Origin"},
                          :y {:aggregate "count", :title "Number of Cars"}}})])

2023-10-09T12:10:20.595249Z

hmm... I'm bumping into to many walls on this today. https://github.com/vega/vega-embed#what-css-should-i-use-to-support-container-sizing <- seems to have something to do w/it but I need to get some stuff ready for a client and what I have is good enough for that

Andrea 2023-10-09T12:37:36.185879Z

@snow40479 > how do you make the top index bar ( served from Clerk ) go away? this should do it

(ns scratch.vega
  (:require [nextjournal.clerk :as clerk]
            [nextjournal.clerk.viewer :as viewer]))

(clerk/add-viewers! [(assoc viewer/header-viewer :render-fn '(fn [_ _] [:div.pt-5]))])

Andrea 2023-10-09T12:38:42.047009Z

it’s kind of a hack, we should make it easier

mkvlr 2023-10-09T12:47:01.347349Z

@andrea712 thanks, don’t agree this is a hack though

sg-qwt 2023-10-09T12:55:32.030309Z

thanks for the tip @andrea712. Hack or no hack, I guess a header option in the :nextjournal.clerk/visibility would be convenient.

mkvlr 2023-10-10T06:59:48.072069Z

@snow40479 I think that’s too much of a special case and a visibility flag would be too limited. Consider some options beyond plain visibility: • hide the header but add padding instead • hide the header without padding • change header contents The viewer api gives you full control here so I think it’s the better option in this case.

✅ 1
sg-qwt 2023-10-09T06:14:22.965489Z

I can hard code a px height inside its :data :layout :height , but its not ideal

mkvlr 2023-10-09T06:32:04.829799Z

(ns scratch
  {:nextjournal.clerk/visibility {:code :hide}}
  (:require [nextjournal.clerk :as clerk]))

(clerk/html {::clerk/width :full} [:div.h-screen.bg-green-200 "hello"])

mkvlr 2023-10-09T06:32:38.240159Z

that should be about what you want, there’s still a padding at the top though which you can take out if you want