@pez I forgot to add toggle group to cljfx, will try to find a time this week to fix it, added an issue https://github.com/cljfx/cljfx/issues/7
I have another, simiilar, beginner question. I am using cljfx (which is pure delight, btw) to build a graphing frontend and would want to be able to hover on the data points in my graphs to see the values. The information I find on doing it in JavaFX again isn’t such that I can figure out how I would do it in cljfx. It seems to involve iterating over the data points and adding the hover panes. Here’s an SO answer about it that has example code attached: https://stackoverflow.com/a/14623439/44639
(fx/on-fx-thread
(fx/create-component
{:fx/type :stage
:showing true
:scene {:fx/type :scene
:root {:fx/type :line-chart
:x-axis {:fx/type :category-axis}
:y-axis {:fx/type :number-axis}
:data [{:fx/type :xy-chart-series
:data [{:fx/type :xy-chart-data
:x-value "10"
:y-value 10
:node {:fx/type fx/ext-on-instance-lifecycle
:on-created (fn [circle]
(let [tooltip (fx/instance
(fx/create-component
{:fx/type :tooltip
:text "I am a tooltip!"}))]
(javafx.scene.control.Tooltip/install circle tooltip)))
:desc {:fx/type :circle
:radius 10}}}]}]}}}))
Added another issue to simplify Tooltip installation in the future https://github.com/cljfx/cljfx/issues/8
@pez Glad that you like cljfx! 😸
So, trying to apply the tooltip creation to my line chart I get this error:
java.lang.IllegalArgumentException: No implementation of method: :create of protocol: #'cljfx.lifecycle/Lifecycle found for class: clojure.lang.Keyword
Thinking I might have messed some nestling up, I tried to simply replace my chart with yours and then I get a round circle that is always showing. But then I haven’t included the :scene
and on-fx-thread
and stuff around the :line-chart
(don’t know to apply that to my setup right now actually).Now tried just evaluating the code you sent me and it gives the same result with an always visible round dot.
If you use renderer, you don't need on-fx-thread
. Exception indicates that one of your keyword fx-types is not registered. A typo maybe?
like {:fx/type :cirlce}
?
Yeah, using renderer, looking for the typo now. 😃
Found it. Now have 3600 round, black, dots, always showing. 😃
Ah, now I get it. The circle isn’t the tooltip, it is just the hover pane. Haha.
yeah, circle is a dot on a graph
Interestingly, if I make it a :stack-pane
instead, it also becomes a circle which is styled like the series. In fact, it looks like the symbols you get if you have :create-symbols
on.
javafx 🤷
Now, I don’t want any symbols, so am just styling the circle to be transparent, but anyway.
I guess it’s a nice hack if you want the symbols, but with tooltips added.