Bug 51196: more progress with chart api
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1125662 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a657b06e30
commit
c1fb0136bb
@ -37,7 +37,7 @@ public class ScatterChart {
|
|||||||
public static void main(String[]args) throws Exception {
|
public static void main(String[]args) throws Exception {
|
||||||
Workbook wb = new XSSFWorkbook();
|
Workbook wb = new XSSFWorkbook();
|
||||||
CreationHelper creationHelper = wb.getCreationHelper();
|
CreationHelper creationHelper = wb.getCreationHelper();
|
||||||
Sheet sheet = wb.createSheet("new sheet");
|
Sheet sheet = wb.createSheet("Sheet 1");
|
||||||
final int NUM_OF_ROWS = 3;
|
final int NUM_OF_ROWS = 3;
|
||||||
final int NUM_OF_COLUMNS = 10;
|
final int NUM_OF_COLUMNS = 10;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class ScatterChart {
|
|||||||
|
|
||||||
Chart chart = drawing.createChart(anchor);
|
Chart chart = drawing.createChart(anchor);
|
||||||
ChartLegend legend = chart.getOrCreateLegend();
|
ChartLegend legend = chart.getOrCreateLegend();
|
||||||
legend.setPosition(LegendPosition.RIGHT);
|
legend.setPosition(LegendPosition.TOP_RIGHT);
|
||||||
|
|
||||||
ScatterChartData data = chart.getChartDataFactory().createScatterChartData();
|
ScatterChartData data = chart.getChartDataFactory().createScatterChartData();
|
||||||
|
|
||||||
@ -65,12 +65,12 @@ public class ScatterChart {
|
|||||||
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
|
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
|
||||||
|
|
||||||
ScatterChartSerie firstSerie = data.addSerie();
|
ScatterChartSerie firstSerie = data.addSerie();
|
||||||
firstSerie.setXValues(sheet, new CellRangeAddress(0, 0, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1));
|
firstSerie.setXValues(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
|
||||||
firstSerie.setYValues(sheet, new CellRangeAddress(1, 1, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1));
|
firstSerie.setYValues(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
|
||||||
|
|
||||||
ScatterChartSerie secondSerie = data.addSerie();
|
ScatterChartSerie secondSerie = data.addSerie();
|
||||||
secondSerie.setXValues(sheet, new CellRangeAddress(0, 0, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1));
|
secondSerie.setXValues(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
|
||||||
secondSerie.setYValues(sheet, new CellRangeAddress(2, 2, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1));
|
secondSerie.setYValues(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1));
|
||||||
|
|
||||||
chart.plot(data, bottomAxis, leftAxis);
|
chart.plot(data, bottomAxis, leftAxis);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.ss.util;
|
package org.apache.poi.ss.util;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.formula.SheetNameFormatter;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.record.SelectionRecord;
|
import org.apache.poi.hssf.record.SelectionRecord;
|
||||||
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
|
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
|
||||||
@ -89,7 +90,7 @@ public class CellRangeAddress extends CellRangeAddressBase {
|
|||||||
public String formatAsString(String sheetName, boolean useAbsoluteAddress) {
|
public String formatAsString(String sheetName, boolean useAbsoluteAddress) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
if (sheetName != null) {
|
if (sheetName != null) {
|
||||||
sb.append(sheetName);
|
sb.append(SheetNameFormatter.format(sheetName));
|
||||||
sb.append("!");
|
sb.append("!");
|
||||||
}
|
}
|
||||||
CellReference cellRefFrom = new CellReference(getFirstRow(), getFirstColumn(),
|
CellReference cellRefFrom = new CellReference(getFirstRow(), getFirstColumn(),
|
||||||
|
Loading…
Reference in New Issue
Block a user