开发者

What's the best way to create a relative color algorithm for data in an HTML table?

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