【发布时间】:2021-08-23 13:00:53
【问题描述】:
我使用 apache poi 绘制了一个 3D 堆叠条形图,但我无法处理左轴标题的字体大小和图表的图例。我查看了找到 here 的 ooxml 文档,但无法确定哪个对象对此负责。我添加了一段代码和生成的图表,感谢任何帮助我走上正确的道路。
XSSFSheet sheet = wb.getSheetAt(0);
// Bar chart coordinates
XSSFDrawing drawing = sheet.createDrawingPatriarch();
XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 37, 16, 47);
XSSFChart chart = drawing.createChart(anchor);
// configure axis properties
XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
leftAxis.setTitle("Call Duration");
// font size for left axis labels (ticks)
leftAxis.getOrAddTextProperties().setFontSize(8d);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
XDDFChartData data = chart.createData(ChartTypes.BAR3D, bottomAxis, leftAxis);
// create legend
XDDFChartLegend legend = chart.getOrAddLegend();
legend.setPosition(LegendPosition.BOTTOM);
/*DATA ADDITION HERE*/
【问题讨论】:
标签: java excel charts apache-poi bar-chart