[reportlab-users] How can I stripe the grid
ulf.renman at favoptic.com
Thu Nov 12 08:39:27 EST 2009
I solved this myself with the code below. Any comments on that?
weekColors = [
drawing = Drawing(w,h)
lp = LinePlot()
# Create the grid.
# Use the same size and position as the LinePlot
# Calculate the gridstep by checking the actual data
# Offset it by half a step to make the grid better aligned with
# Calculate the order of the striping by getting the weekday of
# data point.
grid = Grid()
grid.x = lp.x
grid.y = lp.y
grid.width = lp.width
grid.height = lp.height
grid.delta = 20
mi = data['date'].toordinal()
ma = data[-1]['date'].toordinal()
grid.delta = float(grid.width)/(ma-mi)
grid.delta0 = grid.delta/2
wd = int(date.fromordinal(mi).strftime('%u'))-1
grid.stripeColors = (weekColors+weekColors)[wd:wd+len(weekColors)]
grid.useLines = 1
grid.useRects = 1
grid.strokeWidth = 0.3
# Add the LinePlot after the grid since we want it to be painted on top
# of the grid.
Ulf Renman wrote:
> I use a LinePlot with dates on the x-axis. How can I make the grid so
> that the columns for Saturday and Sunday be highligted?
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
More information about the reportlab-users