1

I am using HTML-Email with HTML Table within - Python MIME type : text/html Email with below code :

dashboardTable = """ <table>"""       
indexCount = 1
for sectionIndex in  range(0,len(sections_available)):
   dashboardTable = dashboardTable + """
      <tr>
          <td align='left'>""" + str(indexCount) + """  </td>
          <td align='left'>""" + sections_available[sectionIndex] + """  </td>
          <td align='left'> """ + str(sections_timeTaken[sectionIndex]) + """ </td>
     </tr>"""
   indexCount = indexCount + 1

dashboardTable = dashboardTable + """</table>"""

I need to color Third Cell:

<td align='left'> """ + str(sections_timeTaken[sectionIndex]) + """ </td>

In a way such that, Highest sections_timeTaken value kept with "Red Color" to lowest in "Green Color". Coloring entire range of values in ordered manner from Highest to Lowsest :

Like Red -> Light red -> Lightesr Red -> Yellow - > Green eventually.[ Not mentioning exact shade]

The total number of Values to be plotted inside table will remain dynamic.

I am using Python HTML table within Email.

Unnati Shukla
  • 342
  • 3
  • 15

1 Answers1

0

I think this would be easier to work with in HSL, at least for setting up your color values. That way you can work with one counter per h-s-l in a 0-1 range versus setting up a bunch of points in hexadecimal to fade up to / down from and addressing them via an array.

Luckily there's a good python library for color format conversion: https://pypi.python.org/pypi/colour/0.0.5

should be pretty easy to work that into your code i reckon.

zazzyzeph
  • 1,727
  • 1
  • 12
  • 19
  • or if you wanted you could set up your colors as hex color -> hsl conversion -> for statements -> hex conversion – zazzyzeph Jan 23 '15 at 16:53