You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to customize the tooltip shown when a user hovers over a scatterplot point. To do this, I need to pull data out of the data object passed to format.contents. However, not all of the fields from my data.frame are getting into data. How can I add fields to data, or otherwise get the other columns from the data.frame into the right place?
Here is an example that should illustrate what I mean:
data.frame(
x = rnorm(200),
y = rnorm(200),
group = sample(letters[1:3], size=200, replace=T),
label = sample(letters[4:26], size=200, replace=T)
) %>%
billboarder(data=.) %>%
bb_aes(x = x, y = y, group=group, label=label) %>%
bb_scatterplot() %>%
bb_tooltip(grouped=FALSE,
contents = htmlwidgets::JS(
"function(data, titleFormat, valueFormat, color) {console.log(data);return `<table><tr><td>${data[0].label}</td></tr><tr><td>${data[0].x}</td></tr><tr><td>${data[0].value}</td></tr></table>`;}"
))
As of now, the labels are all undefined, because data has group for both the id and name fields.
The text was updated successfully, but these errors were encountered:
That's complicated... the additional data are not kept, it is not possible to refer to label. A solution will be to pass a custom JSON in the contents function and retrieve data by index and group. I'll investigate.
I'd like to customize the tooltip shown when a user hovers over a scatterplot point. To do this, I need to pull data out of the
data
object passed toformat.contents
. However, not all of the fields from mydata.frame
are getting intodata
. How can I add fields todata
, or otherwise get the other columns from thedata.frame
into the right place?Here is an example that should illustrate what I mean:
As of now, the labels are all
undefined
, becausedata
hasgroup
for both theid
andname
fields.The text was updated successfully, but these errors were encountered: