亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

POI 4.1.0 折線圖 y 系列顯示錯誤的圖例

POI 4.1.0 折線圖 y 系列顯示錯誤的圖例

qq_遁去的一_1 2023-10-13 16:33:47
如何在 y 系列上創建具有單個圖例的折線圖,而不是在 x 系列上顯示多個圖例int rows = numberOfRows - 1;int cols = headers.size();XSSFDrawing drawing = sheet.createDrawingPatriarch();XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15);XSSFChart chart = drawing.createChart(anchor);chart.displayBlanksAs(DisplayBlanks.GAP);XDDFChartLegend legend = chart.getOrAddLegend();legend.setPosition(LegendPosition.TOP_RIGHT);// Use a category axis for the bottom axis.XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);bottomAxis.setOrientation(AxisOrientation.MAX_MIN);bottomAxis.setTitle("Date");XDDFValueAxis rightAxis = chart.createValueAxis(AxisPosition.RIGHT);rightAxis.setTitle("Rates");rightAxis.setCrosses(AxisCrosses.AUTO_ZERO);XDDFChartLegend chartLegend = chart.getOrAddLegend();chartLegend.setPosition(LegendPosition.TOP_RIGHT);chartLegend.setOverlay(false);XDDFLineChartData lineChartData = (XDDFLineChartData) chart.createData(ChartTypes.LINE, bottomAxis, rightAxis);XDDFDataSource<String> xs = XDDFDataSourcesFactory.fromStringCellRange(sheet, new CellRangeAddress(1, rows, 0, 0));for (int col = 1; col < cols; col++) {    XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(1, rows, col, col));    XDDFLineChartData.Series series1 = (XDDFLineChartData.Series) lineChartData.addSeries(xs, ys1);    series1.setTitle(headers.get(col), null);    series1.setSmooth(false);    series1.setMarkerStyle(MarkerStyle.NONE);}chart.plot(lineChartData);上圖顯示了我當前的繪圖折線圖,y 系列預計只有 1 個圖例,但顯示了多個上圖折線圖是使用 Excel 繪制的,y 系列僅顯示 1 個圖例
查看完整描述

1 回答

?
翻過高山走不出你

TA貢獻1875條經驗 獲得超3個贊

有一個設置可以改變圖表中同系列數據標記的顏色。請參閱:改變圖表中同系列數據標記的顏色。false默認情況下最多為Excel 2007?,F在Microsoft決定將該設置設為true默認值。false因此,如果您不想要它,則需要明確設置。


在你的情況下:


...

XDDFLineChartData lineChartData = (XDDFLineChartData) chart.createData(ChartTypes.LINE, bottomAxis, rightAxis);

lineChartData.setVaryColors(false);

...


查看完整回答
反對 回復 2023-10-13
  • 1 回答
  • 0 關注
  • 231 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號