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


Python VerticalBarChart.barLabels方法代码示例

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


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

示例1: create_single_class_pdf

# 需要导入模块: from reportlab.graphics.charts.barcharts import VerticalBarChart [as 别名]
# 或者: from reportlab.graphics.charts.barcharts.VerticalBarChart import barLabels [as 别名]

#.........这里部分代码省略.........
            + "%"
        )
        standard_averages[0].append(
            int(round((standard_total_dict[standard][1] / standard_total_dict[standard][0]) * 100))
        )

        # add assignments to correct buckets
        for grade in grade_standard_dict.keys():
            for standardId in grade_standard_dict[grade][1]:
                if standardId == standard:
                    standard_table[i].append(
                        grade_standard_dict[grade][0]
                        + ":"
                        + format((grade_student_dict[grade][1] / grade_student_dict[grade][0]) * 100, ".2f")
                        + "%"
                    )
        i += 1
    sorted(standard_table, key=lambda l: l[0])

    # graph
    drawing = Drawing(600, 200)
    data = standard_averages
    bc = VerticalBarChart()

    # location in the document (x,y)
    bc.x = 10
    bc.y = 30

    # width and height of the graph
    bc.height = 225
    bc.width = 400
    bc.data = data
    bc.categoryAxis.drawGridLast = True
    bc.categoryAxis.gridStart = 0
    bc.categoryAxis.gridStrokeLineCap = 2
    bc.categoryAxis.gridEnd = 3
    bc.barLabels = [10, 20, 30, 40, 50]

    # Update colors of the bars in the graph
    bc.bars.symbol = ShadedRect()
    bc.bars.symbol.fillColorStart = colors.lightblue
    bc.bars.symbol.fillColorEnd = colors.lightblue
    bc.bars.symbol.strokeWidth = 0

    # this draws a line at the top of the graph to close it.
    bc.strokeColor = colors.black

    # Y-axis min, max, and steps.
    if minimum != 100:
        bc.valueAxis.valueMin = minimum - 10
    else:
        bc.valueAxis.valueMin = 50
    bc.valueAxis.valueMax = 100
    bc.valueAxis.valueStep = 5

    # where to anchor the origin of the graph
    bc.categoryAxis.labels.boxAnchor = "ne"

    # Locations of labels for the X-axis
    bc.categoryAxis.labels.dx = 2
    bc.categoryAxis.labels.dy = -2

    # The angle of the lables for the X-axis
    bc.categoryAxis.labels.angle = 30
    # List of the categories to place on the X-axis
    bc.categoryAxis.categoryNames = standards_list
    drawing.add(bc)

    # Graph Legend
    legend = Legend()
    legend.alignment = "right"
    legend.x = 420
    legend.y = 150
    legend.deltax = 60
    legend.dxTextSpace = 10
    legend.columnMaximum = 4

    legend.colorNamePairs = [(colors.lightblue, "grade average")]
    drawing.add(legend, "legend")
    drawing_title = "Bar Graph"
    Story.append(drawing)

    t = Table(standard_table)
    t.setStyle(
        t.setStyle(
            TableStyle(
                [
                    ("BOX", (0, 0), (-1, -1), 0.25, colors.black),
                    ("FONTSIZE", (0, 0), (-1, -1), 7),
                    ("BACKGROUND", (0, 0), (0, -1), colors.lightgrey),
                    ("INNERGRID", (0, 0), (-1, -1), 0.25, colors.black),
                ]
            )
        )
    )
    Story.append(t)
    doc.build(Story)
    pdf = buff.getvalue()
    buff.close()
    return pdf
开发者ID:bpatzke,项目名称:student-growth-tracker,代码行数:104,代码来源:classes.py


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