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


Python Legend.boxAnchor方法代码示例

本文整理汇总了Python中reportlab.graphics.charts.legends.Legend.boxAnchor方法的典型用法代码示例。如果您正苦于以下问题:Python Legend.boxAnchor方法的具体用法?Python Legend.boxAnchor怎么用?Python Legend.boxAnchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.graphics.charts.legends.Legend的用法示例。


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

示例1: addAutoLegend

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
    def addAutoLegend(self,chart,offset,num,side='bottom'):
        from reportlab.lib.validators import Auto
        width = 300
        height = 150
        legend = Legend()
        if side == 'bottom':
            legend.x = offset[0]-15
            legend.dx = 20
            legend.dy = 5
            legend.y = offset[1]-25
            legend.deltax = None
            legend.autoXPadding = 35
            legend.deltay = 5
            legend.boxAnchor = 'nw'
            legend.dxTextSpace = 5
            legend.columnMaximum = (num/3)
            if num%3 >0:
                legend.columnMaximum += 1

            legend.variColumn = True
        elif side == 'right':
            legend.x = offset[0]+offset[2]+40
            legend.dx = 20
            legend.dy = 5
            legend.y = offset[1]+offset[3]-15
            legend.deltax = None
            legend.deltay = 5
            legend.boxAnchor = 'nw'
            legend.dxTextSpace = 5
            legend.columnMaximum = 9

        legend.colorNamePairs=Auto(chart=chart)
        return legend
开发者ID:jhuguetn,项目名称:WAD_Python,代码行数:35,代码来源:reporter.py

示例2: autoLegender

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
def autoLegender(i,chart,styleObj,sym='symbol'):
    if sym:
        setattr(styleObj[0],sym, makeMarker('Diamond',size=6))
        setattr(styleObj[1],sym,makeMarker('Square'))
    width = 300
    height = 150
    legend = Legend()
    legend.x = width-5
    legend.y = 5
    legend.dx = 20
    legend.dy = 5
    legend.deltay = 0
    legend.boxAnchor = 'se'
    if i=='col auto':
        legend.colorNamePairs[0]=(Auto(chart=chart),'auto chart=self.chart')
        legend.colorNamePairs[1]=(Auto(obj=chart,index=1),'auto  chart=self.chart index=1')
    elif i=='full auto':
        legend.colorNamePairs=Auto(chart=chart)
    elif i=='swatch set':
        legend.swatchMarker=makeMarker('Circle')
        legend.swatchMarker.size = 10
    elif i=='swatch auto':
        legend.swatchMarker=Auto(chart=chart)
    d = Drawing(width,height)
    d.background = Rect(0,0,width,height,strokeWidth=1,strokeColor=colors.red,fillColor=None)
    m = makeMarker('Cross')
    m.x = width-5
    m.y = 5
    m.fillColor = colors.red
    m.strokeColor = colors.yellow
    d.add(chart)
    d.add(legend)
    d.add(m)
    return d
开发者ID:Jbaumotte,项目名称:web2py,代码行数:36,代码来源:test_graphics_charts.py

示例3: sample4pie

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
def sample4pie():
    width = 300
    height = 150
    d = Drawing(width, height)
    pc = Pie()
    pc.x = 150
    pc.y = 50
    pc.data = [1, 50, 100, 100, 100, 100, 100, 100, 100, 50]
    pc.labels = ['0','a','b','c','d','e','f','g','h','i']
    pc.slices.strokeWidth=0.5
    pc.slices[3].popout = 20
    pc.slices[3].strokeWidth = 2
    pc.slices[3].strokeDashArray = [2,2]
    pc.slices[3].labelRadius = 1.75
    pc.slices[3].fontColor = colors.red
    d.add(pc)
    legend = Legend()
    legend.x = width-5
    legend.y = height-5
    legend.dx = 20
    legend.dy = 5
    legend.deltax = 0
    legend.boxAnchor = 'nw'
    legend.colorNamePairs=Auto(chart=pc)
    d.add(legend)
    return d
开发者ID:Jbaumotte,项目名称:web2py,代码行数:28,代码来源:test_graphics_charts.py

