Example #1
0
 def demo(self,drawing=None):
     from reportlab.lib import colors
     if not drawing:
         drawing = Drawing(400, 200)
     lp = AdjLinePlot()
     lp.x = 50
     lp.y = 50
     lp.height = 125
     lp.width = 300
     lp.data = _monthlyIndexData
     lp.joinedLines = 1
     lp.strokeColor = colors.black
     c0 = colors.PCMYKColor(100,65,0,30, spotName='PANTONE 288 CV', density=100)
     lp.lines[0].strokeColor = c0
     lp.lines[0].strokeWidth = 2
     lp.lines[0].strokeDashArray = None
     c1 = colors.PCMYKColor(0,79,91,0, spotName='PANTONE Wm Red CV', density=100)
     lp.lines[1].strokeColor = c1
     lp.lines[1].strokeWidth = 1
     lp.lines[1].strokeDashArray = [3,1]
     lp.xValueAxis.labels.fontSize = 10
     lp.xValueAxis.labels.textAnchor = 'start'
     lp.xValueAxis.labels.boxAnchor = 'w'
     lp.xValueAxis.labels.angle = -45
     lp.xValueAxis.labels.dx = 0
     lp.xValueAxis.labels.dy = -8
     lp.xValueAxis.xLabelFormat = '{mm}/{yy}'
     lp.yValueAxis.labelTextFormat = '%5d%% '
     lp.yValueAxis.tickLeft = 5
     lp.yValueAxis.labels.fontSize = 10
     lp.background = Grid()
     lp.background.stripeColors = [colors.pink, colors.lightblue]
     lp.background.orientation = 'vertical'
     drawing.add(lp,'plot')
     return drawing
Example #2
0
 def __init__(self):
     from reportlab.lib import colors
     SimpleTimeSeriesPlot.__init__(self)
     self.scaleFactor = None
     self.background = Grid()
     self.background.orientation = 'horizontal'
     self.background.useRects = 0
     self.background.useLines = 1
     self.background.strokeWidth = 0.5
     self.background.strokeColor = colors.black
Example #3
0
 def __init__(self):
     from reportlab.lib import colors
     LinePlot.__init__(self)
     self.xValueAxis = NormalDateXValueAxis()
     self.yValueAxis = AdjYValueAxis()
     self.scaleFactor = None
     self.background = Grid()
     self.background.orientation = 'horizontal'
     self.background.useRects = 0
     self.background.useLines = 1
     self.background.strokeWidth = 0.5
     self.background.strokeColor = colors.black
     self.data = _monthlyIndexData
Example #4
0
def draw_label(label, width, height, obj):
    # Pick a background colour.
    colour = random.choice(colours)

    # And a style.
    style = random.choice(('solid', 'stripes', 'hatch'))

    # Draw a solid background.
    if style == 'solid':
        r = shapes.Rect(0, 0, width, height)
        r.fillColor = colour
        r.strokeColor = None
        label.add(r)

    # Both stripes and hatches need vertical stripes.
    if style in ('stripes', 'hatch'):
        g = Grid()
        g.width = width
        g.height = height
        g.delta = width/14.0                        # The width of the stripes.
        g.delta0 = random.random() * (width/14.0)   # Offset of the start of the stripe.
        g.fillColor = None
        g.strokeColor = None
        g.orientation = 'vertical'
        g.stripeColors = (colors.HexColor(0xFFFFFF), colour)
        label.add(g)

    # Draw the horizontal stripes of any hatching.
    # Note the empty parts need to be 'coloured' transparent to avoid
    # hiding the vertical stripes.
    if style == 'hatch':
        g2 = Grid()
        g2.width = width
        g2.height = height
        g2.delta = height/4.0
        g2.delta0 = random.random() * (height/4.0)
        g2.fillColor = None
        g2.strokeColor = None
        g2.orientation = 'horizontal'
        g2.stripeColors = (colors.transparent, colour)
        label.add(g2)

    # Print the label value as a string.
    label.add(shapes.String(2, 2, str(obj), fontName="Helvetica", fontSize=40))
Example #5
0
def draw_label(label, width, height, obj):
    # Pick a background colour.
    colour = random.choice(colours)

    # And a style.
    style = random.choice(('solid', 'stripes', 'hatch'))

    # Draw a solid background.
    if style == 'solid':
        r = shapes.Rect(0, 0, width, height)
        r.fillColor = colour
        r.strokeColor = None
        label.add(r)

    # Both stripes and hatches need vertical stripes.
    if style in ('stripes', 'hatch'):
        g = Grid()
        g.width = width
        g.height = height
        g.delta = width / 14.0  # The width of the stripes.
        g.delta0 = random.random() * (width / 14.0
                                      )  # Offset of the start of the stripe.
        g.fillColor = None
        g.strokeColor = None
        g.orientation = 'vertical'
        g.stripeColors = (colors.HexColor(0xFFFFFF), colour)
        label.add(g)

    # Draw the horizontal stripes of any hatching.
    # Note the empty parts need to be 'coloured' transparent to avoid
    # hiding the vertical stripes.
    if style == 'hatch':
        g2 = Grid()
        g2.width = width
        g2.height = height
        g2.delta = height / 4.0
        g2.delta0 = random.random() * (height / 4.0)
        g2.fillColor = None
        g2.strokeColor = None
        g2.orientation = 'horizontal'
        g2.stripeColors = (colors.transparent, colour)
        label.add(g2)

    # Print the label value as a string.
    label.add(shapes.String(2, 2, str(obj), fontName="Helvetica", fontSize=40))