santa
santa

Reputation: 12512

Programmatically adjust cell color

I have a table with numeric values in some (not all) cells

<table>
<tr>
  <td>2</td>
  <td></td>
  <td>1</td>
  <td>6</td>
  <td>9</td>
</tr>
</table>

The lowest value is 0, and I have no way of knowing what the max value could be, but it's probably in low double-digits.

I would like to use jQuery to change the background of each cell with red shift towards the higher numbers. So it, the value in a cell is zero, the color is #FFFFCC and the highest is #CC0000.

So I think this could be accomplished with the following steps:

  1. Find the lowest and the highest values
  2. Calculate color increment
  3. Assign background colors

Before I jump into re-invention of a wheel, I wanted to check if something like this has been done and if yes, if someone would point me in the right direction.

Upvotes: 0

Views: 41

Answers (1)

subZero
subZero

Reputation: 5176

Check out HeatColor, a jQuery plugin that does exactly this.

Upvotes: 2

Related Questions