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


Python Pie.x方法代码示例

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


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

示例1: __add_graph

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [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

示例2: sample4pie

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [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

示例3: test0

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
    def test0(self, isFast=0):
        """Hello World, on a rectangular background.

        The rectangle's fillColor is yellow.
        The string's fillColor is red.
        """
        reportlab.rl_config.shapeChecking = not isFast

        pdfPath = outputfile('test_graphics_speed_fast.pdf')
        c = Canvas(pdfPath)
        t0 = time.time()

        d = Drawing(400, 200)
        num = 100
        for i in range(num):
            pc = Pie()
            pc.x = 150
            pc.y = 50
            pc.data = [10,20,30,40,50,60]
            pc.labels = ['a','b','c','d','e','f']
            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)
        d.drawOn(c, 80, 500)

        t1 = time.time()

        result = 'drew %d pie charts in %0.4f' % (num, t1 - t0)
        open(outputfile('test_graphics_speed_test%s.log' % (isFast+1)), 'w').write(result)
开发者ID:B-Rich,项目名称:M2M,代码行数:35,代码来源:test_graphics_speed.py

示例4: test_24_PieCharts

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
    def test_24_PieCharts(self):
        from reportlab.lib.styles import getSampleStyleSheet
        from reportlab.lib import colors
        from reportlab.lib.units import inch
        from reportlab.platypus import SimpleDocTemplate, Spacer, Paragraph
        from reportlab.pdfbase import pdfmetrics
        from reportlab.graphics.shapes import Drawing
        from reportlab.pdfbase.ttfonts import TTFont
        from reportlab.graphics.charts.piecharts import Pie

        pdfmetrics.registerFont(TTFont('chsFont', 'STHeiti Light.ttc'))
        stylesheet = getSampleStyleSheet()

        elements = []
        doc = SimpleDocTemplate("demo.pdf")

        elements.append(Paragraph('<font name="chsFont">JY.zenist.song - 俊毅</font>', stylesheet['Title']))
        elements.append(Spacer(1,1*inch))

        d = Drawing(400,200)
        data = [13,5,20,22,37,45]
        pc = Pie()
        pc.x = 65
        pc.y = 15
        pc.width = 150
        pc.height = 150
        pc.data = data
        pc.labels = ['a','b','c','d','e','f']
        d.add(pc)

        elements.append(d)

        doc.build(elements)
开发者ID:zenist,项目名称:ZLib,代码行数:35,代码来源:test_pdf.py

示例5: sample4pie

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [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

示例6: __init__

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
    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)
开发者ID:maximerobin,项目名称:Ufwi,代码行数:31,代码来源:render.py

示例7: draw_time_repartition

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
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,代码行数:28,代码来源:export_utils_pdf.py

示例8: make_chart

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def make_chart(stats):
    drawing = Drawing()
    pc = Pie()
    pc.x = 150
    pc.y = 50
    pc.data = stats
    pc.labels = ['Heavily Damaged: %s' % stats[0],'Serverly Damaged: %s' % stats[1]]
    drawing.add(pc, '')
    return drawing
开发者ID:ingenieroariel,项目名称:haiti,代码行数:11,代码来源:views.py

示例9: draw_Pie

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def draw_Pie(story, ProjectID):
    d = Drawing(140, 180)
    pie = Pie()
    pie.sideLabels = 1
    pie.labels= get_story_name_list(ProjectID)
    pie.data = get_story_count_list(ProjectID)
    pie.width = 140
    pie.height = 140
    pie.y = 0
    pie.x = 150
    d.add(pie)
    story.append(d)
开发者ID:ceyeclone,项目名称:team_alpha_project,代码行数:14,代码来源:filemaker.py

示例10: sample4pie

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def sample4pie():
    d = Drawing(400, 200)
    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)
    return d
开发者ID:eaudeweb,项目名称:naaya,代码行数:17,代码来源:test_graphics_charts.py

示例11: graphout

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def graphout(prod_catnames, data):
    drawing = Drawing(500, 200)
    pie = Pie()

    pie.sideLabels       = 1
    pie.labels           = prod_catnames
    pie.data             =  data[0]
    pie.width            = 140
    pie.height           = 140
    pie.y                = 35
    pie.x                = 125
    pie.slices.popout = 5 
    
    drawing.add(pie)
        
    return drawing
开发者ID:CypressBusinessSolutions,项目名称:multivalue-lab,代码行数:18,代码来源:FurnitureRevenuePie.py

示例12: __init__

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [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

示例13: create_pie

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def create_pie(pie_data):
    pie_chart = Drawing(400, 200)
    pc = Pie()
    pc.x = 65
    pc.y = 15
    pc.width = 100
    pc.height = 100
    pc.data = pie_data["data"]     	     
    pc.labels = list(pie_data["label"][0]) 
    pc.slices.strokeWidth=0.5
    pc.slices[3].popout = 10
    pc.slices[3].strokeWidth = 2
    pc.slices[3].strokeDashArray = [2,2]
    pc.slices[3].labelRadius = 1.75
    pc.slices[3].fontColor = colors.red
    pie_chart.add(pc)
    return pie_chart
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:19,代码来源:pie.py

示例14: pie_graph

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def pie_graph(data, elements):
    drawing = Drawing(100, 350)
    pc = Pie()
    pc.x = 65
    pc.y = 15
    pc.width = 300
    pc.height = 300
    pc.data = data
    pc.labels = ['a', 'b', 'c', 'd', 'e', 'f']
    pc.slices.strokeWidth = 0.5
    pc.slices[3].popout = 10
    pc.slices[3].strokeWidth = 2
    pc.slices[3].strokeDashArray = [2, 2]
    pc.slices[3].labelRadius = 1.75
    pc.slices[3].fontColor = colors.red
    drawing.add(pc)
    elements.append(drawing)
开发者ID:prakhar987,项目名称:PDF-Generator-SSAD-Project,代码行数:19,代码来源:views.py

示例15: piegraph

# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import x [as 别名]
def piegraph(elements):
    drawing = Drawing(100, 350)
    pc = Pie()
    pc.x = 65
    pc.y = 15
    pc.width = 300
    pc.height = 300
    pc.data = [10, 20, 30, 40, 50, 60]
    pc.labels = ['a', 'b', 'c', 'd', 'e', 'f']
    pc.slices.strokeWidth = 0.5
    pc.slices[3].popout = 10
    pc.slices[3].strokeWidth = 2
    pc.slices[3].strokeDashArray = [2, 2]
    pc.slices[3].labelRadius = 1.75
    pc.slices[3].fontColor = colors.red
    drawing.add(pc)
    elements.append(drawing)
    elements.append(Spacer(1, 0.7 * inch))
开发者ID:prakhar987,项目名称:PDF-Generator-SSAD-Project,代码行数:20,代码来源:views1.py


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