Fill colors can now be specified. Fixes issue #227.

This commit is contained in:
Tom Keffer
2017-03-11 12:54:32 -08:00
parent 199f5c20a0
commit 2bbe581f08
4 changed files with 15 additions and 3 deletions

View File

@@ -273,7 +273,6 @@ class GeneralPlot(object):
for x in weeutil.weeutil.stampgen(self.xscale[0], self.xscale[1], self.xscale[2]) :
sdraw.line((x, x), (self.yscale[0], self.yscale[1]), fill=self.chart_gridline_color,
width=self.anti_alias)
drawlabel = not drawlabel
if drawlabelcount % self.x_label_spacing == 0 :
xlabel = self._genXLabel(x)
axis_label_size = sdraw.draw.textsize(xlabel, font=axis_label_font)
@@ -552,7 +551,7 @@ class PlotLine(object):
"""Represents a single line (or bar) in a plot.
"""
def __init__(self, x, y, label='', color=None, width=None, plot_type='line',
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,
x_label_spacing=2, y_label_spacing=2):
@@ -564,7 +563,7 @@ class PlotLine(object):
self.marker_type = marker_type
self.marker_size = marker_size
self.color = color
self.fill_color = color
self.fill_color = fill_color
self.width = width
self.bar_width = bar_width
self.vector_rotate = vector_rotate

View File

@@ -169,6 +169,8 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
# See if a color has been explicitly requested.
color = line_options.get('color')
if color is not None: color = weeplot.utilities.tobgr(color)
fill_color = line_options.get('fill_color')
if fill_color is not None: fill_color = weeplot.utilities.tobgr(fill_color)
# Get the line width, if explicitly requested.
width = to_int(line_options.get('width'))
@@ -212,6 +214,7 @@ class ImageGenerator(weewx.reportengine.ReportGenerator):
new_stop_vec_t[0], new_data_vec_t[0],
label = label,
color = color,
fill_color = fill_color,
width = width,
plot_type = plot_type,
line_type = line_type,

View File

@@ -7,6 +7,9 @@ The ordinal increment between x- and y-axis labels can now be chosen.
The increment between x-axis tick marks can now be chosen. Thanks
to user paolobenve!
Bar chart fill colors can now be specified for individual observation
types. Fixes issue #227.
3.7.0 03/11/2017

View File

@@ -4937,6 +4937,13 @@ UV = UV Index</pre>
Optional. Default is to use the color in <span class="code">chart_line_colors</span>.
</p>
<p class="config_option">fill_color</p>
<p>
This option is to override the fill color for a bar chart.
Optional. Default is to use the color in <span class="code">chart_fill_colors</span>.
</p>
<p class="config_option">line_type</p>
<p>