Open verajosemanuel opened 3 years ago
What do you want to happen instead? You want black text?
Visible text should suffice.
I think you maybe have another setting, like a default to white text?
When I use your code , I get black text knitted.
However, when I have an issue with color, possibly that needs to be changing with the background, I write a custom function.
Here's an example, stoplight tile...which turns text white with a red background but otherwise has black text.
stoplighttile <- function(cut1 = .1, cut2 = .2, fun = "comma", digits = 0) {
fun <- match.fun(fun)
formatter("span", x ~ fun(x, digits = digits),
style = function(y) style(
display = "block",
padding = "0 4px",
"border-radius" = "4px",
"color" = ifelse( y >= cut2, csscolor("#FFFDF9"), csscolor("black")),
"background-color" = ifelse( y < cut1, csscolor("#50D890"),
ifelse( y < cut2, csscolor("#F6DA63"),
csscolor("#E32249")))
)
)
}
with your data,
formattable(products, list(
price = color_tile("transparent", "lightpink"),
rating = color_bar("lightgreen"),
market_share = stoplighttile(cut1 = 0.05, cut2 = 0.1, fun = "percent", digits = 0)
)
)
The result is:
NOTE: I used the tile function on the market share column and not on the price column where you were having the issue, but I hope it makes sense.