private static void addContributorsPerYear()

in reports/src/main/java/nl/obren/sokrates/reports/core/ReportFileExporter.java [116:165]


    private static void addContributorsPerYear(RichTextReport indexReport, List<ContributionYear> contributorsPerYear) {
        if (contributorsPerYear.size() > 0) {
            int limit = 20;
            if (contributorsPerYear.size() > limit) {
                contributorsPerYear = contributorsPerYear.subList(contributorsPerYear.size() - limit, contributorsPerYear.size());
            }

            indexReport.startSubSection("Trend", "");
            int maxContributors = contributorsPerYear.stream().mapToInt(c -> c.getContributorsCount()).max().orElse(1);
            int maxCommits = contributorsPerYear.stream().mapToInt(c -> c.getCommitsCount()).max().orElse(1);

            indexReport.startTable();

            indexReport.startTableRow();
            indexReport.addTableCell("Commits", "border: none;");
            String style = "border: none; text-align: center; vertical-align: bottom; font-size: 80%";
            contributorsPerYear.forEach(year -> {
                indexReport.startTableCell(style);
                int count = year.getCommitsCount();
                indexReport.addParagraph(count + "", "margin: 2px");
                int height = 1 + (int) (64.0 * count / maxCommits);
                indexReport.addHtmlContent("<div style='width: 100%; background-color: darkgrey; height:" + height + "px'></div>");
                indexReport.endTableCell();
            });
            indexReport.endTableRow();

            indexReport.startTableRow();
            indexReport.addTableCell("Contributors", "border: none;");
            contributorsPerYear.forEach(year -> {
                indexReport.startTableCell(style);
                int count = year.getContributorsCount();
                indexReport.addParagraph(count + "", "margin: 2px");
                int height = 1 + (int) (64.0 * count / maxContributors);
                indexReport.addHtmlContent("<div style='width: 100%; background-color: skyblue; height:" + height + "px'></div>");
                indexReport.endTableCell();
            });
            indexReport.endTableRow();

            indexReport.startTableRow();
            indexReport.addTableCell("", "border: none; ");
            contributorsPerYear.forEach(year -> {
                indexReport.addTableCell(year.getYear(), "border: none; text-align: center; font-size: 90%");
            });
            indexReport.endTableRow();

            indexReport.endTable();

            indexReport.endSection();
        }
    }