From 5140cedf077c4d5de441c350ddb1e2bb366ff42b Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Fri, 16 Apr 2021 13:53:11 -0700 Subject: [PATCH] X-axis for time series plots must always be in unix epoch time. --- bin/weeplot/genplot.py | 3 ++- bin/weewx/imagegenerator.py | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/weeplot/genplot.py b/bin/weeplot/genplot.py index 0a47e57a..b22cd9e0 100644 --- a/bin/weeplot/genplot.py +++ b/bin/weeplot/genplot.py @@ -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) diff --git a/bin/weewx/imagegenerator.py b/bin/weewx/imagegenerator.py index 686f16f9..b3c18217 100644 --- a/bin/weewx/imagegenerator.py +++ b/bin/weewx/imagegenerator.py @@ -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,