如何更改由Apache Poi生成的图表以不使用平滑线并将空白单元格显示为间隙?

如何更改由Apache Poi生成的图表以不使用平滑线并将空白单元格显示为间隙?,第1张

如何更改由Apache Poi生成的图表以不使用平滑线并将空白单元格显示为间隙

感谢Etienne提供了将空白设置为空白的代码。我从POI开发人员那里得到了帮助,这是解决原始问题中提到的两个问题的解决方案。

    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);        }    }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5020924.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存