当前位置: 首页>>代码示例>>Python>>正文


Python shapes.Drawing类代码示例

本文整理汇总了Python中reportlab.graphics.shapes.Drawing的典型用法代码示例。如果您正苦于以下问题:Python Drawing类的具体用法?Python Drawing怎么用?Python Drawing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Drawing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: demo

    def demo(self):
        """Shows basic use of a line chart."""

        drawing = Drawing(400, 200)

        data = [((1, 1), (2, 2), (2.5, 1), (3, 3), (4, 5)), ((1, 2), (2, 3), (2.5, 2), (3.5, 5), (4, 6))]

        lp = LinePlot()

        lp.x = 50
        lp.y = 50
        lp.height = 125
        lp.width = 300
        lp.data = data
        lp.joinedLines = 1
        lp.lineLabelFormat = "%2.0f"
        lp.strokeColor = colors.black

        lp.lines[0].strokeColor = colors.red
        lp.lines[0].symbol = makeMarker("FilledCircle")
        lp.lines[1].strokeColor = colors.blue
        lp.lines[1].symbol = makeMarker("FilledDiamond")

        lp.xValueAxis.valueMin = 0
        lp.xValueAxis.valueMax = 5
        lp.xValueAxis.valueStep = 1

        lp.yValueAxis.valueMin = 0
        lp.yValueAxis.valueMax = 7
        lp.yValueAxis.valueStep = 1

        drawing.add(lp)

        return drawing
开发者ID:eaudeweb,项目名称:naaya,代码行数:34,代码来源:lineplots.py

示例2: sample2

def sample2():
    "Make a pie chart with nine slices."

    d = Drawing(400, 200)

    pc = Pie()
    pc.x = 125
    pc.y = 25
    pc.data = [0.31, 0.148, 0.108,
               0.076, 0.033, 0.03,
               0.019, 0.126, 0.15]
    pc.labels = ['1', '2', '3', '4', '5', '6', '7', '8', 'X']

    pc.width = 150
    pc.height = 150
    pc.slices.strokeWidth=1#0.5

    pc.slices[0].fillColor = colors.steelblue
    pc.slices[1].fillColor = colors.thistle
    pc.slices[2].fillColor = colors.cornflower
    pc.slices[3].fillColor = colors.lightsteelblue
    pc.slices[4].fillColor = colors.aquamarine
    pc.slices[5].fillColor = colors.cadetblue
    pc.slices[6].fillColor = colors.lightcoral
    pc.slices[7].fillColor = colors.tan
    pc.slices[8].fillColor = colors.darkseagreen

    d.add(pc)

    return d
开发者ID:roytest001,项目名称:PythonCode,代码行数:30,代码来源:piecharts.py

示例3: demo

    def demo(self):
        D = Drawing(100, 100)

        g = Grid()
        D.add(g)

        return D
开发者ID:halimath,项目名称:taskcardmaker,代码行数:7,代码来源:grids.py

示例4: PieRender

class PieRender(IRender):
    def __init__(self, width, height, labels, data):
        IRender.__init__(self, width, height, labels, data)

        #self.w = self.width
        #self.h = self.height
        #data = {}
        #for value in self.data:
        #    data[value[0]] = int(value[1])

        #plot = cairoplot.PiePlot('/tmp/tmp.png', data, self.w*2, self.h*2, gradient=True)
        ##plot.font_size *= 2
        #plot.render()
        #plot.commit()
        #with open('/tmp/tmp.png') as f:
        #    self.image = Image(StringIO(f.read()), self.w, self.h)
        pc = Pie()
        pc.width = min(self.height,self.width - 150)
        pc.height = min(self.height - 50,self.width)
        pc.width = pc.height = min(pc.height, pc.width)
        pc.x = self.width / 2 - pc.width / 2
        pc.y = self.height / 2 - pc.height / 2
        pc.data = [int(line[1]) for line in self.data]
        pc.labels = [line[0] for line in self.data]

        for i in xrange(len(self.data)):
            pc.slices[i].fillColor = COLORS[i % len(COLORS)]
            pc.slices[i].strokeColor = COLORS[i % len(COLORS)]
        self.drawing = Drawing(self.width, self.height)
        self.drawing.add(pc)

    def render(self): return self.drawing
开发者ID:maximerobin,项目名称:Ufwi,代码行数:32,代码来源:render.py

示例5: drawOn

 def drawOn(self, canvas):
     logo = self.logo
     x, y = logo.x, logo.y
     w, h = logo.width, logo.height
     D = Drawing(w, h)
     D.add(logo)
     D.drawOn(canvas, 0, 0)
