Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. XSSFDrawing drawing = (XSSFDrawing)sheet.createDrawingPatriarch();
  2. XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 4, 27, 5);
  3. XSSFChart chart = drawing.createChart(anchor);
  4.  
  5. XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
  6. bottomAxis.setTitle("Week");
  7. XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
  8. leftAxis.setTitle("Face Amount ($MM)");
  9. leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
  10. leftAxis.setMaximum(10000);
  11.  
  12. XDDFDataSource<Double> xs = XDDFDataSourcesFactory.fromNumericCellRange((XSSFSheet) sheet,
  13. new CellRangeAddress(299, 299, 0, NUM_OF_COLUMNS - 1));
  14. XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange((XSSFSheet) sheet,
  15. new CellRangeAddress(300, 300, 0, NUM_OF_COLUMNS - 1));
  16.  
  17. XDDFChartData data = chart.createData(ChartTypes.BAR, bottomAxis, leftAxis);
  18. XDDFChartData.Series series1 = data.addSeries(xs, ys);
  19. series1.setTitle("2x", null);
  20.  
  21. chart.plot(data);
  22.  
  23. XDDFBarChartData bar = (XDDFBarChartData) data;
  24. bar.setBarDirection(BarDirection.COL);
  25. bar.setGapWidth(3);
  26. bar.setBarGrouping(BarGrouping.STACKED);
  27.  
  28. //set data labels
  29. XSSFChart xssfChart = (XSSFChart) chart;
  30. CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
  31. CTBoolean ctBool = CTBoolean.Factory.newInstance();
  32. ctBool.setVal(true);
  33. plotArea.getBarChartArray(0).getSerArray(0).addNewDLbls().setShowVal(ctBool);
  34. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().addNewShowLeaderLines();
  35. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowLeaderLines(ctBool);
  36. ctBool.setVal(false);
  37. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowSerName(ctBool);
  38. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowPercent(ctBool);
  39. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowLegendKey(ctBool);
  40. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowCatName(ctBool);
  41. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowLeaderLines(ctBool);
  42. plotArea.getBarChartArray(0).getSerArray(0).getDLbls().setShowBubbleSize(ctBool);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement