Skip to content

Conversation

@mdoucleff
Copy link

@mdoucleff mdoucleff commented Nov 3, 2022

Thank you for publishing the reactablefmtr package. It has helped me achieve a professional look to my app. I've encountered two challenges with the fixed color ranges and would like to share a fix.

First, the zero-variance checks cause user-supplied color range values (min_value & max_values) to be ignored. Note that zero-variance will always occur for single-row tables. This changes applies the zero-variance test after selecting the color range end points instead of before. The variance test itself is also reduced down to a simpler range calculation.

Second, in some fixed color range applications (e.g. red for negative, green for positive) the potential data range is unbounded, which limits the usefulness of hard "min_value must be less than the minimum value observed in the data" stop's. So this change removes the stops and instead clamps the post-normalized value to [0,1]. That way data values outside [min_value, max_value] are displayed using the most-extreme color value.

A different approach (not included in this change) to scale-and-clamping would be to map the potential (-Inf,Inf) data range to the (0,1) color range via some sigmoid function. That way there is always a more-extreme color for a more-extreme data value in a continuous way (although becoming infintesimally similar). Since there are endless such mapping functions, consider accepting an arbitrary mapping function as input, with scale-and-clamp and sigmoid function-factories provided by the package. Just an idea...

Fixes kcuilla/reactfmtr#43

@mdoucleff mdoucleff changed the title Respect user-supplied color range values when supplied zero-variance columns Respect user-supplied color range values for zero-variance columns Nov 4, 2022
@mdoucleff mdoucleff changed the title Respect user-supplied color range values for zero-variance columns Respect user-supplied color range given zero-variance data Nov 4, 2022
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

Successfully merging this pull request may close these issues.

1 participant