poi生成的图表,跳过空值,将空单元显示为间隙
更改空单元格、null (#N/A) 值和隐藏的行与列在图表中的显示方式
错误效果
正确效果
// 下面代码实测有效
XSSFChart chart = (XSSFChart)drawing.createChart(anchor);
// this will set blank values as gaps in the chart so you
// can accurately plot data series of different lengths
CTDispBlanksAs disp = CTDispBlanksAs.Factory.newInstance();
disp.setVal(STDispBlanksAs.GAP);
chart.getCTChart().setDispBlanksAs(disp);
// setup chart, axes, data series, etc或者
chart.plot(data, new ChartAxis[] { bottomAxis, leftAxis });
// this must occur after the call to chart.plot above
CTPlotArea plotArea = chart.getCTChart().getPlotArea();
for (CTLineChart ch : plotArea.getLineChartList()) {
for (CTLineSer ser : ch.getSerList()) {
CTBoolean ctBool = CTBoolean.Factory.newInstance();
ctBool.setVal(false);
ser.setSmooth(ctBool);
}
}