use of org.apache.poi.ss.usermodel.charts.ScatterChartSeries in project poi by apache.
the class XSSFScatterChartData method addSerie.
public ScatterChartSeries addSerie(ChartDataSource<?> xs, ChartDataSource<? extends Number> ys) {
if (!ys.isNumeric()) {
throw new IllegalArgumentException("Y axis data source must be numeric.");
}
int numOfSeries = series.size();
Series newSerie = new Series(numOfSeries, numOfSeries, xs, ys);
series.add(newSerie);
return newSerie;
}
use of org.apache.poi.ss.usermodel.charts.ScatterChartSeries in project poi by apache.
the class TestXSSFScatterChartData method testOneSeriePlot.
@Test
public void testOneSeriePlot() throws IOException {
Workbook wb = new XSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, plotData).build();
Drawing<?> drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
Chart chart = drawing.createChart(anchor);
ChartAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
ChartAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
ScatterChartData scatterChartData = chart.getChartDataFactory().createScatterChartData();
ChartDataSource<String> xs = DataSources.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
ScatterChartSeries series = scatterChartData.addSerie(xs, ys);
assertNotNull(series);
assertEquals(1, scatterChartData.getSeries().size());
assertTrue(scatterChartData.getSeries().contains(series));
chart.plot(scatterChartData, bottomAxis, leftAxis);
wb.close();
}
Aggregations