Closed Conaws closed 4 years ago
Answered first part of the question
:class "dots"
:tag "circle"
:prepare-dataset prepare-dataset
:did-mount
(fn [node ratom]
(let [y-scale (->y-scale ratom)
x-scale (->x-scale ratom)]
(rid3-> node
(.on "mouseover" #(js/alert (gobj/get % "label")))
{:cx (fn [d]
(let [label (gobj/get d "label")]
(x-scale label)))
:cy (fn [d]
(let [value (gobj/get d "value")]
(y-scale value)))
:r 4
:fill "#3366CC"})))}```
@Conaws You are correct that you should use (.on "mouseover" ...) for hover events.
For color of the circles in the scatterplot, here is a very basic example to get you going:
:fill (fn [d]
(let [value (gobj/get d "value")]
(if (> value 15) "blue" "red")))
Depending on how you want to color them, you probably want to reach for d3's built in scales, which can handle colors.
Working off of your scatterplot example
I want to be able to add click and hover events to the individual nodes
additionally, I'd like to be able to change the color of the node based on it's cy position
can you point me to resources on this