Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XSSFDrawing drawing = (XSSFDrawing)sheet.createDrawingPatriarch();
- XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 4, 27, 5);
- XSSFChart chart = drawing.createChart(anchor);
- XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
- bottomAxis.setTitle("Week");
- XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
- leftAxis.setTitle("Face Amount ($MM)");
- leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
- leftAxis.setMaximum(10000);
- XDDFDataSource<Double> xs = XDDFDataSourcesFactory.fromNumericCellRange((XSSFSheet) sheet,
- new CellRangeAddress(299, 299, 0, NUM_OF_COLUMNS - 1));
- XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange((XSSFSheet) sheet,
- new CellRangeAddress(300, 300, 0, NUM_OF_COLUMNS - 1));
- XDDFChartData data = chart.createData(ChartTypes.BAR, bottomAxis, leftAxis);
- XDDFChartData.Series series1 = data.addSeries(xs, ys);
- series1.setTitle("2x", null);
- chart.plot(data);
- XDDFBarChartData bar = (XDDFBarChartData) data;
- bar.setBarDirection(BarDirection.COL);
- bar.setGapWidth(3);
- bar.setBarGrouping(BarGrouping.STACKED);
- //set data labels
- XSSFChart xssfChart = (XSSFChart) chart;
- CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
- CTBoolean ctBool = CTBoolean.Factory.newInstance();
- ctBool.setVal(true);
- plotArea.getBarChartArray(0).getSerArray(0).addNewDLbls().setShowVal(ctBool);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().addNewShowLeaderLines();
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowLeaderLines(ctBool);
- ctBool.setVal(false);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowSerName(ctBool);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowPercent(ctBool);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowLegendKey(ctBool);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowCatName(ctBool);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowLeaderLines(ctBool);
- plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowBubbleSize(ctBool);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement