Skip to content

Commit

Permalink
fix default alpha_off
Browse files Browse the repository at this point in the history
  • Loading branch information
tdhock committed Nov 15, 2023
1 parent 151e25e commit 1d9f795
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion inst/htmljs/animint.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ var animint = function (to_select, json_file) {
return linetypesize2dasharray(lt, get_size(d));
};

var alpha = 1, alpha_off;
var alpha = 1, alpha_off = 0.5;
var get_alpha;
if(aes.hasOwnProperty("alpha")){
get_alpha = get_attr("alpha");
Expand Down
8 changes: 6 additions & 2 deletions tests/testthat/test-renderer1-geom-text-color.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
acontext("geom text color")
library(animint2)

df <- data.frame(x=1,y="foo")
viz <- animint(
text=ggplot()+
Expand All @@ -9,20 +8,25 @@ viz <- animint(
scale_color_manual(values=c(foo="blue"))+
geom_text(aes(x, 2, label=y), color="red", data=df)+
geom_text(aes(x, 1, label=y), color="black", color_off="pink", clickSelects="y", data=df))

info <- animint2HTML(viz)
test_that("geom_text color rendered as fill style", {
fill <- getStyleValue(info$html, '//text[@class="geom"]', "fill")
expect_color(fill, c("black", "blue","red","black"))
opacity <- getStyleValue(info$html, '//text[@class="geom"]', "opacity")
expect_identical(opacity, c("1","1","1","1"))
})

clickID("plot_text_y_variable_foo_svg")#or foo_label?
after.html <- getHTML()
test_that("geom_text color rendered as fill style", {
fill <- getStyleValue(after.html, '//text[@class="geom"]', "fill")
print(fill)
expect_color(fill, c("black", "red","pink"))
})

test_that("default text alpha_off correct", {
opacity <- getStyleValue(after.html, '//text[@class="geom"]', "opacity")
print(opacity)
expect_identical(opacity, c("0.5","1","1"))
expect_identical(opacity, c("0.5","1","0.5"))
})

0 comments on commit 1d9f795

Please sign in to comment.