示例4: legend_draw

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
    def legend_draw(self, labels, chart, **kwargs):
        legend = Legend()
        chart_type = kwargs['type']
        legend.fontName = 'FreeSans'
        legend.fontSize = 13
        legend.strokeColor = None
        if 'x' in kwargs:
            legend.x = kwargs['x']
        if 'y' in kwargs:
            legend.y = kwargs['y']
        legend.alignment = 'right'
        if 'boxAnchor' in kwargs:
            legend.boxAnchor = kwargs['boxAnchor']
        if 'columnMaximum' in kwargs:
            legend.columnMaximum = kwargs['columnMaximum']
        # x-distance between neighbouring swatche\s
        legend.deltax = 0
        lcolors = legendcolors
        if chart_type == 'line':
            lcolors = [colors.red, colors.blue]
        legend.colorNamePairs = zip(lcolors, labels)

        for i, color in enumerate(lcolors):
            if chart_type == 'line':
                chart.lines[i].fillColor = color
            elif chart_type == 'pie':
                chart.slices[i].fillColor = color
            elif chart_type == 'bar':
                chart.bars[i].fillColor = color
        return legend
开发者ID:Cuahutli,项目名称:python-django-exporting-files,代码行数:32,代码来源:pdf_utils.py

示例5: autoLegender

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
def autoLegender(i, chart, styleObj, sym="symbol"):
    if sym:
        setattr(styleObj[0], sym, makeMarker("Diamond", size=6))
        setattr(styleObj[1], sym, makeMarker("Square"))
    width = 300
    height = 150
    legend = Legend()
    legend.x = width - 5
    legend.y = 5
    legend.dx = 20
    legend.dy = 5
    legend.deltay = 0
    legend.boxAnchor = "se"
    if i == "col auto":
        legend.colorNamePairs[0] = (Auto(chart=chart), "auto chart=self.chart")
        legend.colorNamePairs[1] = (Auto(obj=chart, index=1), "auto  chart=self.chart index=1")
    elif i == "full auto":
        legend.colorNamePairs = Auto(chart=chart)
    elif i == "swatch set":
        legend.swatchMarker = makeMarker("Circle")
        legend.swatchMarker.size = 10
    elif i == "swatch auto":
        legend.swatchMarker = Auto(chart=chart)
    d = Drawing(width, height)
    d.background = Rect(0, 0, width, height, strokeWidth=1, strokeColor=colors.red, fillColor=None)
    m = makeMarker("Cross")
    m.x = width - 5
    m.y = 5
    m.fillColor = colors.red
    m.strokeColor = colors.yellow
    d.add(chart)
    d.add(legend)
    d.add(m)
    return d
开发者ID:sylex-team,项目名称:reportlab-patched,代码行数:36,代码来源:test_graphics_charts.py

示例6: sample4pie

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
def sample4pie():
    width = 300
    height = 150
    d = Drawing(width, height)
    pc = Pie()
    pc.x = 150
    pc.y = 50
    pc.data = [1, 50, 100, 100, 100, 100, 100, 100, 100, 50]
    pc.labels = ["0", "a", "b", "c", "d", "e", "f", "g", "h", "i"]
    pc.slices.strokeWidth = 0.5
    pc.slices[3].popout = 20
    pc.slices[3].strokeWidth = 2
    pc.slices[3].strokeDashArray = [2, 2]
    pc.slices[3].labelRadius = 1.75
    pc.slices[3].fontColor = colors.red
    d.add(pc)
    legend = Legend()
    legend.x = width - 5
    legend.y = height - 5
    legend.dx = 20
    legend.dy = 5
    legend.deltax = 0
    legend.boxAnchor = "nw"
    legend.colorNamePairs = Auto(chart=pc)
    d.add(legend)
    return d
开发者ID:sylex-team,项目名称:reportlab-patched,代码行数:28,代码来源:test_graphics_charts.py

示例7: __add_graph

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
    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,代码行数:62,代码来源:reporter.py

示例8: __init__

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
    def __init__(self, data, labels):
        super(PieChart, self).__init__(400,200)

        colors = [  
            HexColor("#0000e5"),  
            HexColor("#ff0011"),
            HexColor("#800000"),
            HexColor("#e05897"),   
            HexColor("#a08ff7"),  
            HexColor("#8f8ff5"),  
            HexColor("#c7c7fa"),  
            HexColor("#800000"),  
            HexColor("#eb8585"),   
            HexColor("#d60a0a"),  
            HexColor("#ffff00"),
            HexColor("#1f1feb"),   
        ]  

        # Create pie chart 
        pieChart = Pie()
        pieChart.x = 40
        pieChart.y = 30
        pieChart.width = 120
        pieChart.height = 120
        pieChart.slices.strokeWidth=0.5
        data = json.loads(data)
        pieChart.data = data
        pieChart.labels = []
        labels = json.loads(labels.replace("'",'"'))
        for d in data:
            pieChart.labels.append(str(d))

        # Create legend
        legend = Legend()
        legend.x = 380
        legend.y = 60  
        legend.boxAnchor           = 'se'  
        legend.subCols[1].align    = 'right'
        legend.colorNamePairs = []

        len_data = len(data) 
        for i in range(0,len_data):
            pieChart.slices[i].fillColor = colors[i]
            legend.colorNamePairs.append((colors[i],labels[i]))

        self.add(pieChart, "pie chart")       
        self.add(legend, "legend")
