[reportlab-users] barchart background (repost for archive)
Dirk Datzert
reportlab-users@reportlab.com
Tue, 30 Jul 2002 17:30:51 +0200
Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------D3AB85A3B1E8FEFE6D63E31F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
I missed a background option for barcharts and modified my local
version.
I sent my changes for discussion or integration purpose.
chart.background = ShadedRect()
chart.background.fillColorStart = colors.blue
chart.background.fillColorEnd = colors.red
chart.background.x,y,width,height will be set in makeBackground()
default is chart.background = None
and the default makeBackground() mechanism will be used.
Regards,
Dirk
--------------D3AB85A3B1E8FEFE6D63E31F
Content-Type: text/plain; charset=us-ascii;
name="barchart.background.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="barchart.background.diff"
--- barcharts.py.orig Sat Jul 27 12:42:21 2002
+++ barcharts.py Sun Jul 28 22:56:40 2002
@@ -65,6 +65,7 @@
barLabelFormat = AttrMapValue(None, desc='Formatting string or function used for bar labels.'),
reversePlotOrder = AttrMapValue(isBoolean, desc='If true, reverse common category plot order.'),
naLabel = AttrMapValue(NoneOrInstanceOfNA_Label, desc='Label to use for N/A values.'),
+ background = AttrMapValue(None, desc='Handle to background object.'),
)
def __init__(self):
@@ -129,9 +130,20 @@
self.bars[2].fillColor = colors.blue
self.naLabel = None#NA_Label()
+ self.background = None
+
def makeBackground(self):
strokeColor,strokeWidth,fillColor=self.strokeColor, self.strokeWidth, self.fillColor
- if (strokeWidth and strokeColor) or fillColor:
+ if self.background is not None:
+ g = Group()
+ bg = self.background
+ bg.x = self.x
+ bg.y = self.y
+ bg.width = self.width
+ bg.height = self.height
+ g.add(bg)
+ return g
+ elif (strokeWidth and strokeColor) or fillColor:
g = Group()
g.add(Rect(self.x, self.y, self.width, self.height,
strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor))
--------------D3AB85A3B1E8FEFE6D63E31F--