本文整理汇总了Python中reportlab.graphics.charts.piecharts.Pie.y方法的典型用法代码示例。如果您正苦于以下问题:Python Pie.y方法的具体用法?Python Pie.y怎么用?Python Pie.y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.graphics.charts.piecharts.Pie
的用法示例。
在下文中一共展示了Pie.y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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)
示例2: sample4pie
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例3: test_24_PieCharts
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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)
示例4: __add_graph
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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)
示例5: test0
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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)
示例6: sample4pie
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例7: draw_time_repartition
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例8: make_chart
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例9: draw_Pie
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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)
示例10: sample4pie
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例11: graphout
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例12: __init__
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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")
示例13: create_pie
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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
示例14: pie_graph
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [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)
示例15: plpleg
# 需要导入模块: from reportlab.graphics.charts.piecharts import Pie [as 别名]
# 或者: from reportlab.graphics.charts.piecharts.Pie import y [as 别名]
def plpleg(i=None):
from reportlab.lib.colors import pink, red, green
pie = Pie()
pie.x = 0
pie.y = 0
pie.pointerLabelMode='LeftAndRight'
pie.slices.label_boxStrokeColor = red
pie.simpleLabels = 0
pie.sameRadii = 1
pie.data = [1, 0.1, 1.7, 4.2,0,0]
pie.labels = ['abcdef', 'b', 'c', 'd','e','fedcba']
pie.strokeWidth=1
pie.strokeColor=green
pie.slices.label_pointer_piePad = 6
pie.width = 160
pie.direction = 'clockwise'
pie.pointerLabelMode = 'LeftRight'
return autoLegender(i,pie,pie.slices,None)