def draw_pie(data=[], labels=[], use_colors=[], width=360,): '''更多属性请查询reportlab.graphics.charts.piecharts.WedgeProperties''' pie = Pie() pie.x = 60 # x,y饼图在框中的坐标 pie.y = 20 pie.slices.label_boxStrokeColor = colors.white #标签边框的颜色 pie.data = data # 饼图上的数据 pie.labels = labels # 数据的标签 pie.simpleLabels = 0 # 0 标签在标注线的右侧;1 在线上边 pie.sameRadii = 1 # 0 饼图是椭圆;1 饼图是圆形 pie.slices.strokeColor = colors.red # 圆饼的边界颜色 pie.strokeWidth=1 # 圆饼周围空白区域的宽度 pie.strokeColor= colors.white # 整体饼图边界的颜色 pie.slices.label_pointer_piePad = 10 # 圆饼和标签的距离 pie.slices.label_pointer_edgePad = 25 # 标签和外边框的距离 pie.width = width pie.direction = 'clockwise' pie.pointerLabelMode = 'LeftRight' # for i in range(len(labels)): # pie.slices[i].fontName = 'song' #设置中文 for i, col in enumerate(use_colors): pie.slices[i].fillColor = col return pie
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)
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)
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)