开发者ID:roytest001,项目名称:PythonCode,代码行数:7,代码来源:customshapes.py

示例6: sample1b

def sample1b():
    "A line plot with non-equidistant points in x-axis."

    drawing = Drawing(400, 200)

    data = [
            ((1,1), (2,2), (2.5,1), (3,3), (4,5)),
            ((1,2), (2,3), (2.5,2), (3.5,5), (4,6))
        ]

    lp = LinePlot()

    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = data
    lp.joinedLines = 1
    lp.lines.symbol = makeMarker('Circle')
    lp.lineLabelFormat = '%2.0f'
    lp.strokeColor = colors.black

    lp.xValueAxis.valueMin = 0
    lp.xValueAxis.valueMax = 5
    lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5]
    lp.xValueAxis.labelTextFormat = '%2.1f'

    lp.yValueAxis.valueMin = 0
    lp.yValueAxis.valueMax = 7
    lp.yValueAxis.valueStep = 1

    drawing.add(lp)

    return drawing
开发者ID:SongJLG,项目名称:johan-doc,代码行数:34,代码来源:lineplots.py

示例7: draw_time_repartition

def draw_time_repartition(mandate):
    drawing = Drawing(width=180*mm, height=120*mm)
    pdf_chart_colors = [HexColor("#fa9d00"), HexColor("#006884"), HexColor("#00909e"), HexColor("#ffd08d"), ]
    pie = Pie()
    pie.x = 60*mm
    pie.y = 35*mm
    pie.width = 60*mm
    pie.height = 60*mm
    pie.slices.strokeWidth = 0.5
    pie.slices.fontName = 'Helvetica'
    pie.slices.fontSize = 8
    pie.data = []
    pie.labels = []
    titles = []
    add_data_and_titles_to_pie(pie, titles, mandate.research_percent, 'research_percent')
    add_data_and_titles_to_pie(pie, titles, mandate.tutoring_percent, 'tutoring_percent')
    add_data_and_titles_to_pie(pie, titles, mandate.service_activities_percent, 'service_activities_percent')
    add_data_and_titles_to_pie(pie, titles, mandate.formation_activities_percent, 'formation_activities_percent')
    if len(pie.data) > 0:
        drawing.add(pie)
        add_legend_to_pie(drawing)
        n = len(pie.data)
        set_items(n, pie.slices, 'fillColor', pdf_chart_colors)
        drawing.legend.colorNamePairs = \
            [(pie.slices[i].fillColor, (titles[i], '%0.f' % pie.data[i] + '%')) for i in range(n)]
    return drawing
开发者ID:uclouvain,项目名称:osis-assistant,代码行数:26,代码来源:export_utils_pdf.py

示例8: createBarCodes

def createBarCodes(path, barcode_value):
    from reportlab.graphics.barcode import eanbc
    from reportlab.graphics.shapes import Drawing
    from reportlab.pdfgen import canvas
    from reportlab.graphics import renderPDF
    from reportlab.lib.units import cm, mm
    from reportlab.lib.styles import getSampleStyleSheet
    from reportlab.platypus.para import Paragraph

    # draw the eanbc13 code
    barcode_eanbc13 = eanbc.Ean13BarcodeWidget(barcode_value)
    bounds = barcode_eanbc13.getBounds()
    barcode_eanbc13.barHeight = 19*mm
    width = bounds[2] - bounds[0]
    height = bounds[3] - bounds[1]
    d = Drawing()
    d.add(barcode_eanbc13)

    c = canvas.Canvas(path, pagesize=(43*mm, 25*mm))

    # print width, height
    text = "%s.%s" % (150, '00')
    p = Paragraph(text, getSampleStyleSheet()["Normal"])
    p.wrapOn(c, 43*mm, 5*mm)
    p.drawOn(c, 16*mm, 20*mm)
    renderPDF.draw(d, c, 3*mm, 1*mm)
    c.save()
开发者ID:StasEvseev,项目名称:adminbuy,代码行数:27,代码来源:resource.py

示例9: draw_qr_global_id

