kcuilla / reactablefmtr

Streamlined Table Styling and Formatting for Reactable
https://kcuilla.github.io/reactablefmtr/
Other
206 stars 27 forks source link

Add optional `max` parameter in `icon_assign()` #63

Open StefanMusch opened 10 months ago

StefanMusch commented 10 months ago

Instead of always calculating the max from the values itself, it would be a great feature to allow the user to input the max value. E.g., I have a few tables where the score is out of 10, but for some cuts, the max value is 6, so it only shows 6 icons, whereas I'd like it to show 6 out of 10.

Any way this is already doable with the current functionality by making a row not visible?

Here's a quick and dirty addition:

Adding a parameter:

function(max = NULL){

 max_value <- max(floor(data[[name]] + 0.5)

  if (max < max_value, na.rm = TRUE)) {
    stop("`max` must be higher than your highest data value, which is {max_value}")
  }
}
     if(!is.null(max)){
        max_value <- max
      } else {
        max_value <- max(floor(data[[name]] + 0.5), na.rm = TRUE)
      }