Nice article @vlaaad -- I'll have to dig deeper into the Figwheel machinery to see if can figure out a way to hook into what it is doing...
I just added cljfx support to my ui library and thought it would be fun to test by writing a reveal plugin. Creating the reveal plugin was surprisingly painless.
I present reveal-treemap (https://github.com/phronmophobic/reveal-treemap) which offers a treemap
reveal action to visualize arbitrary data structures as a treemap.
I couldn't find any best practices for offering reveal plugins, but all you need to do is include the dependency and require the appropriate namespace. One of my biggest gripes with reveal is that I wish it had a better view for displaying exceptions so I'll probably try that next.
Found the time to try it out, very interesting way to visualize arbitrary data structures! I found it throws exception when invoking treemap action on "scalar" values (i.e. non-collections: keywords, booleans, numbers)
Don't know what I expected trying it on (into {} (map (juxt identity ns-interns) (all-ns)))
😆
good point. I should change it to not be an available action for scalars
Would be cool to have Reveal popup there as well to get back to values
the key idea is to try to summarize a datastructure using some bounded number of pixels and I think there's still lots of room for improvement
how would I add support for the popup?
that doesn't seem like it would be hard to add
does it use cljfx descriptions for rectangles?
no, everything is drawn in a canvas
but the events for which values you're hovering over bubble all the way up
so if there's a function I can call or some meta data I can set on the canvas as you move the mouse, then that would be easy to do
ah, that might be a bit more complex... there is vlaaad.reveal.ext/popup-view
cljfx component, in case of canvas you'll need to provide a way to get a value from something like mouse click position (see :select
option)
getting a value from a mouse click position is pretty easy
then it should be doable!
it will look like that:
{:fx/type rx/popup-view
:select (fn [jfx-event] ....)
:desc {:fx/type your-tree-map-view ...}}
jfx event is hmm... can be ContextMenuEvent
for right-clicks or KeyEvent
if space is pressed
Anyway, it's very cool, with Reveal I hoped to make this kind of visualization tooling practical for ad-hoc use! This makes me happy!
if you have any suggestions for different variations for the treemap, it's definitely a topic I'm interested in exploring
basically, I want something general like pprint, but better at summarizing in a reasonable size space for mediumish size data structures
I'm receiving the event, but I'm not sure what I'm supposed to provide for the :bounds
key
:bounds
(required) - JavaFX screen Bounds of a node that will show the
popup
nvmd, figured it out
there's something deep about working on a reveal action using reveal to debug my reveal view
hehe, sometimes it is like that when developing reveal in reveal
sometimes it's frustrating when I break reveal and can't see the error because reveal is broken 😂
do you do anything special with your reveal set up for visualizing exceptions?
I still find I prefer the viewing the exception in the emacs cider buffer since I'm better at navigating in emacs
I was thinking of trying to do a reveal action that would try to limit the stack trace to functions in the current code base
and allow you to hover over the stack trace lines to show the surrounding code
No, I don't have anything special wrt exceptions
maybe I just trigger too many exceptions
ok, new version should support the context menu
I was thinking that it would be cool to add a zoom feature to the treemap, but now I don't have to since you kinda get it for free with the reveal context menu
just right click and view value
or right click and treemap again
yeah, recursive inspection FTW!
@smith.adriane Excellent; I can see myself using this. Thanks for sharing!