1 回答
TA贡献1863条经验 获得超2个赞
新XDDF代码缺少and 中的axIds设置。lineChartscatterChart
在/xl/charts/chart1.xml这看起来像:
<c:lineChart>
...
<c:axId val="0"/>
<c:axId val="1"/>
</c:lineChart>
对于折线图..
做添加:
...
XDDFChartData data = chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
data.addSeries(xs, ys1);
data.addSeries(xs, ys2);
chart.plot(data);
//setting the axis Ids to the LineChart
chart.getCTChart().getPlotArea().getLineChartArray(0).addNewAxId().setVal(bottomAxis.getId());
chart.getCTChart().getPlotArea().getLineChartArray(0).addNewAxId().setVal(leftAxis.getId());
// Write the output to a file
try (FileOutputStream fileOut = new FileOutputStream("ooxml-line-chart.xlsx")) {
wb.write(fileOut);
}
...
在 LineChart.java
和
...
XDDFChartData data = chart.createData(ChartTypes.SCATTER, bottomAxis, leftAxis);
data.addSeries(xs, ys1);
data.addSeries(xs, ys2);
chart.plot(data);
//setting the axis Ids to the ScatterChart
chart.getCTChart().getPlotArea().getScatterChartArray(0).addNewAxId().setVal(bottomAxis.getId());
chart.getCTChart().getPlotArea().getScatterChartArray(0).addNewAxId().setVal(leftAxis.getId());
// Write the output to a file
try (FileOutputStream fileOut = new FileOutputStream("ooxml-scatter-chart.xlsx")) {
wb.write(fileOut);
}
...
在 ScatterChart.java
它会起作用。
添加回答
举报