示例#1
0
    def drawLineChart(self, (names, start, end, data, title), reserved=None):
        w = PAGE_WIDTH - 2 * inch
        h = w * 0.6
        drawing = Drawing(w, h)

        lp = LinePlot()
        lp.x = 0
        lp.y = 0
        lp.height = h - 30
        lp.width = w
        lp.data = data
        lp.joinedLines = 1
        lp.strokeColor = colors.black

        lp.xValueAxis = XValueAxis()
        lp.xValueAxis.valueMin = start
        lp.xValueAxis.valueMax = end
        lp.xValueAxis.valueSteps = [(start + i * (end - start) / 5)
                                    for i in range(6)]
        lp.xValueAxis.labelTextFormat = lambda seconds: time.strftime(
            "%m/%d %H:%M", time.localtime(seconds))
        lp.xValueAxis.labels.angle = 35
        lp.xValueAxis.labels.fontName = 'Helvetica'
        lp.xValueAxis.labels.fontSize = 7
        lp.xValueAxis.labels.dy = -10
        lp.xValueAxis.labels.boxAnchor = 'e'
        lp.yValueAxis.labelTextFormat = lambda value: '%d MB' % (int(value) /
                                                                 1000)
        lp.yValueAxis.labels.fontName = 'Helvetica'
        lp.yValueAxis.labels.fontSize = 7
示例#2
0
# Create the drawing and the lineplot
drawing = Drawing(400, 200)
lp = LinePlot()
lp.x = 50
lp.y = 50
lp.height = 125
lp.width = 300
lp._inFill = 1
lp.data = result
for i in range(len(result)):
    lp.lines[i].strokeColor = colors.toColor('hsl(%s,80%%,40%%)' % (i * 60))

fontName = 'Helvetica'
fontSize = 7

lp.xValueAxis = NormalDateXValueAxis()
lp.xValueAxis.labels.fontName = fontName
lp.xValueAxis.labels.fontSize = fontSize - 1
lp.xValueAxis.forceEndDate = 1
lp.xValueAxis.forceFirstDate = 1
lp.xValueAxis.labels.boxAnchor = 'autox'
lp.xValueAxis.xLabelFormat = '{d}-{MMM}'
lp.xValueAxis.maximumTicks = 5
lp.xValueAxis.minimumTickSpacing = 0.5
lp.xValueAxis.niceMonth = 0
lp.xValueAxis.strokeWidth = 1
lp.xValueAxis.loLLen = 5
lp.xValueAxis.hiLLen = 5
# lp.xValueAxis.gridEnd               = self.width
# lp.xValueAxis.gridStart             = self.chart.x-10
示例#3
0
    def drawLineChart(self, (names, start, end, data, title), reserved=None):
        w = PAGE_WIDTH - 2 * inch
        h = w * 0.6
        drawing = Drawing(w, h)

        lp = LinePlot()
        lp.x = 0
        lp.y = 0
        lp.height = h - 30
        lp.width = w
        lp.data = data
        lp.joinedLines = 1
        lp.strokeColor = colors.black

        lp.xValueAxis = XValueAxis()
        lp.xValueAxis.valueMin = start
        lp.xValueAxis.valueMax = end
        lp.xValueAxis.valueSteps = [(start + i * (end - start) / 5) for i in range(6)]
        lp.xValueAxis.labelTextFormat = lambda seconds: time.strftime("%m/%d %H:%M", time.localtime(seconds))
        lp.xValueAxis.labels.angle = 35
        lp.xValueAxis.labels.fontName = 'Helvetica'
        lp.xValueAxis.labels.fontSize = 7
        lp.xValueAxis.labels.dy = -10
        lp.xValueAxis.labels.boxAnchor = 'e'
        lp.yValueAxis.labelTextFormat = lambda value: '%d MB' % (int(value) / 1000)
        lp.yValueAxis.labels.fontName = 'Helvetica'
        lp.yValueAxis.labels.fontSize = 7
        lp.yValueAxis.visibleGrid = True
        lp.yValueAxis.drawGridLast = True
        lp.yValueAxis.valueMin = 0
示例#4
0
drawing = Drawing(400, 200)

# chart
my_colors = PCMYKColor(50, 0, 100, 20, alpha=40), PCMYKColor(
    0, 100, 100,
    40), PCMYKColor(100, 0, 90, 50), PCMYKColor(0, 0, 0, 40), PCMYKColor(
        10, 0, 100, 11), PCMYKColor(15, 0, 0, 0), PCMYKColor(0, 0, 0, 50)
