Skip to content

Commit

Permalink
fixes #110
Browse files Browse the repository at this point in the history
  • Loading branch information
mKainzbauer committed May 6, 2023
1 parent ee2b308 commit f8b99c0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/user/historygenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _statsDict(self, table_options, table_stats, table, binding, NOAA=False):
log.error("Error in [HistoryReport][[%s]]: check units" % table)
return None

line["values"].append(self._colorCell(value[0], format_string, cell_colors))
line["values"].append(self._colorCell(value, format_string, cell_colors))

if summary_column:
obs_year = getattr(year, obs_type)
Expand All @@ -340,12 +340,12 @@ def _statsDict(self, table_options, table_stats, table, binding, NOAA=False):
else:
value = converter.convert(getattr(obs_year, aggregate_type).value_t)

line["summary"] = self._colorCell(value[0], format_string, summary_cell_colors)
line["summary"] = self._colorCell(value, format_string, summary_cell_colors)

table_dict["lines"].append(line)

return table_dict

def getCount(self, obs_period, aggregate_type, threshold_value, threshold_units, obs_type):
try:
return getattr(obs_period, aggregate_type)((threshold_value, threshold_units, weewx.units.obs_group_dict[obs_type])).value_t
Expand All @@ -360,11 +360,12 @@ def _colorCell(self, value, format_string, cell_colors):
cellColors: An array containing 4 lists. [minvalues], [maxvalues], [background color], [foreground color]
"""
cell = {"value": "", "bgcolor": "", "fontcolor": ""}
if value is not None:
if value[0] is not None:
vh = weewx.units.ValueHelper(value)
for c in cell_colors:
if (value >= float(c[0])) and (value < float(c[1])):
if (value[0] >= float(c[0])) and (value[0] < float(c[1])):
cell["bgcolor"] = c[2]
cell["fontcolor"] = c[3]
break
cell["value"] = format_string % value
return cell
cell["value"] = vh.format(format_string, None, False, True)
return cell

0 comments on commit f8b99c0

Please sign in to comment.