def draw_qr_global_id(canvas, survey):
    if survey.global_id is None:
        raise AssertionError

    # Only allow ascii
    value = survey.global_id.encode('ascii')

    y = survey.defs.paper_height - defs.corner_mark_bottom
    x = (survey.defs.paper_width - defs.corner_mark_right + defs.corner_mark_left) / 2

    qr_code = qr.QrCodeWidget(value, barLevel='H')
    bounds = qr_code.getBounds()

    width = bounds[2] - bounds[0]
    height = bounds[3] - bounds[1]

    # Squeeze into the space between corner mark and content
    size = defs.bottom_page_margin - defs.corner_mark_bottom

    code_y = y
    code_x = x - size / 2.0

    d = Drawing(size*mm, size*mm, transform=[float(size*mm)/width,0,0,-float(size*mm)/height,0,0])
    d.add(qr_code)

    renderPDF.draw(d, canvas, code_x*mm, code_y*mm)
开发者ID:bgeneto,项目名称:sdaps,代码行数:26,代码来源:generic.py

示例10: draw_qr_sdaps_info

def draw_qr_sdaps_info(canvas, survey, page):
    # The page number is one based here already
    # The survey_id is a 32bit number, which means we need
    # 10 decimal digits to encode it, then we need to encode the
    # the page with at least 3 digits(just in case someone is insane enough
    # to have a questionnaire with more than 99 pages.
    # So use 10+4 digits

    value = "%010d%04d" % (survey.survey_id, page)

    y = survey.defs.paper_height - defs.corner_mark_bottom
    x = survey.defs.paper_width - defs.corner_mark_right

    qr_code = qr.QrCodeWidget(value, barLevel='H')
    bounds = qr_code.getBounds()

    width = bounds[2] - bounds[0]
    height = bounds[3] - bounds[1]

    # Squeeze into the space between corner mark and content
    size = defs.bottom_page_margin - defs.corner_mark_bottom

    code_y = y
    code_x = x - size

    d = Drawing(size*mm, size*mm, transform=[float(size*mm)/width,0,0,-float(size*mm)/height,0,0])
    d.add(qr_code)

    renderPDF.draw(d, canvas, code_x*mm, code_y*mm)
开发者ID:bgeneto,项目名称:sdaps,代码行数:29,代码来源:generic.py

示例11: __add_graph

    def __add_graph(self):
        drawing = Drawing(200, 100)
        data = list()
        labels = list()

        self.c.drawString(370, 730, 
            'Distribucion en pesos'.encode('utf-8'))

        for acc in self.accounts:
            balance = acc.balance
            if acc.currency == 'USD':
                balance = balance * self.dolar

            data.append(balance)
            labels.append(acc.name)

        pie = Pie()
        pie.x = 280
        pie.y = 630
        pie.height = 100
        pie.width = 100
        pie.data = data
        pie.labels = labels
        pie.simpleLabels = 1
        pie.slices.strokeWidth = 1
        pie.slices.strokeColor = black
        pie.slices.label_visible = 0

        legend = Legend()
        legend.x = 400
        legend.y = 680
        legend.dx              = 8
        legend.dy              = 8
        legend.fontName        = 'Helvetica'
        legend.fontSize        = 7
        legend.boxAnchor       = 'w'
        legend.columnMaximum   = 10
        legend.strokeWidth     = 1
        legend.strokeColor     = black
        legend.deltax          = 75
        legend.deltay          = 10
        legend.autoXPadding    = 5
        legend.yGap            = 0
        legend.dxTextSpace     = 5
        legend.alignment       = 'right'
        legend.dividerLines    = 1|2|4
        legend.dividerOffsY    = 4.5
        legend.subCols.rpad    = 30
        n = len(pie.data)
        self.__setItems(n,pie.slices,
            'fillColor',self.pdf_chart_colors)

        legend.colorNamePairs = [(pie.slices[i].fillColor, 
            (pie.labels[i][0:20],'$%0.2f' % pie.data[i])) for i in xrange(n)]


        drawing.add(pie)
        drawing.add(legend)
        x, y = 0, 0
        renderPDF.draw(drawing, self.c, x, y, showBoundary=False)
开发者ID:gaccardo,项目名称:buxfer_api,代码行数:60,代码来源:reporter.py

示例12: demo

 def demo(self,drawing=None):
     from reportlab.lib import colors
     if not drawing:
         tx,ty=self._getDrawingDimensions()
         drawing = Drawing(tx,ty)
     drawing.add(self.draw())
     return drawing
开发者ID:7o9,项目名称:stdm-plugin,代码行数:7,代码来源:slidebox.py

示例13: sample2

