X-axis for time series plots must always be in unix epoch time.

This commit is contained in:
Tom Keffer
2021-04-16 13:53:11 -07:00
parent a65244ec73
commit 5140cedf07
2 changed files with 5 additions and 6 deletions

View File

@@ -581,7 +581,7 @@ class TimePlot(GeneralPlot) :
self.xscale = weeplot.utilities.scaletime(xmin, xmax)
def _calcXLabelFormat(self):
"""Specialized version for time plots."""
"""Specialized version for time plots. Assumes that time is in unix epoch time."""
if self.x_label_format is None:
(xmin, xmax) = self._calcXMinMax()
if xmin is not None and xmax is not None:
@@ -594,6 +594,7 @@ class TimePlot(GeneralPlot) :
self.x_label_format = u"%X"
def _genXLabel(self, x):
"""Specialized version for time plots. Assumes that time is in unix epoch time."""
if self.x_label_format is None:
return u''
time_tuple = time.localtime(x)

View File

@@ -204,9 +204,7 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
stop_vec_t[1], # Unit
stop_vec_t[2]) # Unit group
# Do any necessary unit conversions:
new_start_vec_t = self.converter.convert(start_vec_t)
new_stop_vec_t = self.converter.convert(stop_vec_t)
# Convert the data to the requested units
new_data_vec_t = self.converter.convert(data_vec_t)
# Add a unit label. NB: all will get overwritten except the last. Get the label
@@ -244,7 +242,7 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
if vector_rotate_str is not None else None
elif plot_type == 'bar':
interval_vec = [x[1] - x[0] for x in
zip(new_start_vec_t.value, new_stop_vec_t.value)]
zip(start_vec_t.value, stop_vec_t.value)]
elif plot_type == 'line':
gap_fraction = to_float(line_options.get('line_gap_fraction'))
if gap_fraction is not None and not 0 < gap_fraction < 1:
@@ -265,7 +263,7 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
# Add the line to the emerging plot:
plot.addLine(weeplot.genplot.PlotLine(
new_stop_vec_t[0], new_data_vec_t[0],
stop_vec_t[0], new_data_vec_t[0],
label = label,
color = color,
fill_color = fill_color,