Apache POI hinzufügen einer Reihe von Namen in LineChart

Erstelle ich ein LineChart -, Apache-POI in Excel-Dokument. Soweit habe ich es geschafft, zu erreichen, ist in der unten Bild:

Apache POI hinzufügen einer Reihe von Namen in LineChart

Ich schrieb den code mit Beispielen aus der Apache-svn, also mein Aktueller Ansatz sieht so aus:

Drawing drawing = question.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 4, 8, 14, 18);

Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);

LineChartData data = chart.getChartDataFactory().createLineChartData();

ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
bottomAxis.setCrosses(AxisCrosses.AUTO_ZERO);
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);

List<ReportQuestionModel> questionModels = groupModel.getQuestionModels();
for (ReportQuestionModel questionModel : questionModels) {

    List<ReportOptionModel> optionModels = questionModel.getOptionModels();
    for (ReportOptionModel optionModel : optionModels) {
        rowNum++;

        XSSFRow optionRow = question.createRow(rowNum);

        XSSFCell optionsCell = optionRow.createCell(0);
        optionsCell.setCellValue(optionModel.getAnswerText());

        long count = optionModel.getCount();
        totalResponses += count;

        XSSFCell optionsCountCell = optionRow.createCell(1);
        optionsCountCell.setCellValue(count);

        XSSFCell optionsPercentageCell = optionRow.createCell(2);
        optionsPercentageCell.setCellValue(optionModel.getPercentage());
    }
}

ChartDataSource<Number> xs = DataSources.fromNumericCellRange(question, new CellRangeAddress(8, 8, 0, 1));
for (int i = 9; i <= rowNum; i ++) {
    ChartDataSource<Number> ys = DataSources.fromNumericCellRange(question, new CellRangeAddress(i, i, 0, 1));
    data.addSerie(xs, ys);
}
chart.plot(data, bottomAxis, leftAxis);

Was ich nicht finden kann ist, wie man Standard - "Series 1", "Series 2", ..., "Series n" Namen entnommen werden, wie meine Werte aus den Spalten, in diesem Fall von: "Antwort-Optionen". Und es scheint nicht zu sein, alle Methoden, die in der aktuellen API, wie Sie angeben, Namen der Serie.

Kann jemand mir helfen mit diesem, bitte?

Schreibe einen Kommentar