Adds support for conditional colors to the percentageBars rendering function #579
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR modifies the
DataTable.render.percentBar
function by adding theconditionalColors
parameter to support conditional coloring of the percentage bars. If theconditionalColors
parameter is provided, the function will iterate through the conditional colors array and apply the appropriate color based on the range specified. IfconditionalColors
is not provided, the function will default to the original color settings. These changes enable more customization of the appearance of the percentage bars.Are you happy for it to be included and distributed under the MIT license? ✔️
Here's the output after the change:
This change was requested in:
I thought this is a cool idea and seemed pretty easy (for a noob like me). It takes array of hashes and depending on settings can overwrite color based on condition. It's conditioned for backgroundColor, textColor and barColor. If any of them are not provided it takes the default one, so users can provide min,max, barColor if that's what they want to play with as well.
I didn't "format" the file even tho the spacing is a mess (tabs in the begining, spaces in the end). I can fix that if required as well?
Here's live example, with code inline: