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
它會起作用。
添加回答
舉報