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

the color_bar direction #79

Open
WLswert opened this issue Aug 9, 2016 · 3 comments
Open

the color_bar direction #79

WLswert opened this issue Aug 9, 2016 · 3 comments

Comments

@WLswert
Copy link

WLswert commented Aug 9, 2016

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 ?

@ghost
Copy link

ghost commented Sep 19, 2017

Picking up on this - I'd also like a solution if possible. Perhaps an extra argument to call into color_bar()?

@herndonj
Copy link

+1 I'd also be interested in having the option to have the bars going from left to right.

@rio-sanjuan
Copy link

rio-sanjuan commented Jan 10, 2020

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, ...))
                  ))
      }

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

3 participants