如何在Apache Poi中反转轴。

huangapple go评论69阅读模式
英文:

How to invert axis in Apache Poi

问题

以下是翻译好的内容:

我正在使用POI 4.1.0创建图表,但是我的柱状图颠倒了。

如何在Apache Poi中反转轴。

如何在Apache Poi中反转轴。

我如何翻转图表?

XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, col1, row1, col2, row2);
XSSFChart chart = drawing.createChart(anchor);
XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
XDDFDataSource<String> dataSource = XDDFDataSourcesFactory.fromStringCellRange(sheet,
    new CellRangeAddress(startRow, data.getRows().size() + (startRow - 1), 0, 0));
XDDFChartData data = chart.createData(chartObj.getType(), bottomAxis, leftAxis);
XDDFNumericalDataSource<Double> values = XDDFDataSourcesFactory.fromNumericCellRange(sheet,
    new CellRangeAddress(startRow, this.data.getRows().size() + (startRow - 1), 
    chartObj.getColumn(),chartObj.getColumn()));
XDDFChartData.Series series1 = data.addSeries(dataSource, values);
chart.plot(data);
英文:

I am using POI 4.1.0 to create charts but my bar chart is upside down

如何在Apache Poi中反转轴。

如何在Apache Poi中反转轴。

How can I flip the chart?

XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, col1, row1, col2, row2);
XSSFChart chart = drawing.createChart(anchor);
XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
XDDFDataSource&lt;String&gt; dataSource = XDDFDataSourcesFactory.fromStringCellRange(sheet,
			new CellRangeAddress(startRow, data.getRows().size() + (startRow - 1), 0, 0));
XDDFChartData data = chart.createData(chartObj.getType(), bottomAxis, leftAxis);
XDDFNumericalDataSource&lt;Double&gt; values = XDDFDataSourcesFactory.fromNumericCellRange(sheet,
				new CellRangeAddress(startRow, this.data.getRows().size() + (startRow - 1), 
chartObj.getColumn(),chartObj.getColumn()));
XDDFChartData.Series series1 = data.addSeries(dataSource, values);
chart.plot(data);

答案1

得分: 1

XDDFChartData data = chart.createData(...);
...
XDDFBarChartData bar = (XDDFBarChartData) data;
bar.getCategoryAxis().setOrientation(AxisOrientation.MAX_MIN);

英文:
XDDFChartData data = chart.createData(...);
...
XDDFBarChartData bar = (XDDFBarChartData) data;
bar.getCategoryAxis().setOrientation(AxisOrientation.MAX_MIN);

huangapple
  • 本文由 发表于 2020年7月23日 15:49:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/63049375.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定