This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-15
Channels
- # babashka (3)
- # beginners (28)
- # calva (8)
- # cider (16)
- # clj-on-windows (4)
- # clojure (69)
- # clojure-europe (29)
- # clojure-norway (42)
- # clojure-uk (4)
- # community-development (5)
- # conjure (3)
- # cursive (18)
- # datomic (68)
- # emacs (23)
- # events (1)
- # honeysql (7)
- # introduce-yourself (1)
- # jobs (1)
- # lsp (11)
- # music (1)
- # observability (3)
- # off-topic (35)
- # other-languages (33)
- # releases (1)
- # remote-jobs (2)
- # ring (18)
- # shadow-cljs (16)
- # timbre (5)
- # tools-deps (9)
#C0BQDEJ8M may be a good place to ask
A word of caution, just in case - Vega is very hard to debug. Sometimes it does give you a useful error message, but often it doesn't. And if you decide to extend it with some custom transform or something, good luck to you, because it's not only hard by itself with the docs and docstring on it being next to none, maintaining that code is a PITA. The last time I checked, it also adds a whopping 1 MB to the bundle, even in a minimal setup.
@U2FRKM4TW size wise, it isn't as bad as that: https://bundlephobia.com/package/[email protected]
To answer the question, I'll give the boring answer. The docs here are actually pretty good: https://vega.github.io/vega/docs/ I would look at a few examples, then just look at the docs for the details.
My process has been to start with an example that looks like what I want (https://vega.github.io/vega/examples/), then tweak until I’ve got something that works.
Also FWIW - while I think vega is useful and good generally, there are a few times I wish I never even tried it for a certain thing, and just did it manually instead. (svg or canvas). There are limits to what kinds of things it can do, and sometimes you don't find out until very late. For example, at work tried having a line plot where the color of the line changed along it's path according to some property, but that just isn't possible. So if that was a hard requirement it would have been bad.
@U08JKUHA9 Don't trust that website, trust your build report.
E.g. try vega-lite
with it. It will be even smaller. But vega-lite
cannot work without vega
.
thanks for the ideas. I've been running examples through chatgpt, mainly. So I can sort of tediously build things. Next step is to start thinking in vega, somehow. Looking at the vega-lite docs, they tend to describe how to draw a quantile transform, rather than what is a quantile transform. I feel pretty ignorant of the underlying theory - maybe that's where I should start.
@U2FRKM4TW Looks reasonable from the build report. You are probably right about the website though.
As I said, I don't even remember when I checked the size. But still, 600 kB when my whole bundle is 2 MB is a lot and IMO unjustified if you use Vega for just a couple of simple charts. Of course, gzipped size seems smaller, but, assuming the rest of the bundle compresses just as well, the fraction remains the same.
Oh, remembered a couple of other issues with Vega: • Responsive charts are hard. I have to use a resize observer and it takes a few frames to settle down • Working around all the printing bugs is a nightmare. Charts are too small, too large, not visible, etc. And different browsers display things differently. In the project where I use Vega, this problem is only with Vega charts - no other component exhibits it.
Just double-checked, and it seems that I have to fix printing again. The first pic is the website, the second is a printed PDF.
Fair points. Haven't had too many browser inconsistencies, but I agree resizing, stabilizing etc was a little tricky.
Aaaand, one more thing. :) Vega is limited, quite a bit. In a way, it's similar to RoR. If your needs line up with Vega's capabilities quite well - awesome, apart from the aforementioned things you should have no problems. But if you need something just a tad different (e.g. putting both data labels and arbitrary labels under an axis), you're in for a bad time. Chances are, you won't be able to do what you want at all. We've had quite a few brainstorms with the owner of the website from which I got the pics to figure out what exactly is the intersection of representations suitable to him and representations I can actually implement in Vega.
Could you please suggest what would be a better alternative to vega-lite/vega if somebody wants full flexibility and is afraid to “draw himself into a corner” with the limitations stated above?
Probably would need to go from scratch (svg/canvas). I suspect d3 would be also an option, but I haven't played with it enough to say for sure.
I think there's a non-trivial trade-off between flexibility and ease of use. Vega is easy to use, when you can use it, but not that flexible. Something like D3 is very flexible but might not be all that easy to use because a lot of the things require manual configuration. There are D3 wrappers that try to reach for the middle ground where the most common tasks are easy to implement. Quite some time ago I was very involved in a Python plotting library called Bokeh, and back then it was the best (at least, among all the ones I surveyed) in terms of that trade-off and also in terms of performance. It's a client-server library where the server is in Python and the client, BokehJS, is in JavaScript. I haven't been following it for a couple of years so no clue about the current state of affairs, but if I were to start a project that relies on highly customizable complex charts, I'd definitely try using BokehJS first. Even if using it without the Python counterpart might involve a bit of source code diving.
Folks, a question: I made a "lazy bencode parser" - for example, i10e
is the number 10
in bencode; my code basically allows you top parse i
, then 1
, then 0e
and only then emits the number 10
, caching every intermediate step in the process. To make it, I basically made the parser return a map with :results
, a vector with all the results, and :next
, which is the "next" function one needs to call to continue parsing. It's similar to a "continuation", to "generators", but it's actually none of these things.
I was curious - is there a name to this approach? The one that returns both the results so far and the next thing that will be parsed?
No, not exactly. What I mean is this case where I feed some incomplete info and return back a function that will "continue" when we feed the rest of the thing - not really related to parsing but more like "anything that can treat incomplete stuff". For example, I could make the same for a zip file format: feed some binaries and emit the extracted file/contents for it, together with a function that, if I feed more binaries, will emit the next files that are in the zip; there's not really any "combination" of parsers in this case, I guess?
what makes it not a continuation?
Well... none of the examples I saw used the same structure that I did, usually they just "pause" and "resume", there's not much on "returning something partial and then pausing", but I don't know... is it a continuation?
it feels like continuation passing style
Just for completion, that's an example on how to parse:
(let [parse (gen-parser)
r1 (parse "i")
r2 ((:next r1) "1")
r3 ((:next r2) "0e")]
; This returns [10]
(:results r3))
You are returning the continuation to a point, so delimited continuation or coroutine
lazy stream parser or just a stream parser?
oh, nvm, got it wrong
Ok, delimited continuation sounds cooler, so I'll go with this :rolling_on_the_floor_laughing: