the color_bar direction
Hi I want to change the color_bar's direction attr . and i set it like this: `color="red" fl=formatter("span", style = function(x) style( display = "inline-block", direction = "ltr", "border-radius" = "4px", "padding-right" = "2px", "background-color" = csscolor(color), width = percent(proportion(as.numeric(x))) ))
formattable(mtcars, list(disp = fl))`
but i don't work . I find the table td style is text-align:right,when i set the text-align:left, the color_bar direction is working. if i want change the color_bar direction,what should I do ?
Picking up on this - I'd also like a solution if possible. Perhaps an extra argument to call into color_bar()?
+1 I'd also be interested in having the option to have the bars going from left to right.
Here's a fairly simple solution. Use this instead of formattable::color_bar.
my_color_bar <- function(color, fun, ...) {
fun <- match.fun(fun)
formatter("span",
style = function(x) style(
display = "block",
direction = "ltr",
"border-radius" = "4px",
"padding-right" = "4px",
"background-color" = csscolor(color),
"padding-right" = "2px",
"background-color" = csscolor(color),
width = percent(fun(x, ...))
))
}