lp = LinePlot()
lp.x = 0
lp.y = 0
lp.width = 400
lp.height = 120
lp.lines[0].inFill = True
lp.lines[0].strokeColor = my_colors[0]
# x axis
lp.xValueAxis = NormalDateXValueAxis()  # we change the axis type here
lp.xValueAxis.bottomAxisLabelSlack = 0
lp.xValueAxis.dailyFreq = 0
lp.xValueAxis.forceEndDate = True
lp.xValueAxis.forceFirstDate = True
lp.xValueAxis.gridEnd = 0
lp.xValueAxis.gridStart = 0
lp.xValueAxis.gridStrokeWidth = 1
lp.xValueAxis.joinAxisMode = 'bottom'
lp.xValueAxis.labels.angle = 30
lp.xValueAxis.labels.boxAnchor = 'e'
lp.xValueAxis.labels.dx = -2
lp.xValueAxis.labels.dy = -10
lp.xValueAxis.labels.fontName = 'Times-Roman'
lp.xValueAxis.labels.fontSize = 10
lp.xValueAxis.maximumTicks = 13
示例#5
0
def drawsystemdailyefficiency(can, resultsbuffer):
    can.setFont("Helvetica", 24)
    sec_title = "Chiller Plant System Daily Efficiency"
    can.drawString(25, 750, sec_title)

    desc_text = "The chiller plant system daily efficiency demonstrates the total efficiency including every" \
                " parts of the system across a series of days. The range can be by default (say, 2 days) or" \
                " specified by administrators."
    stylesheet = getSampleStyleSheet()
    paragraph = Paragraph(desc_text, stylesheet['Normal'])
    aW, aH = 500, 600
    w, h = paragraph.wrap(aW, aH)
    if w <= aW and h <= aH:
        paragraph.drawOn(can, 25, 700)

    # Draw the chart
    drawing = Drawing(600, 400)

    # font
    fontName = 'Helvetica'
    fontSize = 7

    # chart
    lp = LinePlot()
    lp.y = 16
    lp.x = 32
    lp.width = 400
    lp.height = 200

    # line styles
    lp.lines.strokeWidth = 0
    lp.lines.symbol = makeMarker('FilledSquare')

    # x axis
    lp.xValueAxis = NormalDateXValueAxis()
    lp.xValueAxis.labels.fontName = fontName
    lp.xValueAxis.labels.fontSize = fontSize - 1
    lp.xValueAxis.forceEndDate = 1
    lp.xValueAxis.forceFirstDate = 1
    lp.xValueAxis.labels.boxAnchor = 'autox'
    lp.xValueAxis.xLabelFormat = '{d}-{MMM}'
    lp.xValueAxis.maximumTicks = 5
    lp.xValueAxis.minimumTickSpacing = 0.5
    lp.xValueAxis.niceMonth = 0
    lp.xValueAxis.strokeWidth = 1
    lp.xValueAxis.loLLen = 5
    lp.xValueAxis.hiLLen = 5
    lp.xValueAxis.gridEnd = drawing.width
    lp.xValueAxis.gridStart = lp.x - 10

    # y axis
    # self.chart.yValueAxis = AdjYValueAxis()
    lp.yValueAxis.visibleGrid = 1
    lp.yValueAxis.visibleAxis = 0
    lp.yValueAxis.labels.fontName = fontName
    lp.yValueAxis.labels.fontSize = fontSize - 1
    lp.yValueAxis.labelTextFormat = '%0.2f%%'
    lp.yValueAxis.strokeWidth = 0.25
    lp.yValueAxis.visible = 1
    lp.yValueAxis.labels.rightPadding = 5

    # self.chart.yValueAxis.maximumTicks = 6
    lp.yValueAxis.rangeRound = 'both'
    lp.yValueAxis.tickLeft = 7.5
    lp.yValueAxis.minimumTickSpacing = 0.5
    lp.yValueAxis.maximumTicks = 8
    lp.yValueAxis.forceZero = 0
    lp.yValueAxis.avoidBoundFrac = 0.1

    # legend
    ll = LineLegend()
    ll.fontName = fontName
    ll.fontSize = fontSize
    ll.alignment = 'right'
    ll.dx = 5

    # sample data
    lp.data = [[(19010706, 3.3900000000000001), (19010806, 3.29),
                (19010906, 3.2999999999999998), (19011006, 3.29),
                (19011106, 3.3399999999999999), (19011206, 3.4100000000000001),
                (19020107, 3.3700000000000001), (19020207, 3.3700000000000001),
                (19020307, 3.3700000000000001), (19020407, 3.5),
                (19020507, 3.6200000000000001), (19020607, 3.46),
                (19020707, 3.3900000000000001)],
               [(19010706, 3.2000000000000002), (19010806, 3.1200000000000001),
                (19010906, 3.1400000000000001), (19011006, 3.1400000000000001),
                (19011106, 3.1699999999999999), (19011206, 3.23),
                (19020107, 3.1899999999999999), (19020207, 3.2000000000000002),
                (19020307, 3.1899999999999999), (19020407, 3.3100000000000001),
                (19020507, 3.4300000000000002), (19020607, 3.29),
                (19020707, 3.2200000000000002)]]

    lp.lines[0].strokeColor = PCMYKColor(0, 100, 100, 40, alpha=100)
    lp.lines[1].strokeColor = PCMYKColor(100, 0, 90, 50, alpha=100)
    lp.xValueAxis.strokeColor = PCMYKColor(100, 60, 0, 50, alpha=100)
    ll.colorNamePairs = [(PCMYKColor(0, 100, 100, 40,
                                     alpha=100), '01-Mar-2017'),
                         (PCMYKColor(100, 0, 90, 50,
                                     alpha=100), '02-Mar-2017')]
    lp.lines.symbol.x = 0
    lp.lines.symbol.strokeWidth = 0
    lp.lines.symbol.arrowBarbDx = 5
    lp.lines.symbol.strokeColor = PCMYKColor(0, 0, 0, 0, alpha=100)
    lp.lines.symbol.fillColor = None
    lp.lines.symbol.arrowHeight = 5
    ll.dxTextSpace = 7
    ll.boxAnchor = 'nw'
    ll.subCols.dx = 0
    ll.subCols.dy = -2
    ll.subCols.rpad = 0
    ll.columnMaximum = 1
    ll.deltax = 1
    ll.deltay = 0
    ll.dy = 5
    ll.y = 240
    ll.x = 300
    lp.lines.symbol.kind = 'FilledCross'
    lp.lines.symbol.size = 5
    lp.lines.symbol.angle = 45

    drawing.add(lp)
    drawing.add(ll)
    # drawing.title.text = "Jurong Point System Efficiency"
    # drawing.title.fondSize = 16
    drawing.drawOn(can, 100, 450)

    can.showPage()