Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply default css properties to data_id elements #296

Open
markjrieke opened this issue May 29, 2024 · 1 comment
Open

apply default css properties to data_id elements #296

markjrieke opened this issue May 29, 2024 · 1 comment

Comments

@markjrieke
Copy link

It'd be nice to be able to apply arbitrary css properties to objects that are then overwritten by explicit opts_hover(), opts_tooltip() and the like.

For example, in the below code, applying an opacity transition to opts_hover_inv() nicely transitions the non-hovered gears as expected. However, when not hovering, the inverted selection "snaps" back to full opacity. I believe this is because the css in opts_hover_inv() is only applied when the hover condition is met, so when not hovering, there is no transition property. It'd be nice to define transition as a higher level property so that the points transition back to full opacity as desired. This is non-interactive in github but you can run locally to see the effect described above.

Great package regardless!

library(ggplot2)
library(ggiraph)
#> Warning: package 'ggiraph' was built under R version 4.3.3

plt <- 
  ggplot(mtcars,
         aes(x = qsec,
             y = hp,
             data_id = gear,
             tooltip = paste("Gear:", gear))) +
  geom_point_interactive()

girafe(
  ggobj = plt,
  options = list(
    opts_hover_inv(css = "opacity:0.1;transition:opacity 1s;")
  )
)

Created on 2024-05-29 with reprex v2.1.0

@davidgohel
Copy link
Owner

Hello,

I think it is possible with CSS. I'll have a try and let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants