Git Product home page Git Product logo

Comments (3)

monkeywithacupcake avatar monkeywithacupcake commented on July 30, 2024

What do you want to happen instead? You want black text?

from formattable.

verajosemanuel avatar verajosemanuel commented on July 30, 2024

Visible text should suffice.

from formattable.

monkeywithacupcake avatar monkeywithacupcake commented on July 30, 2024

I think you maybe have another setting, like a default to white text?

When I use your code , I get black text knitted.

Screen Shot 2021-10-16 at 11 34 37

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:
Screen Shot 2021-10-16 at 11 41 33

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.

from formattable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.