From 2bbe581f0883675a08aaa1ce3cf0fc2d77ffa74a Mon Sep 17 00:00:00 2001
From: Tom Keffer
Date: Sat, 11 Mar 2017 12:54:32 -0800
Subject: [PATCH] Fill colors can now be specified. Fixes issue #227.
---
bin/weeplot/genplot.py | 5 ++---
bin/weewx/imagegenerator.py | 3 +++
docs/changes.txt | 3 +++
docs/customizing.htm | 7 +++++++
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/bin/weeplot/genplot.py b/bin/weeplot/genplot.py
index 7f055b43..14bfc768 100644
--- a/bin/weeplot/genplot.py
+++ b/bin/weeplot/genplot.py
@@ -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
diff --git a/bin/weewx/imagegenerator.py b/bin/weewx/imagegenerator.py
index 418b1d1b..d832ecce 100644
--- a/bin/weewx/imagegenerator.py
+++ b/bin/weewx/imagegenerator.py
@@ -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,
diff --git a/docs/changes.txt b/docs/changes.txt
index d5f5fae1..1626746b 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -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
diff --git a/docs/customizing.htm b/docs/customizing.htm
index 2ad0fb40..f7d2a6e2 100644
--- a/docs/customizing.htm
+++ b/docs/customizing.htm
@@ -4937,6 +4937,13 @@ UV = UV Index
Optional. Default is to use the color in chart_line_colors.
+ fill_color
+
+
+ This option is to override the fill color for a bar chart.
+ Optional. Default is to use the color in chart_fill_colors.
+
+
line_type