开发者ID:ranjithtenz,项目名称:pulpo-forms-django,代码行数:49,代码来源:PieChart.py

示例9: generar_pdf_busquedas_view

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]

#.........这里部分代码省略.........
            ('BACKGROUND', (0, 0), (-1, 0), colors.dodgerblue)
        ]
    ))


#GRAFICA DE BARRAS

    titulo = Paragraph("Busquedas encontradas y no encontradas en el sistema", estilo['title'])

    drawing = Drawing(400, 200)
    data = [(si, no)]
    bc = VerticalBarChart()
    bc.x = 50
    bc.y = 50
    bc.height = 125
    bc.width = 300
    bc.data = data
    bc.bars[0].fillColor = colors.blue
    bc.bars[1].fillColor = colors.black
    bc.strokeColor = colors.black
    bc.fillColor = colors.silver
    bc.valueAxis.valueMin = 0
    bc.valueAxis.valueMax = total_busquedas+30
    try:
        r = total_busquedas/2
        if type(r) == 'float':
            bc.valueAxis.valueStep = total_busquedas+0.5
        if type(r) == 'int':
            bc.valueAxis.valueStep = r
    except:
        "Nos se puede"


    bc.categoryAxis.labels.boxAnchor = 'ne'
    bc.categoryAxis.labels.dx = 8
    bc.categoryAxis.labels.dy = -2
    bc.categoryAxis.labels.angle = 0
    bc.categoryAxis.categoryNames = ['Encontradas', 'No Encontradas']
    drawing.add(bc)

    bc.barLabels.nudge = 20
    bc.barLabelFormat = '%0.0f'
    bc.barLabels.dx = 0
    bc.barLabels.dy = 0
    bc.barLabels.boxAnchor = 'n' # irrelevant (becomes 'c')
    bc.barLabels.fontName = 'Helvetica'
    bc.barLabels.fontSize = 14





    
#GRAFICAS DE PASTEL
    titulo2 = Paragraph("Busquedas y número de veces realizadas", estilo['title'])

    d = Drawing(400, 200)
    pc = Pie()
    pc.x = 125
    pc.y = 25
    pc.data = lista
    print lista
    #pc.data = [7, 1, 1, 1, 1, 2]

    #pc.labels = [ str(i.values()) for i in Busqueda.objects.filter(fecha__range=(fecha_inicio, fecha_final)).values('busqueda').distinct()]
    lista_labels = [ str(i.values()) for i in Busqueda.objects.filter(fecha__range=(fecha_inicio, fecha_final)).values('busqueda').distinct()]
开发者ID:Monita1234,项目名称:adsi,代码行数:70,代码来源:views.py

示例10: __get_tags_statistics

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
    def __get_tags_statistics(self):
        monto_categorias = dict()
        for tra in self.transactions:
            if len(tra.tags) > 0:
                for tag in tra.tags:
                    if tag in monto_categorias.keys():
                        monto_categorias[tag] += tra.amount
                    else:
                        monto_categorias[tag] = tra.amount

        labels = [lab.encode('utf-8') for lab in monto_categorias.keys()]
        data = monto_categorias.values()

        p = PageBreak()
        p.drawOn(self.c, 0, 1000)
        self.c.showPage()
        self.l = 600

        self.c.setFont('Courier', 14)
        self.c.drawString(30, 800, 'Categorias')

        drawing = Drawing(200, 200)

        pie = Pie()
        pie.x = 30
        pie.y = self.l - 130
        pie.height = 300
        pie.width = 300
        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 = self.l
        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, 10

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

