cljfx

https://github.com/cljfx/cljfx
vlaaad 2019-03-28T07:12:04.000100Z

@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

pez 2019-03-28T09:53:43.005600Z

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

vlaaad 2019-03-28T10:07:44.005900Z

(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}}}]}]}}}))

❤️ 1
vlaaad 2019-03-28T10:12:54.006600Z

Added another issue to simplify Tooltip installation in the future https://github.com/cljfx/cljfx/issues/8

🤘 1
vlaaad 2019-03-28T10:31:39.007800Z

@pez Glad that you like cljfx! 😸

1
pez 2019-03-28T10:45:56.012Z

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).

pez 2019-03-28T10:46:58.013100Z

Now tried just evaluating the code you sent me and it gives the same result with an always visible round dot.

vlaaad 2019-03-28T10:47:55.014200Z

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?

vlaaad 2019-03-28T10:48:25.014600Z

like {:fx/type :cirlce}?

pez 2019-03-28T10:49:37.015100Z

Yeah, using renderer, looking for the typo now. 😃

pez 2019-03-28T10:52:22.016700Z

Found it. Now have 3600 round, black, dots, always showing. 😃

1
pez 2019-03-28T10:57:11.017800Z

Ah, now I get it. The circle isn’t the tooltip, it is just the hover pane. Haha.

👍 1
vlaaad 2019-03-28T11:05:09.018200Z

yeah, circle is a dot on a graph

pez 2019-03-28T11:14:38.020100Z

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.

vlaaad 2019-03-28T11:15:17.020700Z

javafx 🤷

pez 2019-03-28T11:15:21.020800Z

Now, I don’t want any symbols, so am just styling the circle to be transparent, but anyway.

pez 2019-03-28T11:16:15.021500Z

I guess it’s a nice hack if you want the symbols, but with tooltips added.