def sample2():
    "A line plot with non-equidistant points in x-axis."

    drawing = Drawing(400, 200)

    data = [
        (
            ("25/11/1991", 1),
            ("30/11/1991", 1.000933333),
            ("31/12/1991", 1.0062),
            ("31/01/1992", 1.0112),
            ("29/02/1992", 1.0158),
            ("31/03/1992", 1.020733333),
            ("30/04/1992", 1.026133333),
            ("31/05/1992", 1.030266667),
            ("30/06/1992", 1.034466667),
            ("31/07/1992", 1.038733333),
            ("31/08/1992", 1.0422),
            ("30/09/1992", 1.045533333),
            ("31/10/1992", 1.049866667),
            ("30/11/1992", 1.054733333),
            ("31/12/1992", 1.061),
        )
    ]

    data[0] = preprocessData(data[0])

    lp = LinePlot()

    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = data
    lp.joinedLines = 1
    lp.lines.symbol = makeMarker("FilledDiamond")
    lp.strokeColor = colors.black

    start = mktime(mkTimeTuple("25/11/1991"))
    t0 = mktime(mkTimeTuple("30/11/1991"))
    t1 = mktime(mkTimeTuple("31/12/1991"))
    t2 = mktime(mkTimeTuple("31/03/1992"))
    t3 = mktime(mkTimeTuple("30/06/1992"))
    t4 = mktime(mkTimeTuple("30/09/1992"))
    end = mktime(mkTimeTuple("31/12/1992"))
    lp.xValueAxis.valueMin = start
    lp.xValueAxis.valueMax = end
    lp.xValueAxis.valueSteps = [start, t0, t1, t2, t3, t4, end]
    lp.xValueAxis.labelTextFormat = seconds2str
    lp.xValueAxis.labels[1].dy = -20
    lp.xValueAxis.labels[2].dy = -35

    lp.yValueAxis.labelTextFormat = "%4.2f"
    lp.yValueAxis.valueMin = 100
    lp.yValueAxis.valueMax = 110
    lp.yValueAxis.valueStep = 2

    drawing.add(lp)

    return drawing
开发者ID:eaudeweb,项目名称:naaya,代码行数:60,代码来源:lineplots.py

示例14: sample1a

def sample1a():
    drawing = Drawing(400, 200)

    data = [
            (13, 5, 20, 22, 37, 45, 19, 4),
            (5, 20, 46, 38, 23, 21, 6, 14)
            ]

    lc = SampleHorizontalLineChart()

    lc.x = 50
    lc.y = 50
    lc.height = 125
    lc.width = 300
    lc.data = data
    lc.joinedLines = 1
    lc.strokeColor = colors.white
    lc.fillColor = colors.HexColor(0xCCCCCC)
    lc.lines.symbol = makeMarker('FilledDiamond')
    lc.lineLabelFormat = '%2.0f'

    catNames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ')
    lc.categoryAxis.categoryNames = catNames
    lc.categoryAxis.labels.boxAnchor = 'n'

    lc.valueAxis.valueMin = 0
    lc.valueAxis.valueMax = 60
    lc.valueAxis.valueStep = 15

    drawing.add(lc)

    return drawing
开发者ID:wolf29,项目名称:EG-notifications,代码行数:32,代码来源:linecharts.py

示例15: print_chunks_chart

    def print_chunks_chart(self):
        nChunks = len(self.filechunks)

        d = Drawing(400, 140)
        traffic_MB = [n/(1024*1024) for n in self.traffic]
        data = [traffic_MB]
        bc = VerticalBarChart()
##        bc.x = 0
##        bc.y = 10
        bc.height = 100
        bc.width = 370
        bc.data = data
        bc.categoryAxis.tickUp = 0.5
        bc.categoryAxis.tickDown = 1.5

        bc.categoryAxis.categoryNames = []
        for n in range(nChunks):
            if n%5 == 0:
                bc.categoryAxis.categoryNames.append( str(n) )
            else:
                bc.categoryAxis.categoryNames.append('')

        bc.bars.strokeWidth = 0.3
        bc.valueAxis.labels.fontSize = 6
        bc.categoryAxis.labels.fontSize = 6
        bc.bars[0].fillColor = colors.lightblue
        
        bc.valueAxis.valueMin = 0

        d.add(bc)
        drawing = GraphicsDrawing(d, 'Traffic per chunk in MB')

        self.story.append(drawing)
        self.story.append(Spacer(0.01,1.0*cm))
开发者ID:rusingineer,项目名称:EmulePlus,代码行数:34,代码来源:traf_chart.py


注:本文中的reportlab.graphics.shapes.Drawing类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。