Last active
September 12, 2019 15:47
-
-
Save daranzolin/424acd8f218063e5dc53d321ba65aecb to your computer and use it in GitHub Desktop.
Using {minicss} to create a custom tooltip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(pinpoint) # remotes::install_github("daranzolin/pinpoint") | |
library(glue) | |
library(dplyr) | |
library(minicss) | |
sel1 <- Selector$new('h1')$class('demo') | |
sel2 <- css_sel("h2")$class('highlight') | |
sel1 <- Selector$new('h1')$class('demo') | |
sel2 <- css_sel("h2")$class('highlight') | |
kf1 <- Keyframe$new('from', color = '#123456') | |
kf2 <- css_keyframe('to', color = '#1289ae')$translateX(10, 'px') | |
keyframes <- Keyframes$new("pulser", kf1, kf2) | |
style1 <- Style$new( | |
sel1, | |
css_prop$animation(name = 'pulser', duration = 0.8, direction = 'alternate') | |
) | |
style2 <- Style$new('.mini', background_color = 'green') | |
style3 <- Style$new(sel2, css_prop$`text-decoration`$underline) | |
stylesheet <- css_stylesheet(style1, style2, style3, keyframes) | |
style2$update(background_colour = '#a0a0ff') | |
html <- glue::glue(" | |
<html> | |
<head> | |
<style> | |
{stylesheet} | |
</style> | |
</head> | |
<body> | |
<div> | |
<h1 class = 'demo'> Hello #Rstats</h1> | |
<h2 class='highlight'> A minicss demo! </h2> | |
This is an example of using <span class='mini'>minicss</span> to manipulate CSS. | |
</div> | |
</body> | |
</html>") | |
mtcars %>% | |
mutate(special_tooltip = html) %>% | |
pinpoint(mpg, cyl, special_tooltip) %>% | |
pp_style(jitter_width = 70) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment