java窗体线条切换消失_java – 如何更改apache poi生成的图表不使用平滑线条并将空单元格显示为间隙?...

我使用的是POI 3.12-beta1,并且代码可以在图例中创建包含多个数据集和命名系列的折线图.但是,poi中折线图的默认设置会生成一条已在数据点上平滑的线.空值也被绘制为0,但我们希望这些线在第一列停止,其中有一个空单元格.

一旦在xlsx文件中呈现并更改这些设置,我就可以进入图表属性,但我们需要使用这些设置渲染xlsx.我在可用的API中找不到任何更改这些设置的内容.

Drawing drawing = sheet.createDrawingPatriarch();

ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 17, 18, 30);

Chart chart = drawing.createChart(anchor);

ChartLegend legend = chart.getOrCreateLegend();

legend.setPosition(LegendPosition.RIGHT);

LineChartData data = chart.getChartDataFactory().createLineChartData();

ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);

ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);

leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);

int row = 2;

int startCol = 3;

int endCol = 17;

boolean abs = false;

ChartDataSource xs = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(row, row, startCol, endCol));

row = 10;

int seriesCol = 0;

ChartDataSource ys1 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(row, row, startCol, endCol));

LineChartSerie ser1 = data.addSerie(xs, ys1);

ser1.setTitle(new CellReference(sheet.getSheetName(), row, seriesCol, abs, abs));

row = 11;

ChartDataSource ys2 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(row, row, startCol, endCol));

LineChartSerie ser2 = data.addSerie(xs, ys2);

ser2.setTitle(new CellReference(sheet.getSheetName(), row, seriesCol, abs, abs));

row = 12;

ChartDataSource ys3 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(row, row, startCol, endCol));

LineChartSerie ser3 = data.addSerie(xs, ys3);

ser3.setTitle(new CellReference(sheet.getSheetName(), row, seriesCol, abs, abs));

chart.plot(data, new ChartAxis[] { bottomAxis, leftAxis });

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值