Question

I have an HTML table of data and I want to mimic the Excel Color scales for conditional formatting so it highlights the relative value across this set of data.

The HTML table is simply drawing out a list of rows and for each row I have a value ( 0 - 300) and i want to have it color the background of the row of the table based on this algorithm so I assume it will need to generate an HTML color name or value for each number that is input

Any help where to start here?

Was it helpful?

Solution

You could use this, and when deciding to generate the color, divide the row value/300 to use the exact function.

Edit (Originally a comment)

When specifying html colors, you can use the rgb(Rvalue, Gvalue, Bvalue) notation. Or you could convert the decimal values to their hex equivalent to to the #RRGGBB notation.

In javascript, this would be achieved by following this method to convert to hex

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top