示例11: __per_account_statistic

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
    def __per_account_statistic(self):

        for acc in self.accounts:
            p = PageBreak()
            p.drawOn(self.c, 0, 1000)
            self.c.showPage()
            self.l = 760

            self.c.setFont('Courier', 14)
            self.c.drawString(30, 800, 'Cuenta: %s' % \
                acc.name)

            header = ['Fecha', 'Tipo', 'Monto', 'Description']
            data   = [header]
            g_data = list()
            g_labe = list()
            total  = 0

            for tra in self.transactions:
                if tra.account == acc.name:
                    if tra.t_type in ['expense', 'transfer']:
                        tipo = self.__translate_type(tra.t_type)
                        data.append([tra.date, tipo.upper(),
                            '$%2.f' % tra.amount, tra.description])
                        total += tra.amount

                        g_data.append(tra.amount)
                        g_labe.append(tra.description.encode('utf-8'))

            data.append(['TOTAL', '', '$%.2f' % total, ''])

            if len(g_data) == 0 or len(g_labe) == 0:
                self.c.setFont('Courier', 12)
                self.c.drawString(30, 770, 'Sin movimientos negativos')
                continue
 
            from_title = 35
            if len(data) != 2:
                self.l -= ((len(data) * len(data)) + len(data)) + from_title

            t = Table(data)
            t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, black),
                ('BOX', (0,0), (-1,-1), 0.25, black),
                ('FONTNAME', (0,0), (-1,0), 'Courier-Bold'),
                ('BACKGROUND', (0,0), (-1,0), HexColor('#efeded')),
                ('BACKGROUND', (0,0), (0,-1), HexColor('#efeded')),
                ('FONTSIZE', (0,0), (-1,0), 12),
                ('FONTSIZE', (0,1), (-1,-1), 8),
                ('FONTNAME', (0,1), (-1,-1), 'Courier'),
                ('BACKGROUND', (0,-1), (-1,-1), red),
                ('TEXTCOLOR', (0,-1), (-1,-1), white)]))

            t.wrapOn(self.c, 30, self.l)
            t.drawOn(self.c, 30, self.l)

            drawing = Drawing(200, 100)

            pie = Pie()
            pie.x = 30
            pie.y = self.l - 300
            pie.height = 200
            pie.width = 200
            pie.data = g_data
            pie.labels = g_labe
            pie.simpleLabels = 1
            pie.slices.strokeWidth = 1
            pie.slices.strokeColor = black
            pie.slices.label_visible = 0
            pie.slices.popout        = 1
            #pie.labels   = map(str, pie.data)

            
            legend = Legend()
            legend.x = 250
            legend.y = self.l - 250
            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)]
            

#.........这里部分代码省略.........
开发者ID:gaccardo,项目名称:buxfer_api,代码行数:103,代码来源:reporter.py

示例12: range

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
# Set bar colors
for i in range(len(colors)):
    chart.bars[i].fillColor = colors[i]

# Add data to chart
chart.data = prices
chart.categoryAxis.categoryNames = categories

# Add labels to chart
chart.barLabelFormat = '$%.2f'  # Text to display on label - 2 decimal float
chart.barLabels.nudge = 8       # Nudge labels upwards by 8px


# ------- Create legend -------
legend = Legend()               # Create the legend
legend.boxAnchor = 'sw'         # Set anchor to bottom-left
legend.x = 50                   # Shift legend right to bring in line with chart
legend.y = 50                   # Shift legend up by 50px
legend.alignment = 'right'      # Put labels to the right of color icons

# Set legend colors
legend.colorNamePairs = [(colors[i], '{}  '.format(labels[i])) for i in range(len(colors))]


# Add chart and legend to drawing
d.add(chart)
d.add(legend)

# Export as test_img.png
d.save(fnRoot='test_img', formats=['png'])
开发者ID:llf0029,项目名称:ue4-marketplace-scraper,代码行数:32,代码来源:outputTest.py

示例13: range

# 需要导入模块: from reportlab.graphics.charts.legends import Legend [as 别名]
# 或者: from reportlab.graphics.charts.legends.Legend import boxAnchor [as 别名]
        lp.yValueAxis.labels.fontName = 'Helvetica'
        lp.yValueAxis.labels.fontSize = 7
        lp.yValueAxis.visibleGrid = True
        lp.yValueAxis.drawGridLast = True
        lp.yValueAxis.valueMin = 0
        if reserved:
            if reserved[0]: lp.yValueAxis.valueMax = reserved[0]
            if reserved[1]: lp.yValueAxis.valueStep = reserved[1]

        for i in range(len(names)):
            lp.lines[i].strokeColor = self.Color[i]

        legend = Legend()
        legend.x = 0
        legend.y = h - 30
        legend.boxAnchor = 'sw'
        legend.colorNamePairs = [(self.Color[i], names[i]) for i in range(len(names))]
        legend.fontName = 'Helvetica'
        legend.fontSize = 8
        legend.dxTextSpace = 5
        legend.dy = 5
        legend.dx = 5
        legend.deltay = 5
        legend.alignment ='right'

        drawing.add(lp)
        drawing.add(legend)

        if title != None:
            label = Label()
            label.x = w
开发者ID:cokesprite,项目名称:memory-tool,代码行数:33,代码来源:mmparse.py


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