mirror of
https://github.com/weewx/weewx.git
synced 2026-04-21 10:07:05 -04:00
Merge branch 'development' into V5
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2009-2021 Tom Keffer <tkeffer@gmail.com>
|
||||
# Copyright (c) 2009-2023 Tom Keffer <tkeffer@gmail.com>
|
||||
#
|
||||
# See the file LICENSE.txt for your full rights.
|
||||
#
|
||||
@@ -366,8 +366,8 @@ class GeneralPlot(object):
|
||||
|
||||
# Calculate the size of a gap in data
|
||||
maxdx = None
|
||||
if this_line.gap_fraction is not None:
|
||||
maxdx = this_line.gap_fraction * (self.xscale[1] - self.xscale[0])
|
||||
if this_line.line_gap_fraction is not None:
|
||||
maxdx = this_line.line_gap_fraction * (self.xscale[1] - self.xscale[0])
|
||||
|
||||
if this_line.plot_type == 'line':
|
||||
ms = this_line.marker_size
|
||||
@@ -611,7 +611,7 @@ class PlotLine(object):
|
||||
"""Represents a single line (or bar) in a plot. """
|
||||
def __init__(self, x, y, label='', color=None, fill_color=None, width=None, plot_type='line',
|
||||
line_type='solid', marker_type=None, marker_size=10,
|
||||
bar_width=None, vector_rotate = None, gap_fraction=None):
|
||||
bar_width=None, vector_rotate = None, line_gap_fraction=None):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.label = to_text(label) # Make sure the label is in unicode
|
||||
@@ -624,7 +624,7 @@ class PlotLine(object):
|
||||
self.width = width
|
||||
self.bar_width = bar_width
|
||||
self.vector_rotate = vector_rotate
|
||||
self.gap_fraction = gap_fraction
|
||||
self.line_gap_fraction = line_gap_fraction
|
||||
|
||||
|
||||
class UniDraw(ImageDraw.ImageDraw):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2009-2021 Tom Keffer <tkeffer@gmail.com>
|
||||
# Copyright (c) 2009-2023 Tom Keffer <tkeffer@gmail.com>
|
||||
#
|
||||
# See the file LICENSE.txt for your full rights.
|
||||
#
|
||||
@@ -255,6 +255,10 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
|
||||
# Get the type of plot ('bar', 'line', or 'vector')
|
||||
plot_type = line_options.get('plot_type', 'line').lower()
|
||||
|
||||
if plot_type not in {'line', 'bar', 'vector'}:
|
||||
log.error(f"Unknown plot type {plot_type}. Ignored")
|
||||
continue
|
||||
|
||||
if aggregate_type and plot_type != 'bar':
|
||||
# If aggregating, put the point in the middle of the interval
|
||||
start_vec_t = ValueTuple(
|
||||
@@ -302,7 +306,7 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
|
||||
width = to_int(line_options.get('width'))
|
||||
|
||||
interval_vec = None
|
||||
gap_fraction = None
|
||||
line_gap_fraction = None
|
||||
vector_rotate = None
|
||||
|
||||
# Some plot types require special treatments:
|
||||
@@ -313,15 +317,12 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
|
||||
elif plot_type == 'bar':
|
||||
interval_vec = [x[1] - x[0] for x in
|
||||
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:
|
||||
if plot_type in ('line', 'bar'):
|
||||
line_gap_fraction = to_float(line_options.get('line_gap_fraction'))
|
||||
if line_gap_fraction and not 0 <= line_gap_fraction <= 1:
|
||||
log.error("Gap fraction %5.3f outside range 0 to 1. Ignored.",
|
||||
gap_fraction)
|
||||
gap_fraction = None
|
||||
else:
|
||||
log.error("Unknown plot type '%s'. Ignored", plot_type)
|
||||
continue
|
||||
line_gap_fraction)
|
||||
line_gap_fraction = None
|
||||
|
||||
# Get the type of line (only 'solid' or 'none' for now)
|
||||
line_type = line_options.get('line_type', 'solid')
|
||||
@@ -344,7 +345,7 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
|
||||
marker_size=marker_size,
|
||||
bar_width=interval_vec,
|
||||
vector_rotate=vector_rotate,
|
||||
gap_fraction=gap_fraction))
|
||||
line_gap_fraction=line_gap_fraction))
|
||||
|
||||
# Return the constructed plot if it has any non-null data, otherwise return None
|
||||
return plot if have_data else None
|
||||
|
||||
@@ -52,6 +52,8 @@ Fixes issue #833
|
||||
Fix bug that prevents `group_deltatime` from being used by timespans. Users
|
||||
Add suffix `.length` to class TimespanBinder. This allows expressions such as
|
||||
|
||||
Option line_gap_fraction can now be used with bar plots. Fixes issue #818.
|
||||
|
||||
|
||||
## 4.9.1 10/25/2022
|
||||
Fix problem with `wind` for older versions of sqlite.
|
||||
|
||||
Reference in New Issue
Block a user